Skip to main content
gamedev.net
🔒 Locked

Timing

Started by Sappharos 1 reply 900+ views
Original Post
Sappharos
Sappharos
I'm trying to find a neat and reliable method for making an OpenGL program run at precisely 60 fps, while allowing for a frame-rate display. I've tried searching, but every site I've found gives a different method, and none of these seem to be ideal. The official OpenGL site recommends GLUT, but I'm reluctant to use this unless it's absolutely necessary. Could anyone give some advice please? Thanks.
razorjack
razorjack
It's maybe this v-synch you can enable or disable.
Take a look at: http://www.devmaster.net/forums/showthread.php?t=443
My spacesim project blog:http://www.simerge.com/
AndyEsser
AndyEsser
Although this isn't 100% precise (you will never get a 100% precise timer), the way that I implement a framerate limiter is:

1. Start Timer before Rendering
2. Render
3. After rendering, check Timer, if time elapsed < (1000 / 60) then loop
4. When time elapsed > (1000 / 60) then move onto next frame

You can also implement it slightly more accurately by altering (1000 / 60) to represent the actual time and frames left in that second, so if your first frame took 24ms then the 2nd frames calculationg should be (976 / 59) to get the correct frame time.

Hope this helps

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.