瀏覽代碼

Store the requested FPS in the Ticker class.

legacy
Sam Hocevar sam 14 年之前
父節點
當前提交
c5aea027b9
共有 2 個檔案被更改,包括 10 行新增2 行删除
  1. +8
    -1
      src/ticker.cpp
  2. +2
    -1
      src/ticker.h

+ 8
- 1
src/ticker.cpp 查看文件

@@ -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 查看文件

@@ -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();


||||||
x
 
000:0
Loading…
取消
儲存