Lock FPS to refresh rate

Started by
4 comments, last by gimp 23 years, 8 months ago
How would I ensure that my code is ''in sync'' with the current video refresh rate. Is locking the FPS sufficient(say using a high performance timer) or is there a way of using the video subsystem to do it?
Chris Brodie
Advertisement
certains cards i believe have this in the display tab options

opengl its
wglSwapIntervalEXT(0); no vsync
wglSwapIntervalEXT(1); vsync
and also 2 but i forget what that does
Hi,

Unless you can actually control the refresh rate then you will be better off programming your game such that it doesn''t care what it is. Otherwise, if you program your sprites to move a certain number of pixels per frame and the framerate changes then the sprites will move faster or slower than you intended.

So, program a time based movement system (such that the sprites move a certain distance over a specified time ie. n pixels per second). Each time you come to move the sprites calculate the time elapsed since the last movement and calculate the distance to move accordingly.


Niv
Nivelo: Are you a fan of RED DWARF or Esperanto? Level

-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
Check out our NPC AI Mailing List :
http://www.egroups.com/group/NPCAI/
made due to popular demand here at GDNet :)
Nivelo,

The reason I''m locking the fps to allow dynamic tesselation of objects with ''remaining CPU time'' for a given scene. Hence more objects in a scene will run with lower tesselations, or less objects will run with higher tesselations.

Your example is very quake-like (previously my view as well). Can you imagine what happens to your scene iof 100 characters in the distance come walking over a hill towards you? In my example the FPS would be 60 and thats it on a TNT2 OR a geforce. The difference will be that the geforce will represent the characters with more detail.

Locking the fps to the refresh is a well known way of improving percieved image quality so that the images sent to the video card are sent at an even interval thats in sync with the timing of it''s ''reads''. I won''t bother listing the reasons why, here is a good link :http://www.penstarsys.com/editor/30v60/30v60p1.htm

As for movement rates, my game will have timed events so that all game events are executed at a set timed interval. This is locked to the networking layer that synchronises at a set speed(lockstepping).

Ideally what I''d like to find out from an ~OpenGL API what refresh the monitor is running at.

Hey zedzeek, what does ''no vsync'' do?
Chris Brodie
i wroyte a little program yesterday http://members.xoom.com/myBollux win_swap_interval_extension see for yourself what no vsync does

This topic is closed to new replies.

Advertisement