Jump to content
  • Advertisement
Sign in to follow this  
Esmo2000

How to run a game timer

This topic is 4425 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone: I wanted to ask a question about what's the best approach for timing on a game. I noticed somewhere that tell the Glut idle function to point to your render loops was a bad idea. However, I don't see another way to make the game run as fast as it can. The alternative was to set a desired framerate in a timer class and set the call backs based on that. Both seem to resolve to pretty much the same thing if the computer can't handle the desired frame rate, but the idle function approach goes faster if they can. I read somewhere that it was bad form to use the idle function but I don't recall seeing a reason, and don't know what it could be. Suggestions anyone? Thanks! [Edited by - Esmo2000 on July 6, 2006 12:13:10 AM]

Share this post


Link to post
Share on other sites
Advertisement
Hi,

In Glut, the display function should call your render function because it is designed to that end (to be more precise to internally comply with the way windows updates the screen).

However the idle function may call your logic update function. The idle function is called each time the program is not either displaying a scene or processing a windows message (like keyboard messages).

To have a better view on the timing of your game, I propose you separate your game loop in two parts:
1- rendering part called by display
2- logic/AI part called by idle

This will enable you to time the rendering part and the logic part separately. By adding another timer you can also change the update rate of the logic loop (you could update the logic 8 times per second instead of 24 or 32 times per second: depends on what your logic function does).

Timing separately the rendering loop lets you better control any optimization you may add to the rendering system (frustum culling, occlusion culling, use of vertex arrays, ...)

Hope that helps.
Ghostly yours,
Red.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!