+ std::list<LayerP> layers;
+
+ std::list<LayerP>::iterator it;
+ for (it = mStack.begin(); it != mStack.end(); ++it)
+ {
+ layers.push_back(*it);
+
+ if (it == mStackIt) fixIt = true;
+
+ if ((*it).get() == layer)
+ {
+ ++it;
+ mStack.erase(mStack.begin(), it);
+
+ for (it = layers.begin(); it != layers.end(); ++it)
+ {
+ (*it)->popped(mInterface);
+ logDebug << "stack: " << mStack.size()
+ << " [popped " << (*it).get() << "]" << std::endl;
+ }
+
+ if (fixIt) mStackIt = --mStack.begin();
+
+ return layers.back();
+ }
+ }
+
+ return LayerP();
+ }
+
+ void clear()
+ {
+ mStack.clear();
+ mStackIt = mStack.begin();
+ logDebug("stack: 0 [cleared]");
+ }
+
+
+ void capFps()
+ {
+ if (mMaxFps < mTimestep)
+ {
+ logWarning << "capping maximum fps to timestep ("
+ << mTimestep << ")" << std::endl;
+ mMaxFps = mTimestep;
+ }
+ }
+
+
+ Engine& mInterface;
+ VideoP mVideo;
+ Dispatch mDispatch;
+
+ ALCdevice* mAlDevice;
+ ALCcontext* mAlContext;
+
+ std::list<LayerP> mStack;
+ std::list<LayerP>::iterator mStackIt;
+
+ Scalar mTimestep;
+ Scalar mMaxFps;
+
+ int mFps;
+ bool mPrintFps;