Skip to main content
GameDev.net gamedev.net
🔒 Locked

FrameRate Low

Started by DorRaba Jan 21, 2004 at 12:14 PM 2 replies 300+ views
Original Post
DorRaba
DorRaba
My Problem is not like the first one that I posted in this forum, my problem now is that my frame rate always changes form 62 to 31 and backwards, this thing is changing the speed of my app, lets say I have a rotate cube, it will be moving slow and then fast and then slow, can''t I tell the app to have a constant speed of 62 FPS?
DDDDor RRRRaba
DrunkenHyena
DrunkenHyena
This is a problem with Vertical Sync. Your app normally runs at about 62, but occasionally it''s a little bit too slow and so it misses the retrace and has to wait for the next one, this halves your frame rate.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
Agony
Agony
Also, as I''ve read many times on this forum, I would recommend using frame-independent movement. Base the rotation of your cube off of a timer of some sort, rather than what frame number you''re on (or rather than adding a constant number to the amount of rotation every frame). This will save you plenty of headaches later on with animation, I''m sure.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
Supernat02
Supernat02
I agree with the frame independent method. Keep track, you probably already are, of how many milliseconds pass between frames. Then add a time dependent amount of units to your Radians variable based on the milliseconds.


// TimePassed assumed to be an unsigned long updated every frame.

// Radians assumed to be static float somewhere

// Rate assumed to be a static float somewhere, defined as radians to add per millisecond


Radians += (Rate*TimePassed);



If more time passes between render calls, you add more units to the Radians variable.

If you want 0.001f radians per millisecond, and 10 milliseconds pass, you will add 0.01f radians. It''s pretty straight forward. If you want to do it in per second basis:


Radians += (Rate*TimePassed*0.001f);


Chris
Chris ByersMicrosoft DirectX MVP - 2005

Topic Locked

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

Sign in to reply to this topic.