Add support for application.frameRate

This commit is contained in:
Joshua Granick
2015-05-14 16:29:31 -07:00
parent 2ebbb58493
commit cb87783f2b
8 changed files with 171 additions and 19 deletions

View File

@@ -27,6 +27,8 @@ namespace lime {
currentApplication = this;
framePeriod = 1000.0 / 60.0;
#ifdef EMSCRIPTEN
emscripten_cancel_main_loop ();
emscripten_set_main_loop (UpdateFrame, 0, 0);
@@ -203,7 +205,6 @@ namespace lime {
void SDLApplication::Init () {
framePeriod = 1000.0 / 60.0;
active = true;
lastUpdate = SDL_GetTicks ();
nextUpdate = lastUpdate;
@@ -441,6 +442,21 @@ namespace lime {
}
void SDLApplication::SetFrameRate (double frameRate) {
if (frameRate > 0) {
framePeriod = 1000.0 / frameRate;
} else {
framePeriod = 1000.0;
}
}
static SDL_TimerID timerID = 0;
bool timerActive = false;
bool firstTime = true;

View File

@@ -28,6 +28,7 @@ namespace lime {
virtual int Exec ();
virtual void Init ();
virtual int Quit ();
virtual void SetFrameRate (double frameRate);
virtual bool Update ();
void RegisterWindow (SDLWindow *window);