]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Engine.cc
moving from SDL_sound to libvorbisfile
[chaz/yoink] / src / Moof / Engine.cc
index 78233688d60f69dba90c880a0c9e94b9518f0814..80a203e6989b368a86cb12c0790568fef0bc7b6c 100644 (file)
 *******************************************************************************/
 
 #include <cstdlib>                     // exit
-#include <iostream>
 #include <string>
 
 #include <SDL/SDL.h>
 #include "fastevents.h"
-#include <SDL/SDL_sound.h>
 #include <AL/alut.h>
 
 #include "Dispatcher.hh"
 #include "Engine.hh"
+#include "Log.hh"
 #include "Random.hh"
 #include "Settings.hh"
 #include "Timer.hh"
@@ -52,24 +51,26 @@ 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());
-               }
-               if (Sound_Init() != 0)
-               {
-                       //throw Exception(Sound_GetError());
-                       std::cerr << Sound_GetError() << std::endl;
+                       logError("fast events error: %s", FE_GetError());
+                       throw Exception(Exception::SDL_ERROR);
                }
                alutInit(&argc, argv);
 
+               Settings& settings = Settings::getInstance();
+               settings.parseArgs(argc, argv);
                settings.loadFromFile(configFile);
 
                long randomSeed;
@@ -87,7 +88,7 @@ public:
                printFps = false;
                settings.get("video.printfps", printFps);
 
-               video = VideoPtr(new Video(name, iconFile));
+               video = Video::alloc(name, iconFile);
                video->makeActive();
        }
 
@@ -97,7 +98,6 @@ public:
                video.reset();
 
                alutExit();
-               Sound_Quit();
                FE_Quit();
                SDL_Quit();
        }
@@ -167,7 +167,7 @@ public:
 
                                        if (printFps)
                                        {
-                                               std::cout << "FPS: " << fps << std::endl;
+                                               logInfo("framerate: %d fps", fps);
                                        }
                                }
 
@@ -219,9 +219,7 @@ public:
 
        Engine*         interface;
 
-       Settings        settings;
-       Dispatcher      dispatcher;
-       VideoPtr        video;
+       VideoP          video;
 
        bool            running;
        int                     exitCode;
This page took 0.019705 seconds and 4 git commands to generate.