X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FEngine.cc;h=51a3af0f5bfb6d75d71cdaed34cb7bdd9518c3ac;hp=78233688d60f69dba90c880a0c9e94b9518f0814;hb=57b78ebe21b1b48acd337daa5a1cb8c383959cfa;hpb=bfa6212d09d8735d8fd5e2638188e4a99f21ada4 diff --git a/src/Moof/Engine.cc b/src/Moof/Engine.cc index 7823368..51a3af0 100644 --- a/src/Moof/Engine.cc +++ b/src/Moof/Engine.cc @@ -27,7 +27,6 @@ *******************************************************************************/ #include // exit -#include #include #include @@ -37,6 +36,7 @@ #include "Dispatcher.hh" #include "Engine.hh" +#include "Log.hh" #include "Random.hh" #include "Settings.hh" #include "Timer.hh" @@ -52,24 +52,31 @@ public: Impl(int argc, char* argv[], const std::string& configFile, const std::string& name, const std::string& iconFile, Engine* outer) : - interface(outer), - settings(argc, argv) + interface(outer) { +#if defined(_WIN32) || defined (_WIN64) || defined(__WIN32__) + if (SDL_Init(SDL_INIT_EVERYTHING) != 0) +#else if (SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_EVENTTHREAD) != 0) +#endif { - throw Exception(SDL_GetError()); + logError("sdl is complaining: %s", SDL_GetError()); + throw Exception(Exception::SDL_ERROR); } if (FE_Init() != 0) { - throw Exception(FE_GetError()); + logError("fast events error: %s", FE_GetError()); + throw Exception(Exception::SDL_ERROR); } - if (Sound_Init() != 0) + if (Sound_Init() == 0) { - //throw Exception(Sound_GetError()); - std::cerr << Sound_GetError() << std::endl; + logError("sound initialization failed: %s", Sound_GetError()); + throw Exception(Exception::SDL_ERROR); } alutInit(&argc, argv); + Settings& settings = Settings::getInstance(); + settings.parseArgs(argc, argv); settings.loadFromFile(configFile); long randomSeed; @@ -87,7 +94,7 @@ public: printFps = false; settings.get("video.printfps", printFps); - video = VideoPtr(new Video(name, iconFile)); + video = Video::alloc(name, iconFile); video->makeActive(); } @@ -167,7 +174,7 @@ public: if (printFps) { - std::cout << "FPS: " << fps << std::endl; + logInfo("framerate: %d fps", fps); } } @@ -219,9 +226,7 @@ public: Engine* interface; - Settings settings; - Dispatcher dispatcher; - VideoPtr video; + VideoP video; bool running; int exitCode;