View Full Version : Frame limiting
12-22-2003, 08:46 PM
How would I go about frame limiting, I'm basing my code off the time based movement tutorial on gametutorials.com. Now I have moved to a different computer and my program is rendering way too fast (1000 fps) And I need to limit it so I don't get tearing of the image. I have no idae how to go about doing this, any help would be appreacated.
12-23-2003, 12:19 AM
Turn on vsync or change the code that does the rendering, don't know what it look's like but you might want to modify it there.
It also does depend on your OS, many windows application just put a stupid loop that calls PeekMessage() and if there is none it goes wild rendering zillions frames per second and hogging 102% cpu time or so.
You could use a high resolution timer and set a maximum framerate to limit the rendering.
But if the only problem is image tearing you should be fine if you just turn on vsync.
12-23-2003, 12:19 AM
I don't see what this has to do with OpenGL, btw.
12-23-2003, 01:47 PM
Okay thanks, but how would I go about turing on vsync, I don't have any books with me fight now, and the code is in openGL thats what it has to do with it.
If you code on windows, see : http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt
wglSwapIntervalEXT(1); // vsync ON
wglSwapIntervalEXT(1); // vsync OFF
Beware, these settings can be overriden by the driver (on NVidia, and probably on ATI too). Tweak 'vertical sync' on the Display Control Panel.
Sorry for the misprint :
wglSwapIntervalEXT(0); // vsync OFF
12-24-2003, 09:33 AM
Thanks but it seems to be giving me erorr 0x0005 or something like that I don;t thaink that has enough zeros, is that an access violation error?
Just get the system time and put an if statement:
... render the scene
this will work fine and will give you more cpu time for other applications.
Can't remember exactly but the name of the function you need was GetSystemCount() or wasn't :eek:
12-28-2003, 11:45 PM
Do you have an active rendering context when you call wglSwapIntervalEXT ?
07-16-2004, 05:35 AM
Um, just wondering, i've seen alot about wglSwapIntervalEXT, but how am i able to get it to work in my program? using visal basic 6 at the moment, and it doesn't have the procedure and keeps asking for one, can't figure out where to get it...
either that, or could someone help me with a way in visual basic 6 to limit the frames?
07-16-2004, 01:24 PM
Having never seen Visual Basic code, I'm not sure how you'd get at the extensions, however I'm sure there's a way to get the system time in milliseconds, in which case busy-waiting on that would work, as TheHighKingBG suggests.
07-16-2004, 11:33 PM
geh! i seriously just can't grasp this damn timer concept, not at all >.< so frustrated at the moment beucase of that.
i know this is asking abit, but could someone either put it in real lamens terms about how to do it, or put some code up for it showing an example? :( i just don't get it!
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.