From c5aea027b9838365def41eb7d4aba7c7a383d69d Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 8 Feb 2011 23:23:54 +0000 Subject: [PATCH] Store the requested FPS in the Ticker class. --- src/ticker.cpp | 9 ++++++++- src/ticker.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ticker.cpp b/src/ticker.cpp index de2b3bff..a8675b60 100644 --- a/src/ticker.cpp +++ b/src/ticker.cpp @@ -139,6 +139,11 @@ int Ticker::Unref(Entity *entity) return --entity->ref; } +void Ticker::Setup(float fps) +{ + data->fps = fps; +} + void Ticker::TickGame() { Profiler::Stop(Profiler::STAT_TICK_FRAME); @@ -308,10 +313,12 @@ void Ticker::TickDraw() Profiler::Start(Profiler::STAT_TICK_BLIT); } -void Ticker::ClampFps(float deltams) +void Ticker::ClampFps() { Profiler::Stop(Profiler::STAT_TICK_BLIT); + float deltams = data->fps ? 1000.0f / data->fps : 0.0f; + if (deltams > data->bias + 200.0f) deltams = data->bias + 200.0f; // Don't go below 5 fps if (deltams > data->bias) diff --git a/src/ticker.h b/src/ticker.h index e6fe9079..6d2bc717 100644 --- a/src/ticker.h +++ b/src/ticker.h @@ -28,9 +28,10 @@ public: static void Ref(Entity *entity); static int Unref(Entity *entity); + static void Setup(float fps); static void TickGame(); static void TickDraw(); - static void ClampFps(float deltams); + static void ClampFps(); static int GetFrameNum(); static void Shutdown();