SwapBuffers performance

Hi all,

i’ve been timing functions looking for bottlenecks in my code and found that the call to SwapBuffers was taking on average 15ms… i find this high but is it normal?

the pixel format is 32bit color / 24bit depth / 8bit alpha / 8bit stencil

geforce4 ti 4200
system is p4 1.7ghz / 2gigs ram

thanks for lookin

I assume you have looked at if vsync is set in the driver or your code?

Yes it’s normal, SwapBuffers makes sure everything is finished before it swaps the buffers, and if you have vsync on then it waits even longer until the next frame starts to redraw.

SwapBuffers does not really do anything in this time. So if you use more CPU time outside SwapBuffers, the wait time decreases and the whole frame time should stay (roughly) the same.

Could anyone tell me how to make vsync on/off in code? Thank you.

wglSwapInterval

thanks for replying guys…

about vsync, my understanding has been that if its disabled you’ll skip or miss frames(but of course you get better framerates)… is this correct?

(for my program i’m doing video playback and its critical that i’m getting every frame)

thanks again

VSync works kind of like this:

Say your monitor has an update rate of 60Hz (60-100Hz is common)

Say your application can run at 120 FPS.

With vsync disabled, the user sees half of one frame and half of another frame. (Commonly called tearing)

With VSync enabled you will get exactly 60 FPS.

The catch is, if you app can only run at 45 FPS, the user sees 30FPS with Vsync enabled. (or even worse if your app runs at 29FPS, it will clamp to 15FPS)

thanks, but why my compiler tell me that wglSwapInterval undeclared identifier ? is it an extention? how can i use it?

Yes it is an extension.
Look at the OpenGL wiki for how to load extensions or use GLee or GLew.

(You may also be searching for wglSwapIntervalEXT )

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.