Question

I have a program where I use a shader program to render to a texture attached to a FBO then change the parameters of the program (by changing the values of the uniforms) and render to a second texture after attaching it to the FBO. The two rendered images are then used to generate a third one.

I'm not sure if the results I'm getting is correct. I understand that the GPU will be free to choose the time at which to execute an OpenGL command. But that should not be a problem so long as the order of execution does follow the sequence in which the commands appear in the code. Is this actually the case?

A follow-up question. I need to save the generated frames to disk. I know how to that. But I need to make sure that the GPU has completed the rendering before doing so. How can I enforce that?

Was it helpful?

Solution

OpenGL will execute the commands in the order they're issued (or at least simulate this behavior). This means, that there is no problem with using 2 different FBOs, one after another. Also this means OpenGL will make sure, that your rendering is complete at the time you get your result from the FBO.

You can call glFinish() to have your program wait until all pending OpenGL commands have been processed by the pipeline, but this is unnecessary in almost all cases.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top