Reputation: 879
I have a an application which uses OpenGl's fixed-pipeline to render images on screen along with some GUI. Before this takes place, I want to use the shaders-based pipeline, to do some image-processing manipulations on the image, and to render it to a texture. This texture I would then pass on to the existing application. Basically the current flow looks like this:
cpu image --> gpu texture --> fixed-pipeline processing --> display on screen
and I want to make it look like this:
cpu image --> gpu texture --> rendering passes to enhance the image --> gpu texture --> fixed-pipeline processing --> display on screen
My question is this: How do I switch between these different operation modes? I have seen some previous questions (1,2,3,4), but none answers my specific problem. Perhaps it's just a simple matter of unbinding the Vertex Arrays?
Now that I have a good answer for this question from @Reto Koradi, I have yet another one: Any idea how much time this sort of mode-changing might take? is there any 'flushing' going on when I switch back to the fixed pipeline?
Upvotes: 0
Views: 639
Reputation: 54642
To switch from your shader based rendering back to the fixed pipeline:
glUseProgram(0);
To switch from your FBO rendering back to rendering to the default framebuffer:
glBindFramebuffer(GL_FRAMEBUFFER, 0);
You can use vertex arrays in the fixed pipeline. But if you want to unbind your vertex arrays/buffers, it's the same thing. Just bind 0 to release your bindings, e.g.:
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
Edit: Answer to follow-up question about the overhead.
The simple answer is... it depends. Overhead for certain operations can be very different depending on platform/hardware. As far as it can be answered in relatively general terms:
Upvotes: 1