Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Hlubocky

glFlush() ... should I use it?

This topic is 6335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
> 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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!