glFlush and glFinish

Started by
10 comments, last by Silly_con 21 years ago
What are the difference between glFLush and glFinish functions?
Advertisement
From MSDN:

quote:
The glFlush function forces execution of OpenGL functions in finite time.

The glFinish function blocks until all OpenGL execution is complete.

On the language different than the MSDN trash that means:

call glFlush instead of SwapBuffers if you are using single-buffered mode and call glFinish at the end of your rendering function to finish all OpenGL pipeline ops.

The PAIN is coming...this summer!!!In cinemas everywhere.
No, you can''t call glFlush instead of SwapBuffers. glFlush doesn''t swap front/back buffers and SwapBuffers doesn''t execute the OpenGL command pipeline.
Sphinx: read again. He said "in single-buffered mode". Although I can''t imagine why anyone would want a single buffer mode anyway...

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

I''ve got another question related to glFinish. In what kind of way does it block? Does it "suspend" the current thread/process until it gets a signal to continue, or does it poll the pipeline until its execution is complete? I mean in the first way the os could give some cpu time to another thread/process or make the cpu sleep for some time if none is waiting.

eloso
quote:Original post by eloso
I''ve got another question related to glFinish. In what kind of way does it block? Does it "suspend" the current thread/process until it gets a signal to continue, or does it poll the pipeline until its execution is complete? I mean in the first way the os could give some cpu time to another thread/process or make the cpu sleep for some time if none is waiting.

eloso


Nope.The only thing that glFinish do is not to return from the function exucusion while all of the pipeline commands aren''t finished.When they are,the function returns.

The PAIN is coming...this summer!!!In cinemas everywhere.
But when it does not return it must do something. Either go to sleep and wait for a signal/interrupt/whatever or go into a loop that polls the pipeline state and breaks when the pipeline has finished. And that''s my question.

eloso
The second is right.I explain it so(ofcourse this is my opinion).glFinish posts some command to the pipeline and blocks it.When it the posted message is resieved the pipeline is clear.

The PAIN is coming...this summer!!!In cinemas everywhere.
If i understood you right it is not a good idea to call glFinish directly after all gl calls if maybe some AI could be computed for the next frame even if they are in another thread. So it is better to first do all the rendering stuff and then compute ai/physics/sound/... as long as you guess the pipeline would need to finish, right?

Btw. is it possible to just check whether the pipeline has finished?

sorry for my obtrusive asking, but i think this is a very important aspect which is not covered by any OpenGL book i''ve read.

eloso

This topic is closed to new replies.

Advertisement