fps question...
Hello, i am a beginner openGL programer.
I wanted to ask how to add a fps counter in my program
thanks for your help!
Hell World Game/3d EngineFind it at http://www.angelfire.com/on3/ironhell3index/HellWorld.html
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
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

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

thanks for the help.but because i don''t yet know much of opengl can you show me an exampla or something like that?
Hell World Game/3d EngineFind it at http://www.angelfire.com/on3/ironhell3index/HellWorld.html
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/
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/
With best regards, Mirek Czerwiñski
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.
I use timeGetTime() function for timeing, it works fine and requires no extra hardware as with a multimedia timer.
look it up on msdn.
look it up on msdn.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
Hi,
On my site, I''ve a program for displaying FPS on the screen.
========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
On my site, I''ve a program for displaying FPS on the screen.
========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
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/
With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/
With best regards, Mirek Czerwiñski
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
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
http://www.lectersoft.com
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?
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?
Hell World Game/3d EngineFind it at http://www.angelfire.com/on3/ironhell3index/HellWorld.html
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement