Jump to content
  • Advertisement
Sign in to follow this  
jcr83

Calculate frame rate Direct3D C#

This topic is 4862 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, How can I calculate on my own how many frames there are at one second. (Not using the SDK user interface) and besides that give a limit to it (for use with audio video playback) Greetz, Johan Reitsma

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jcr83
Hi,

How can I calculate on my own how many frames there are at one second.
(Not using the SDK user interface)

Greetz,

Johan Reitsma


You need only two pieces of information for this:

1. Some counter of how many times you've rendered (often how many Present() calls have been made).

2. A timer to indicate how much time has elapsed since you last checked.

The first one is pretty simple, but the second one you might have to look up some of the basic timing functions in the .Net API.

A trivial implementation, in pseudo code, would be:


//Place this right after a scene has been rendered
if( (current_time - last_checked_time) >= 1000ms ) then
current_frame_rate = frames_rendered //copy this for use later in text output
frames_rendered = 0 //reset the counter for the next 1-second interval
last_checked_time = current_time //reset the timer to start counting again
else
frames_rendered = frames_rendered + 1
end if


hth
Jack

Share this post


Link to post
Share on other sites
There are also an insane INSANE amount of wars right now on the proper
"main loop" structure within a Managed C# game. This could also directly
affect your framerate..

Google for Tom Miller's blog and he mentions a link on the current "best practice"
for the main loop.

Share this post


Link to post
Share on other sites
Ugh, timing in C#.. last time i checked the best way was to somehow attach the win32 dll to get the QueryPerformanceCounter functions :S

That's pretty much when i descided to stop looking into c# mdx.. that and the fact that templates doesn't exist, yet.

Oh hell, the main loop thing. That was the first question i was asking myself - "pumping paint messages, that can't be the way to do it"... then we have the Render(); App.DoEvents(); design which makes alot more sense but still.

When it comes to mdx c#, what they're lacking is the thing they're saying they have, standards.

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!