SwapBuffers is waiting for something?

Hey there I’m making a multi-threaded application in OpenGL in a Windows enviroment.

So everything is working fine except that i’d like to control my own fps instead of letting windows or opengl do it.

So I identified what is blocking my fps rate and its the SwapBuffers( hDC ) function that seems to be blocking, waiting for next frame or something.

My question: is there a diffrent command that i could use besides SwapBuffers? So that I could increase/control my fps?

or someother command that’ll increasy my opengl fps?

Normally SwapBuffers synchronizes with the next vertical retrace (monitor frame). Disable sync-to-vblank to disable that behavior. Several ways. On Linux, “setenv __GL_SYNC_TO_VBLANK 0”, or in nvidia-settings, uncheck “Sync to VBlank” in OpenGL Settings. But the clean way (on all OSs) is to use the SwapInterval API. Search the archives for some good info there.

That won’t make SwapBuffers free (particularly if you have a complicated AA resolve that needs performed or a lot of GL work still in the queue), but it will stop it from busy waiting for the video scan-out. To minimize the amount of queued GL work processed inside of SwapBuffers, it can also be useful (for testing/timing use only!!!) sometimes to trigger a glFinish before SwapBuffers, to ensure that all the queued GL work is done before you enter SwapBuffers.

Use wglSwapIntervalEXT(0) or glXSwapIntervalSGI(0) to disable vertical synchronization. Note that this will introduce tearing and significantly reduce quality (some people cannot see tearing, others cannot stand it). If you must disable vsync, at least make it an option.

Also note that users can force-enable vsync through their drivers, regardless of what you try to do in your application.

thanks for the quick replys but i dont get what files i need to download, i downloaded wglext.h but i’m guess i need the cpp files and maybee more?

i ended up in theese pages but theres no links to more downloads.


where to download the extensions? very confusing.
please be be kind and post a small guide on how to get theese. thank you.

wglSwapIntervalEXT = wglGetProcAddress(“wglSwapIntervalEXT”);

it doesn’t work. but i guess i dont need it. it works when i change vertical-sync in the nvidia control panel though.

thanks for the help all.

oh hey i did make it work. i just did some bad boolean coding. still dont need it though but i was curious :P. thanks all.

#include <gl\wglext.h>

void SetVSync(bool sync)
    wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");