glFlush() ... should I use it?

Started by
2 comments, last by Hlubocky 22 years, 9 months ago
I''m writing a program and having a bit of trouble with fullscreen mode as you may have seen in my other post. I saw a related post on these forums regarding glFlush() and its solving of someone elses problem. This got me thinking....I''m not using glFlush in my program, maybe I should. I know the function is used to force the program to execute all gl commands in the buffer, or something like that. Should I put it at the end of my rendering loop? What are the uses for glFlush()? Thanks for your time! Brian hlubocky@uiuc.edu
Advertisement
OpenGL is set up so that the commands go through a pipeline structure. The pipeline needs to fill up with commands before any of them will be executed, and then the commands are executed one at a time, like a queue. glFlush takes all the commands from the pipeline and executes them, so that everything gets completed for the frame. So, if it looks like everything you want done doesn''t seem to be executed every frame, you probably want to put glFlush at the end of your rendering function. However, if you are using double buffering and GLUT, you''ll have a call to glutSwapBuffers, which makes a call to glFlush itself. You may want to put a call to glFlush, anyway, just in case. Hopefully that was a decent explanation of the way glFlush works.

It might be easier to diagnose the problems you are having if you posted the exact problems you are having.
> glFlush takes all the commands from the pipeline and executes them, so that everything gets completed for the frame.

Nope, it doesn''t. From the OpenGL1.2 specs:

The command void glFlush( void ); indicates that all commands that have previously been sent to the GL must complete in finite time.
The command void glFinish( void ); forces all previous GL commands to complete.

In practice, you don''t need any of them, if you are double buffering. It''s mainly there for debugging and profiling, or if you are interleaving gl commands and direct access to the framebuffer.

-JL
glFlush would be useful if you were using X-windows on a network server type system to "flush" all the commands, local machines generally dont need it

This topic is closed to new replies.

Advertisement