Sign in to follow this  

Time and C++

This topic is 4660 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

I'm writing a DirectX program and need to find a way to keep the frames the same length - to avoid the jumpiness and so on. What are some time-related functions that could be of use to me?

Share this post


Link to post
Share on other sites
QueryPerformanceFrequency()
QueryPerformanceCounter()

You can do something like this to get a millisecond time (since the computer was switched on I think).

QueryPerformanceFrequency(&this->QPFret);
QueryPerformanceCounter(&this->QPCret);
UINT milli = (UINT)((this->QPCret.QuadPart*1000)/this->QPFret.QuadPart) );

Check out this aswell.

Share this post


Link to post
Share on other sites
Quote:
Original post by noVum
You don't want to fix the framerate, just calculate your changes dependent on the frame time.


Often you do want to fix the framerate, You'll hear console games often refer to a "solid 30 frames a second" or 60 frames a second.

YOu never hear them say, "well we just let the framerate depend on the frametime, sometimes its 2 frames a second , sometimes its 60, but ho one really cares if the game runs at 2 frames a second:)"

Cheers
Chris

Share this post


Link to post
Share on other sites
Why should they fix the framerate? Either you have the power for >30FPS or you don't. Fixing it to 30FPS will only have drawbacks.

I've never seen a PC game that does it, I would be very astonished if console games would be different.

Share this post


Link to post
Share on other sites
Quote:
Original post by chollida1
Often you do want to fix the framerate, You'll hear console games often refer to a "solid 30 frames a second" or 60 frames a second.

YOu never hear them say, "well we just let the framerate depend on the frametime, sometimes its 2 frames a second , sometimes its 60, but ho one really cares if the game runs at 2 frames a second:)"

Cheers
Chris


Yeah, because "fixing the framerate" will make a game that runs at 2fps magically run at 30fps.
You (usually) let your system do everything you need as fast as possible, and do all the movment, physics, etc. calculations time-since-last-frame based.

Share this post


Link to post
Share on other sites
Quote:
Original post by noVum
Why should they fix the framerate? Either you have the power for >30FPS or you don't. Fixing it to 30FPS will only have drawbacks.

I've never seen a PC game that does it, I would be very astonished if console games would be different.


Doom3 limits your framerate at 60. If your frame difference is very small it can cause problems with physics code IIRC. And to chollida1: You cant just limit the rendering to 30fps and then have any code that would usually run at 2fps to magically run 15 times faster;)

Ive read some articles that make a point for keep the physics steps the same (e.g. every 20ms) as apparently this makes using some syswtems more accurate but im not to clue'd up on physics to be able to comment more.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
With round-off error, having consistant timesteps for physics code is a GREAT help when it comes to making fully deterministic game engines.

That being said, you shouldn't fix the framerate. It's better to draw as often as possible and interpolate the positions as nessesary. ( And with usual physics timesteps [100ms or lower], straight linear interpolation is fast and looks fine. )

Share this post


Link to post
Share on other sites
Quote:
Original post by noVum
Why should they fix the framerate? Either you have the power for >30FPS or you don't. Fixing it to 30FPS will only have drawbacks.

I've never seen a PC game that does it, I would be very astonished if console games would be different.


Almost all console games now limit the framerate. You can say they don't but it won't make it anymore true:) As for PC games, as mentioned above Doom3 does it and the guys at ID know a little about PC games:)

If they can't get 60 frames they cap at 30 usally so the frame rate doesn't vary.

Cheers
Chris

Share this post


Link to post
Share on other sites
Quote:
Original post by vNistelrooy
Quote:
Original post by chollida1
Often you do want to fix the framerate, You'll hear console games often refer to a "solid 30 frames a second" or 60 frames a second.

YOu never hear them say, "well we just let the framerate depend on the frametime, sometimes its 2 frames a second , sometimes its 60, but ho one really cares if the game runs at 2 frames a second:)"

Cheers
Chris


Yeah, because "fixing the framerate" will make a game that runs at 2fps magically run at 30fps.
You (usually) let your system do everything you need as fast as possible, and do all the movment, physics, etc. calculations time-since-last-frame based.


That's not what I meant, if english isn't your first langauge I understand:) ALl I was trying to point out is taht framerates are often locked in at a certain level, as mentioned doom 3 uses 60 fps.

This is so the developers have soemthing to aim for and to try to keep the frame rate at that level always:)

Cheers
Chris

Share this post


Link to post
Share on other sites
Quote:
Original post by chollida1
Quote:
Original post by vNistelrooy
Quote:
Original post by chollida1
Often you do want to fix the framerate, You'll hear console games often refer to a "solid 30 frames a second" or 60 frames a second.

YOu never hear them say, "well we just let the framerate depend on the frametime, sometimes its 2 frames a second , sometimes its 60, but ho one really cares if the game runs at 2 frames a second:)"

Cheers
Chris


Yeah, because "fixing the framerate" will make a game that runs at 2fps magically run at 30fps.
You (usually) let your system do everything you need as fast as possible, and do all the movment, physics, etc. calculations time-since-last-frame based.


That's not what I meant, if english isn't your first langauge I understand:) ALl I was trying to point out is taht framerates are often locked in at a certain level, as mentioned doom 3 uses 60 fps.

This is so the developers have soemthing to aim for and to try to keep the frame rate at that level always:)

Cheers
Chris


If that was your point then why did you say "but who one really cares if the game runs at 2 frames a second" because that has nothing to do with limiting the framerate.

Share this post


Link to post
Share on other sites
What are the advantages of limiting the framerate to 30?
If you get steady >30 fps then that's of course better than fixed 30 fps.

And btw. D3 is not limiting the framerate. Only the game logic is limited to 60fps in a seperate thread.

Share this post


Link to post
Share on other sites

This topic is 4660 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this