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

FPS problems

Started by Kaezin Aug 2, 2002 at 11:50 PM 9 replies 1.4k views
Original Post
Kaezin
Kaezin
My FPS counter isn't working right, here's my code:
    
fTick=(float)GetTickCount();
FPS=1/((fTick-fPrevTick)/1000);
fPrevTick=fTick;
  
It is called everytime I go through my main game loop. Any problems with that? I'm getting a constant FPS of 100. [edited by - Kaezin on August 3, 2002 1:12:51 AM]
Half the people you know are below average.Trogdor the Burninator
Aram
Aram
Maybe its because of that GetTickCount() has an error of 0.01s.
Try using QueryPerformanceFrequency and QueryPerformanceCounter.

//Aram
True words are not always beautiful, beautiful words are not always truthful.
Kaezin
Kaezin
I tried using those but now I''m getting 0.000000 for my FPS. How am I supposed to use those functions?
Half the people you know are below average.Trogdor the Burninator
shurcool
shurcool
first of all, when u say something like float x = 1 / 5; u have 0 in x. if u say x = 1.0 / 5.0;, then you have 0.2 in x. be careful about that.

---
shurcool
wwdev
Kaezin
Kaezin
I checked MSDN and that didn''t help at all.
Half the people you know are below average.Trogdor the Burninator
Aram
Aram
This is how I use it...

//Init this in the begining
LARGE_INTEGER CLOCKFREQUENCY;
QueryPerformanceFrequency(&CLOCKFREQUENCY);


//Do this to get the time in millisecs
LARGE_INTEGER CLOCKCOUNT;
QueryPerformanceCounter(&CLOCKCOUNT);
TimeInMS = (CLOCKCOUNT.QuadPart*1000)/CLOCKFREQUENCY.QuadPart;



//Aram
True words are not always beautiful, beautiful words are not always truthful.
Alex Salo
Alex Salo
Hey guy!
There is nothing hard to get the FPS. Look at my code, for example: (input it in mainloop()

clock_t clock();
seconds=clock()/CLOCKS_PER_SEC;
counterFPS+=1; //you just forgot to write this line
fps=counterFPS/seconds;

This code is working well!

________________
Alex Salo
alexsalo@ukr.net
____Alex Saloalexsalo@ukr.net
initial_y
initial_y
how about timeGetTime() method?
I use this method() to count FPS.is it right?

汇编语言不会编
Zoot
Zoot
fTick=(float)GetTickCount();
FPS=1.0f/((fTick-fPrevTick)/1000);
fPrevTick=fTick;



It should be "1.0f" not "1"...
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!

Topic Locked

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

Sign in to reply to this topic.