X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FEngine.cc;h=e97c8b5d1b7edbae52a5b48ebc1072574e697ebe;hp=51a3af0f5bfb6d75d71cdaed34cb7bdd9518c3ac;hb=33842c860fe18ca8cf087905992885687434320c;hpb=57b78ebe21b1b48acd337daa5a1cb8c383959cfa diff --git a/src/Moof/Engine.cc b/src/Moof/Engine.cc index 51a3af0..e97c8b5 100644 --- a/src/Moof/Engine.cc +++ b/src/Moof/Engine.cc @@ -31,7 +31,6 @@ #include #include "fastevents.h" -#include #include #include "Dispatcher.hh" @@ -55,9 +54,9 @@ public: interface(outer) { #if defined(_WIN32) || defined (_WIN64) || defined(__WIN32__) - if (SDL_Init(SDL_INIT_EVERYTHING) != 0) + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) #else - if (SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_EVENTTHREAD) != 0) + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) != 0) #endif { logError("sdl is complaining: %s", SDL_GetError()); @@ -68,11 +67,6 @@ public: logError("fast events error: %s", FE_GetError()); throw Exception(Exception::SDL_ERROR); } - if (Sound_Init() == 0) - { - logError("sound initialization failed: %s", Sound_GetError()); - throw Exception(Exception::SDL_ERROR); - } alutInit(&argc, argv); Settings& settings = Settings::getInstance(); @@ -104,7 +98,6 @@ public: video.reset(); alutExit(); - Sound_Quit(); FE_Quit(); SDL_Quit(); } @@ -119,7 +112,7 @@ public: int run() { - Scalar ticksNow = getTicks(); + Scalar ticksNow = Timer::getTicks(); Scalar nextStep = ticksNow; Scalar nextDraw = ticksNow; @@ -135,13 +128,15 @@ public: running = true; do { - Scalar newTicks = getTicks(); + Scalar newTicks = Timer::getTicks(); deltaTime = newTicks - ticksNow; ticksNow = newTicks; if (deltaTime >= 0.25) deltaTime = 0.25; accumulator += deltaTime; + Timer::fireIfExpired(ticksNow); + while (accumulator >= timestep) { dispatchEvents(); @@ -190,7 +185,8 @@ public: } // be a good citizen and give back what you don't need - sleep(std::min(nextStep, nextDraw), true); + Timer::sleep(std::min(std::min(nextStep, nextDraw), + Timer::getNextFire()), true); } while (running);