Browse Source

Store the requested FPS in the Ticker class.

legacy
Sam Hocevar sam 14 years ago
parent
commit
c5aea027b9
2 changed files with 10 additions and 2 deletions
  1. +8
    -1
      src/ticker.cpp
  2. +2
    -1
      src/ticker.h

+ 8
- 1
src/ticker.cpp View File

@@ -139,6 +139,11 @@ int Ticker::Unref(Entity *entity)
return --entity->ref; return --entity->ref;
} }


void Ticker::Setup(float fps)
{
data->fps = fps;
}

void Ticker::TickGame() void Ticker::TickGame()
{ {
Profiler::Stop(Profiler::STAT_TICK_FRAME); Profiler::Stop(Profiler::STAT_TICK_FRAME);
@@ -308,10 +313,12 @@ void Ticker::TickDraw()
Profiler::Start(Profiler::STAT_TICK_BLIT); Profiler::Start(Profiler::STAT_TICK_BLIT);
} }


void Ticker::ClampFps(float deltams)
void Ticker::ClampFps()
{ {
Profiler::Stop(Profiler::STAT_TICK_BLIT); Profiler::Stop(Profiler::STAT_TICK_BLIT);


float deltams = data->fps ? 1000.0f / data->fps : 0.0f;

if (deltams > data->bias + 200.0f) if (deltams > data->bias + 200.0f)
deltams = data->bias + 200.0f; // Don't go below 5 fps deltams = data->bias + 200.0f; // Don't go below 5 fps
if (deltams > data->bias) if (deltams > data->bias)


+ 2
- 1
src/ticker.h View File

@@ -28,9 +28,10 @@ public:
static void Ref(Entity *entity); static void Ref(Entity *entity);
static int Unref(Entity *entity); static int Unref(Entity *entity);


static void Setup(float fps);
static void TickGame(); static void TickGame();
static void TickDraw(); static void TickDraw();
static void ClampFps(float deltams);
static void ClampFps();
static int GetFrameNum(); static int GetFrameNum();


static void Shutdown(); static void Shutdown();


Loading…
Cancel
Save