View Full Version : Frame Limiter???

04-29-2006, 02:47 PM
I want make a frame limiter for my opengl application, what can i do?

Ehsan Kamrani
04-29-2006, 02:56 PM
The book OpenGL Game programming has a timer class that locks the frame rate to a specified value.
Move to this URL and download the example of chapter 19:
Open the file *HiResTimer.h* and take a look at the function lockFPS().

04-29-2006, 03:21 PM
many many many thanks, it's Working :)

05-03-2006, 10:54 PM
I suggest you the following alternative.

Let the fps free, and make the motion of the objects proportional to a variable Syncronize that changes depending of current fps.

So you set the number of fps you want your program to run. Let's say you want animations to run in 60 fps not more not less, that is 17ms.

So if fps is above 60, then Syncronize is less than 1. If fps is below 60 fps, then Syncronize is more than 1.

This way, you multiply all your objects movements by Syncronize, and all events are syncronized in time independently of the current fps.

glTranslatef MoveX*Syncronize, MoveY*Syncronize, MoveZ* Syncronize

Hope it helps! :)