Reputation: 5044
I have a hook that allows me to render my own model. For this model I want to use a custom vertex shader. Now the problem is that the outer program still renders using the old shader/program methods (glUseProgram) and I want to keep my program compatible when they switch to the new 4.4 ProgramPipeline and at the same time provide the same functionality even if the user doesn't support OpenGL 4.x. Now I thought I could do the following:
//Start of hook
int currProgram = glGetInteger(GL_CURRENT_PROGRAM);
int currVertexShader;
int currPipeline;
if (supportsPipelines) {
glUseProgramStages(pipelineName, EXTERNAL_SHADER_BITS, currProgram);
glUseProgram(0);
// How do I store the currently selected pipeline, if any?
glBindProgramPipeline(currPipeline);
} else {
if(currProgram == 0) {
glUseProgram(programName);
} else {
// Fiddle with the shaders ?
}
}
// Do some rendering
// How do I pop back into the original configuration?
Upvotes: 0
Views: 124
Reputation: 101
To store the current pipeline:
GLint prevPipeline = 0;
glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &previousPipeline);
// assorted error checking
And to restore it:
glBindProgramPipeline(prevPipeline);
Upvotes: 1