Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ironhell3

fps question...

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

Advertisement
hey

well, an fps counter by itself means a "frames per second" counter. what you should do, is init a counter that increments over a 1-second period (a value to measure the number of milliseconds that have passed within the last second) and another counter that is incremented every time you draw a frame (make sure, however, that this is the last thing to do each program cycle, e g add it to the end of the game cycle code or you may not get very correct results). when the first counter reaches 1 second limit (typically 1000 milliseconds, wouldn''t you agree ), display the value of the second counter and reset both counters to zero and do the whole thing over again. to get an fps average, store the second counter''s values after each second in an array and after reaching a specific time limit or on an event (such as a keypress), or why not, on exit, display the arithemtic average of all the members in the array.

well, this how you can make one of your own, but you can also search the net for more illustrative examples.

keep cool

Share this post


Link to post
Share on other sites
ello,
go to:
http://warsztat.pac.pl/mirekcz/mczproj.shtml
and download the "particle and fog test" (press on the src+exe button) , it''s a bad commented and poorly written source that does work. You''re interested in the starttiming() and endtiming() instructions (beggining of main.cpp) which calculate the time passed between starttiming and endtiming function along fps value. You might be also interested in DrawText function that draws text to screen (it simple draws textured quads where the texture is a .tga file with letters)
Hope it helps, sorry for it being poorly written and commented.

With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/

Share this post


Link to post
Share on other sites
quote:
Original post by ironhell3
thanks for the help.but because i don''t yet know much of opengl can you show me an exampla or something like that?



Making an FPS counter has nothing to do with OpenGL. It''s simple addition.

Or do you mean you need to know how to display text?

If you cannot display text as of yet, I don''t see why you would need an FPS counter as the rest of your game must not be very advanced.

Share this post


Link to post
Share on other sites
I use timeGetTime() function for timeing, it works fine and requires no extra hardware as with a multimedia timer.

look it up on msdn.

Share this post


Link to post
Share on other sites
eber kain:the timegettime isn''t a good way to count fps as it isn''t exact. You reall need something better , especially once you start to do some animations/physics stuff. And I haven''t seen a machine on which performace counter wouldn''t work. (Including PocketPC)

With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/

Share this post


Link to post
Share on other sites
something for those who dont wanna look at a website.

int fps()
{
static int number;
static int fps;
static DWORD temp;
number++;
if(GetTickCount()>temp)
{
fps=number;
number=0;
temp=GetTickCount()+1000;
}
return fps;
}



http://www.lectersoft.com

Share this post


Link to post
Share on other sites
Hello.Thanks for your help all you guys.i have some questions to dfawcett:
1) what is the difference between int x; and static int x; ?
2) what is a DWORD ?
3) the fps we return (return fps), how can i use it in a printf?

Share this post


Link to post
Share on other sites

  • 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!