I am using an FPS counter class from an open source project and I am having a weird issue. When I run it on my Toshiba Satellite (very fast), the counter seems to max out at 60fps. That's great. Not a problem. I do have another computer, an EEE and it will clock the FPS as high as it will go. In some cases, it can get 132fps and it's a much slower computer. This makes it hard to test for framerate increasing on my main coding computer.
So obviously the issue is something non the code calls that is different across processors. Can any of you with a keen eye find out what it is and suggest alternatives? Thank you so much!
header:
#ifndef FPS_COUNTER_H
#define FPS_COUNTER_H
class FPS_COUNTER
{
public:
void Update(void); //updates counter - call once per frame
void Shutdown(void); //send max, min, average to log
float GetFps(void) { return fps; }
FPS_COUNTER() : fps(0.0f), lastTime(0.0f), frames(0L), time(0.0f)
{}
~FPS_COUNTER() {}
protected:
float fps;
float lastTime;
long frames;
float time;
};
#endif //FPS_COUNTER_H
CPP
#include <windows.h>
#include "LOG.h"
#include "FPS_COUNTER.h"
extern LOG errorLog;
void FPS_COUNTER::Update(void)
{
//keep track of time lapse and frame count
time = timeGetTime()*0.001f; //get current time in seconds
++frames; //increase frame count
if(time-lastTime>1.0f) //if it has been 1 second
{
fps = frames/(time-lastTime); //update fps number
lastTime= time; //set beginning count
frames = 0L; //reset frames this second
}
}
Edit: I assume it's in the call to timeGetTime() - is there any way to make it behave the way it does on my EER across any processor?
Check if Vsync is enabled in the computer that caps at 60 FPS. Vsync does exactly cap the framerate to the motitor sync rate. To get uncapped FPS, just disable Vsync in the graphics drivers control panel.