X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FEngine.cc;h=50711c744c9758cd1a15e965b6166582a5ec35b9;hp=ccfaf81e6d77b0b0b195f4c279a0d183563ac323;hb=a295f8def17036c8071b56e181364f99a377cae7;hpb=7f3984f3f9524f5b6813e01ceb2fe576dadff94e diff --git a/src/Moof/Engine.cc b/src/Moof/Engine.cc index ccfaf81..50711c7 100644 --- a/src/Moof/Engine.cc +++ b/src/Moof/Engine.cc @@ -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,20 +66,22 @@ 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 { char vdName[128]; SDL_VideoDriverName(vdName, sizeof(vdName)); - logDebug << "initialized SDL; using video driver `" + logInfo << "initialized SDL; using video driver `" << vdName << "'" << std::endl; } 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); @@ -94,7 +95,7 @@ public: else { alcMakeContextCurrent(mAlContext); - logDebug << "opened sound device `" + logInfo << "opened sound device `" << alcGetString(mAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER) << "'" << std::endl; } @@ -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::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; } } @@ -282,9 +283,9 @@ public: { ASSERT(layer && "cannot push null layer"); mStack.push_front(layer); - logDebug << "stack: " << mStack.size() + logInfo << "stack: " << mStack.size() << " [pushed " << layer.get() << "]" << std::endl; - layer->pushed(mInterface); + layer->pushedOntoEngine(); } LayerP pop() @@ -294,9 +295,9 @@ public: LayerP layer = mStack.front(); mStack.pop_front(); - logDebug << "stack: " << mStack.size() + logInfo << "stack: " << mStack.size() << " [popped " << layer.get() << "]" << std::endl; - layer->popped(mInterface); + layer->poppedFromEngine(); if (fixIt) mStackIt = --mStack.begin(); @@ -323,8 +324,8 @@ public: for (it = layers.begin(); it != layers.end(); ++it) { - (*it)->popped(mInterface); - logDebug << "stack: " << mStack.size() + (*it)->poppedFromEngine(); + logInfo << "stack: " << mStack.size() << " [popped " << (*it).get() << "]" << std::endl; } @@ -341,7 +342,7 @@ public: { mStack.clear(); mStackIt = mStack.begin(); - logDebug("stack: 0 [cleared]"); + logInfo("stack: 0 [cleared]"); } @@ -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: *************************************************/