PDA

View Full Version : Async behaviour of SwapBuffers



Alexey
09-04-2002, 12:00 PM
Hi,

I found out that SwapBuffers() returns control BEFORE it actually does the job.

Is there any way to wait until it really finishes?

Humus
09-04-2002, 12:13 PM
Any good reason why you'd want that?

Ozzy
09-04-2002, 12:21 PM
try swapControl EXT..
just a question, your rendering time will be stable and within the refreshPeriod?
if not ask Humus. ^^

mcraighead
09-04-2002, 12:32 PM
Call glFinish immediately afterwards?

- Matt

evanGLizr
09-04-2002, 12:35 PM
Originally posted by Alexey:
Hi,

I found out that SwapBuffers() returns control BEFORE it actually does the job.

Is there any way to wait until it really finishes?

From glFinish:


The glFinish function does not return until the effects of all previously called OpenGL functions are complete. Such effects include all changes to the OpenGL state, all changes to the connection state, and all changes to the framebuffer contents.


Strictly speaking, SwapBuffers is not an OpenGL command, but I wonder if doing a glFinish after calling SwapBuffers will work for you, as it's a change to the framebuffer contents (I would say it's driver dependent, though).

Alexey
09-04-2002, 12:43 PM
Thank you very much!

glFinish() worked fine!

Nakoruru
09-04-2002, 08:42 PM
I am still very curious as to why you would want to wait for SwapBuffers. SwapBuffers just schedules a buffer swap at the next vsync (if you have that enabled). I do not see why you need to wait for it to actually happen, why not go on and start rendering the next frame? If you have vsync enabled it will not cause any tearing.

evanGLizr
09-05-2002, 10:48 AM
Originally posted by Nakoruru:
I am still very curious as to why you would want to wait for SwapBuffers.

You may need to wait for swapbuffers to finish if you want to mix GDI with opengl rendering (not something I would recommend, though).