PDA

View Full Version : FPS - how to manage for smooth movement



06-18-2004, 04:04 AM
Hello everyone. I'm a newbie but 2 questions already raised.

1. Is there a way to set monitor's refresh rate while running a fullscren OpenGL app.

2. Is there a way to synchronize buffer swapping in a double bufferd app with monitor's vertical refresh. Specifically I need something similar to the asynchroneous Direct Draw Flip() method. I'm pasting MSDN snippet to make things clearer:

"When working with visible surfaces, such as a primary surface flipping chain or a visible overlay surface flipping chain, the Flip method is asynchronous unless you include the DDFLIP_WAIT flag. On these visible surfaces, the Flip method can return before the actual flip operation occurs in the hardware (because the hardware doesn't flip until the next vertical refresh occurs). While the actual flip operation is pending, the back buffer behind the currently visible surface can't be locked or blitted by calling the IDirectDrawSurface7::Lock, IDirectDrawSurface7::Blt, IDirectDrawSurface7::BltFast, or IDirectDrawSurface7::GetDC methods. If you attempt to call these methods while a flip operation is pending, they will fail and return DDERR_WASSTILLDRAWING. "

Something like that in OpenGL? Thanks.

Relic
06-18-2004, 04:39 AM
1.) Under Windows you need to enumerate all display settings and chose one.
Look up the manual for EnumDisplaySettings() and ...Ex().
Then switch to your desired resolution with ChangeDisplaySettings().
Do this BEFORE you setup your OpenGL window, because it is not a good practice to change display settings while OpenGL apps run, because you can only select a pixelformat once during the lifetime of a window and bad things can happen if you switch to a resolution which doesn't fit to the pixelformat.

2.) For programmable wait on vertical blank check the swapinterval functions of this extension:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt
Make sure the graphics control panel is set in a mode where it doesn't override your programmed settings.