+ std::list<LayerP> popped;
+
+ std::list<LayerP>::iterator it;
+ for (it = mStack.begin(); it != mStack.end(); ++it)
+ {
+ popped.push_back(*it);
+
+ if (it == mStackIt) fixIt = true;
+
+ if ((*it).get() == layer)
+ {
+ ++it;
+ mStack.erase(mStack.begin(), it);
+
+ for (it = popped.begin(); it != popped.end(); ++it)
+ {
+ (*it)->popped(mInterface);
+ }
+
+ if (fixIt) mStackIt = --mStack.begin();
+
+ return popped.back();
+ }
+ }
+
+ return LayerP();
+ }
+
+ void clear()
+ {
+ mStack.clear();
+ mStackIt = mStack.begin();
+ logInfo("clear: %d", mStack.size());
+ }
+
+
+ Engine& mInterface;
+
+ VideoP mVideo;
+
+ std::list<LayerP> mStack;
+ std::list<LayerP>::iterator mStackIt;
+
+ Scalar mTimestep;
+ Scalar mDrawRate;
+
+ long mFps;
+ bool mPrintFps;
+};
+
+
+static Engine* instance = 0;
+
+Engine::Engine(int argc, char* argv[], const std::string& name,
+ const std::string& iconFile, const std::string& configFile) :
+ mImpl(new Engine::Impl(argc, argv, name, iconFile, configFile, *this))