mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
That was only part of the problem, now it should all work properly (and more accurately)
This commit is contained in:
@@ -61,7 +61,7 @@ namespace timer
|
|||||||
* once per second, it does not look erratic when displayed on screen.
|
* once per second, it does not look erratic when displayed on screen.
|
||||||
* @return The "current" FPS.
|
* @return The "current" FPS.
|
||||||
**/
|
**/
|
||||||
virtual double getFPS() const = 0;
|
virtual int getFPS() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the amount of time since the program started. Only useful for timing
|
* Gets the amount of time since the program started. Only useful for timing
|
||||||
|
|||||||
@@ -70,11 +70,11 @@ namespace sdl
|
|||||||
// Convert to number of seconds
|
// Convert to number of seconds
|
||||||
dt = (currTime - prevTime)/1000.0;
|
dt = (currTime - prevTime)/1000.0;
|
||||||
|
|
||||||
int timeSinceLast = (currTime - prevFpsUpdate)/1000.0;
|
double timeSinceLast = (currTime - prevFpsUpdate)/1000.0;
|
||||||
// Update FPS?
|
// Update FPS?
|
||||||
if (timeSinceLast > fpsUpdateFrequency)
|
if (timeSinceLast > fpsUpdateFrequency)
|
||||||
{
|
{
|
||||||
fps = frames/timeSinceLast;
|
fps = int((frames/timeSinceLast) + 0.5);
|
||||||
prevFpsUpdate = currTime;
|
prevFpsUpdate = currTime;
|
||||||
frames = 0;
|
frames = 0;
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ namespace sdl
|
|||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Timer::getFPS() const
|
int Timer::getFPS() const
|
||||||
{
|
{
|
||||||
return fps;
|
return fps;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace sdl
|
|||||||
void step();
|
void step();
|
||||||
void sleep(double seconds);
|
void sleep(double seconds);
|
||||||
double getDelta() const;
|
double getDelta() const;
|
||||||
double getFPS() const;
|
int getFPS() const;
|
||||||
double getTime() const;
|
double getTime() const;
|
||||||
double getMicroTime() const;
|
double getMicroTime() const;
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ namespace sdl
|
|||||||
Uint32 prevFpsUpdate;
|
Uint32 prevFpsUpdate;
|
||||||
|
|
||||||
// Updated with a certain frequency.
|
// Updated with a certain frequency.
|
||||||
double fps;
|
int fps;
|
||||||
|
|
||||||
// The frequency by which to update the FPS.
|
// The frequency by which to update the FPS.
|
||||||
double fpsUpdateFrequency;
|
double fpsUpdateFrequency;
|
||||||
|
|||||||
Reference in New Issue
Block a user