]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Engine.cc
dispatch class not a singleton, engine is static
[chaz/yoink] / src / Moof / Engine.cc
index 56e98b926bf6fed2f6fe7edadfd8c742b4339659..50711c744c9758cd1a15e965b6166582a5ec35b9 100644 (file)
@@ -39,7 +39,6 @@
 
 #include "Engine.hh"
 #include "Event.hh"
-#include "Exception.hh"
 #include "Log.hh"
 #include "Math.hh"
 #include "Settings.hh"
@@ -53,8 +52,8 @@ class Engine::Impl
 {
 public:
 
-       Impl(Engine& engine) :
-               mInterface(engine),
+       Impl() :
+               mError(Error::NONE),
                mTimestep(0.01),
                mPrintFps(false)
        {
@@ -67,7 +66,8 @@ public:
 #endif
                {
                        const char* error = SDL_GetError();
-                       throw Exception(ErrorCode::SDL_INIT, error);
+                       mError.init(Error::SDL_INIT, error);
+                       //throw Exception(Error::SDL_INIT, error);
                }
                else
                {
@@ -80,7 +80,8 @@ public:
                if (FE_Init() != 0)
                {
                        const char* error = FE_GetError();
-                       throw Exception(ErrorCode::FASTEVENTS_INIT, error);
+                       mError.init(Error::FASTEVENTS_INIT, error);
+                       //throw Exception(Error::FASTEVENTS_INIT, error);
                }
 
                mAlDevice = alcOpenDevice(0);
@@ -255,7 +256,7 @@ public:
        {
                for (mStackIt = mStack.begin(); mStackIt != mStack.end(); ++mStackIt)
                {
-                       (*mStackIt)->update(mInterface, t, dt);
+                       (*mStackIt)->update(t, dt);
                }
        }
 
@@ -265,7 +266,7 @@ public:
                std::list<LayerP>::reverse_iterator it;
                for (it = mStack.rbegin(); it != mStack.rend(); ++it)
                {
-                       (*it)->draw(mInterface, alpha);
+                       (*it)->draw(alpha);
                }
        }
 
@@ -273,7 +274,7 @@ public:
        {
                for (mStackIt = mStack.begin(); mStackIt != mStack.end(); ++mStackIt)
                {
-                       if ((*mStackIt)->handleEvent(mInterface, event)) break;
+                       if ((*mStackIt)->handleEvent(event)) break;
                }
        }
 
@@ -284,7 +285,7 @@ public:
                mStack.push_front(layer);
                logInfo << "stack: " << mStack.size()
                                 << " [pushed " << layer.get() << "]" << std::endl;
-               layer->pushed(mInterface);
+               layer->pushedOntoEngine();
        }
 
        LayerP pop()
@@ -296,7 +297,7 @@ public:
                mStack.pop_front();
                logInfo << "stack: " << mStack.size()
                                 << " [popped " << layer.get() << "]" << std::endl;
-               layer->popped(mInterface);
+               layer->poppedFromEngine();
 
                if (fixIt) mStackIt = --mStack.begin();
 
@@ -323,7 +324,7 @@ public:
 
                                for (it = layers.begin(); it != layers.end(); ++it)
                                {
-                                       (*it)->popped(mInterface);
+                                       (*it)->poppedFromEngine();
                                        logInfo << "stack: " << mStack.size()
                                                         << " [popped " << (*it).get() << "]" << std::endl;
                                }
@@ -356,7 +357,8 @@ public:
        }
 
 
-       Engine&                                         mInterface;
+       Error                                           mError;
+
        VideoP                                          mVideo;
        Dispatch                                        mDispatch;
 
@@ -376,12 +378,13 @@ public:
 
 Engine::Engine() :
        // pass through
-       mImpl(new Engine::Impl(*this)) {}
+       mImpl(new Engine::Impl) {}
+
 
-Engine& Engine::getInstance()
+const Error& Engine::getError() const
 {
-       static Engine engine;
-       return engine;
+       // pass through
+       return mImpl->mError;
 }
 
 
@@ -483,6 +486,9 @@ void Engine::dispatch(const std::string& event,
 }
 
 
+Engine engine;
+
+
 } // namespace Mf
 
 /** vim: set ts=4 sw=4 tw=80: *************************************************/
This page took 0.022823 seconds and 4 git commands to generate.