Index: /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgreRoot.h
===================================================================
--- /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgreRoot.h	(revision 1591)
+++ /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgreRoot.h	(revision 1591)
@@ -0,0 +1,832 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+#ifndef __ROOT__
+#define __ROOT__
+
+// Precompiler options
+#include "OgrePrerequisites.h"
+
+#include "OgreSingleton.h"
+#include "OgreString.h"
+#include "OgreSceneManagerEnumerator.h"
+#include "OgreResourceGroupManager.h"
+
+#ifdef GAMETOOLS_ILLUMINATION_MODULE
+#include "OgreFrameListener.h"
+#endif
+
+
+#include <exception>
+
+#if OGRE_COMPILER == OGRE_COMPILER_MSVC || OGRE_COMPILER == OGRE_COMPILER_BORL
+#   define SET_TERM_HANDLER { set_terminate( &Ogre::Root::termHandler ); }
+#else
+#   define SET_TERM_HANDLER { std::set_terminate( &Ogre::Root::termHandler ); }
+#endif
+
+namespace Ogre
+{
+#ifdef GAMETOOLS_ILLUMINATION_MODULE
+	struct FrameListenerComparer
+	{
+		bool operator()(const FrameListener* s1, const FrameListener* s2) const
+		{
+			return s1->compare(s2);
+		}
+	};
+#endif
+
+
+    typedef std::vector<RenderSystem*> RenderSystemList;
+	
+    /** The root class of the Ogre system.
+        @remarks
+            The Ogre::Root class represents a starting point for the client
+            application. From here, the application can gain access to the
+            fundamentals of the system, namely the rendering systems
+            available, management of saved configurations, logging, and
+            access to other classes in the system. Acts as a hub from which
+            all other objects may be reached. An instance of Root must be
+            created before any other Ogre operations are called. Once an
+            instance has been created, the same instance is accessible
+            throughout the life of that object by using Root::getSingleton
+            (as a reference) or Root::getSingletonPtr (as a pointer).
+    */
+    class _OgreExport Root : public Singleton<Root>
+    {
+        // To allow update of active renderer if
+        // RenderSystem::initialise is used directly
+        friend class RenderSystem;
+    private:
+        RenderSystemList mRenderers;
+        RenderSystem* mActiveRenderer;
+        String mVersion;
+		String mConfigFileName;
+	    bool mQueuedEnd;
+        // In case multiple render windows are created, only once are the resources loaded.
+        bool mFirstTimePostWindowInit;
+
+        // Singletons
+        LogManager* mLogManager;
+        ControllerManager* mControllerManager;
+        SceneManagerEnumerator* mSceneManagerEnum;
+        SceneManager* mCurrentSceneManager;
+        DynLibManager* mDynLibManager;
+        PlatformManager* mPlatformManager;
+        ArchiveManager* mArchiveManager;
+        MaterialManager* mMaterialManager;
+        MeshManager* mMeshManager;
+        ParticleSystemManager* mParticleManager;
+        SkeletonManager* mSkeletonManager;
+        OverlayElementFactory* mPanelFactory;
+        OverlayElementFactory* mBorderPanelFactory;
+        OverlayElementFactory* mTextAreaFactory;
+        OverlayManager* mOverlayManager;
+        FontManager* mFontManager;
+        ArchiveFactory *mZipArchiveFactory;
+        ArchiveFactory *mFileSystemArchiveFactory;
+		ResourceGroupManager* mResourceGroupManager;
+		ResourceBackgroundQueue* mResourceBackgroundQueue;
+
+        Timer* mTimer;
+        RenderWindow* mAutoWindow;
+        Profiler* mProfiler;
+        HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
+		ExternalTextureSourceManager* mExternalTextureSourceManager;
+        CompositorManager* mCompositorManager;      
+        unsigned long mCurrentFrame;
+		Real mFrameSmoothingTime;
+
+        std::vector<DynLib*> mPluginLibs;
+
+		typedef std::map<String, MovableObjectFactory*> MovableObjectFactoryMap;
+		MovableObjectFactoryMap mMovableObjectFactoryMap;
+		uint32 mNextMovableObjectTypeFlag;
+		// stock movable factories
+		MovableObjectFactory* mEntityFactory;
+		MovableObjectFactory* mLightFactory;
+		MovableObjectFactory* mBillboardSetFactory;
+		MovableObjectFactory* mManualObjectFactory;
+		MovableObjectFactory* mBillboardChainFactory;
+		MovableObjectFactory* mRibbonTrailFactory;
+
+		typedef std::map<String, RenderQueueInvocationSequence*> RenderQueueInvocationSequenceMap;
+		RenderQueueInvocationSequenceMap mRQSequenceMap;
+
+		/// Are we initialised yet?
+		bool mIsInitialised;
+
+        /** Method reads a plugins configuration file and instantiates all
+            plugins.
+            @param
+                pluginsfile The file that contains plugins information.
+                Defaults to "plugins.cfg".
+        */
+        void loadPlugins( const String& pluginsfile = "plugins.cfg" );
+		/** Initialise all loaded plugins - allows plugins to perform actions
+			once the renderer is initialised.
+		*/
+		void initialisePlugins();
+		/** Shuts down all loaded plugins - allows things to be tidied up whilst
+			all plugins are still loaded.
+		*/
+		void shutdownPlugins();
+
+		/** Unloads all loaded plugins.
+        */
+        void unloadPlugins();
+
+        // Internal method for one-time tasks after first window creation
+        void oneTimePostWindowInit(void);
+#ifdef GAMETOOLS_ILLUMINATION_MODULE	
+		std::set<FrameListener*, FrameListenerComparer> mFrameListeners;
+#else
+        /** Set of registered frame listeners */
+        std::set<FrameListener*> mFrameListeners;
+#endif
+
+        /** Set of frame listeners marked for removal*/
+        std::set<FrameListener*> mRemovedFrameListeners;
+
+        /** Indicates the type of event to be considered by calculateEventTime(). */
+        enum FrameEventTimeType {
+            FETT_ANY, FETT_STARTED, FETT_ENDED
+        };
+
+        /// Contains the times of recently fired events
+        std::deque<unsigned long> mEventTimes[3];
+
+        /** Internal method for calculating the average time between recently fired events.
+        @param now The current time in ms.
+        @param type The type of event to be considered.
+        */
+        Real calculateEventTime(unsigned long now, FrameEventTimeType type);
+    public:
+
+        static void termHandler();
+
+        /** Constructor
+            @param
+                pluginFileName The file that contains plugins information.
+                Defaults to "plugins.cfg".
+		*/
+        Root(const String& pluginFileName = "plugins.cfg", const String& configFileName = "ogre.cfg", const String& logFileName = "Ogre.log");
+        ~Root();
+
+        /** Saves the details of the current configuration
+            @remarks
+                Stores details of the current configuration so it may be
+                restored later on.
+        */
+        void saveConfig(void);
+
+        /** Checks for saved video/sound/etc settings
+            @remarks
+                This method checks to see if there is a valid saved configuration
+                from a previous run. If there is, the state of the system will
+                be restored to that configuration.
+
+            @returns
+                If a valid configuration was found, <b>true</b> is returned.
+            @par
+                If there is no saved configuration, or if the system failed
+                with the last config settings, <b>false</b> is returned.
+        */
+        bool restoreConfig(void);
+
+        /** Displays a dialog asking the user to choose system settings.
+            @remarks
+                This method displays the default dialog allowing the user to
+                choose the renderering system, video mode etc. If there is are
+                any settings saved already, they will be restored automatically
+                before displaying the dialogue. When the user accepts a group of
+                settings, this will automatically call Root::setRenderSystem,
+                RenderSystem::setConfigOption and Root::saveConfig with the
+                user's choices. This is the easiest way to get the system
+                configured.
+            @returns
+                If the user clicked 'Ok', <b>true</b> is returned.
+            @par
+                If they clicked 'Cancel' (in which case the app should
+                strongly consider terminating), <b>false</b> is returned.
+         */
+        bool showConfigDialog(void);
+
+        /** Adds a new rendering subsystem to the list of available renderers.
+            @remarks
+                Intended for use by advanced users and plugin writers only!
+                Calling this method with a pointer to a valid RenderSystem
+                (sublcass) adds a rendering API implementation to the list of
+                available ones. Typical examples would be an OpenGL
+                implementation and a Direct3D implementation.
+            @note
+                <br>This should usually be called from the dllStartPlugin()
+                function of an extension plug-in.
+        */
+        void addRenderSystem(RenderSystem* newRend);
+
+        /** Retrieve a list of the available render systems.
+            @remarks
+                Retrieves a pointer to the list of available renderers as a
+                list of RenderSystem subclasses. Can be used to build a
+                custom settings dialog.
+        */
+        RenderSystemList* getAvailableRenderers(void);
+
+        /** Retrieve a pointer to the render system by the given name
+            @param
+                name Name of the render system intend to retrieve.
+            @returns
+                A pointer to the render system, <b>NULL</b> if no found.
+        */
+        RenderSystem* getRenderSystemByName(const String& name);
+
+        /** Sets the rendering subsystem to be used.
+            @remarks
+                This method indicates to OGRE which rendering system is to be
+                used (e.g. Direct3D, OpenGL etc). This is called
+                automatically by the default config dialog, and when settings
+                are restored from a previous configuraion. If used manually
+                it could be used to set the renderer from a custom settings
+                dialog. Once this has been done, the renderer can be
+                initialised using Root::initialise.
+            @par
+                This method is also called by render systems if they are
+                initialised directly.
+            @param
+                system Pointer to the render system to use.
+            @see
+                RenderSystem
+        */
+        void setRenderSystem(RenderSystem* system);
+
+        /** Retrieve a pointer to the currently selected render system.
+        */
+        RenderSystem* getRenderSystem(void);
+
+        /** Initialises the renderer.
+            @remarks
+                This method can only be called after a renderer has been
+                selected with Root::setRenderSystem, and it will initialise
+                the selected rendering system ready for use.
+            @param
+                autoCreateWindow If true, a rendering window will
+                automatically be created (saving a call to
+                RenderSystem::createRenderWindow). The window will be
+                created based on the options currently set on the render
+                system.
+            @returns
+                A pointer to the automatically created window, if
+                requested, otherwise <b>NULL</b>.
+        */
+	    RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
+
+		/** Returns whether the system is initialised or not. */
+		bool isInitialised(void) const { return mIsInitialised; }
+
+		/** Register a new SceneManagerFactory, a factory object for creating instances
+			of specific SceneManagers. 
+		@remarks
+			Plugins should call this to register as new SceneManager providers.
+		*/
+		void addSceneManagerFactory(SceneManagerFactory* fact);
+
+		/** Unregister a SceneManagerFactory.
+		*/
+		void removeSceneManagerFactory(SceneManagerFactory* fact);
+
+		/** Get more information about a given type of SceneManager.
+		@remarks
+			The metadata returned tells you a few things about a given type 
+			of SceneManager, which can be created using a factory that has been
+			registered already. 
+		@param typeName The type name of the SceneManager you want to enquire on.
+			If you don't know the typeName already, you can iterate over the 
+			metadata for all types using getMetaDataIterator.
+		*/
+		const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
+
+		/** Iterate over all types of SceneManager available for construction, 
+			providing some information about each one.
+		*/
+		SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
+
+		/** Create a SceneManager instance of a given type.
+		@remarks
+			You can use this method to create a SceneManager instance of a 
+			given specific type. You may know this type already, or you may
+			have discovered it by looking at the results from getMetaDataIterator.
+		@note
+			This method throws an exception if the named type is not found.
+		@param typeName String identifying a unique SceneManager type
+		@param instanceName Optional name to given the new instance that is
+			created. If you leave this blank, an auto name will be assigned.
+		*/
+		SceneManager* createSceneManager(const String& typeName, 
+			const String& instanceName = StringUtil::BLANK);
+
+		/** Create a SceneManager instance based on scene type support.
+		@remarks
+			Creates an instance of a SceneManager which supports the scene types
+			identified in the parameter. If more than one type of SceneManager 
+			has been registered as handling that combination of scene types, 
+			in instance of the last one registered is returned.
+		@note This method always succeeds, if a specific scene manager is not
+			found, the default implementation is always returned.
+		@param typeMask A mask containing one or more SceneType flags
+		@param instanceName Optional name to given the new instance that is
+			created. If you leave this blank, an auto name will be assigned.
+		*/
+		SceneManager* createSceneManager(SceneTypeMask typeMask, 
+			const String& instanceName = StringUtil::BLANK);
+
+		/** Destroy an instance of a SceneManager. */
+		void destroySceneManager(SceneManager* sm);
+
+		/** Get an existing SceneManager instance that has already been created,
+			identified by the instance name.
+		@param instanceName The name of the instance to retrieve.
+		*/
+		SceneManager* getSceneManager(const String& instanceName) const;
+
+		/** Get an iterator over all the existing SceneManager instances. */
+		SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
+
+        /** Retrieves a reference to the current TextureManager.
+            @remarks
+                This performs the same function as
+                TextureManager::getSingleton, but is provided for convenience
+                particularly to scripting engines.
+            @par
+                Note that a TextureManager will NOT be available until the
+                Ogre system has been initialised by selecting a RenderSystem,
+                calling Root::initialise and a window having been created
+                (this may have been done by initialise if required). This is
+                because the exact runtime subclass which will be implementing
+                the calls will differ depending on the rendering engine
+                selected, and these typically require a window upon which to
+                base texture format decisions.
+        */
+        TextureManager* getTextureManager(void);
+
+        /** Retrieves a reference to the current MeshManager.
+            @remarks
+                This performs the same function as MeshManager::getSingleton
+                and is provided for convenience to scripting engines.
+        */
+        MeshManager* getMeshManager(void);
+
+        /** Utility function for getting a better description of an error
+            code.
+        */
+        String getErrorDescription(long errorNumber);
+
+        /** Registers a FrameListener which will be called back every frame.
+            @remarks
+                A FrameListener is a class which implements methods which
+                will be called every frame.
+            @par
+                See the FrameListener class for more details on the specifics
+                It is imperitive that the instance passed to this method is
+                not destroyed before either the rendering loop ends, or the
+                class is removed from the listening list using
+                removeFrameListener.
+            @note
+                <br>This method can only be called after Root::initialise has
+                been called.
+            @see
+                FrameListener, Root::removeFrameListener
+        */
+        void addFrameListener(FrameListener* newListener);
+
+        /** Removes a FrameListener from the list of listening classes.
+            @see
+                FrameListener, Root::addFrameListener
+        */
+        void removeFrameListener(FrameListener* oldListener);
+
+        /** Queues the end of rendering.
+            @remarks
+                This method will do nothing unless startRendering() has
+                been called, in which case before the next frame is rendered
+                the rendering loop will bail out.
+            @see
+                Root, Root::startRendering
+        */
+        void queueEndRendering(void);
+
+        /** Starts / restarts the automatic rendering cycle.
+            @remarks
+                This method begins the automatic rendering of the scene. It
+                will <b>NOT</b> return until the rendering cycle is halted.
+            @par
+                During rendering, any FrameListener classes registered using
+                addFrameListener will be called back for each frame that is
+                to be rendered, These classes can tell OGRE to halt the
+                rendering if required, which will cause this method to
+                return.
+            @note
+                <br>Users of the OGRE library do not have to use this
+                automatic rendering loop. It is there as a convenience and is
+                most useful for high frame rate applications e.g. games. For
+                applications that don't need to constantly refresh the
+                rendering targets (e.g. an editor utility), it is better to
+                manually refresh each render target only when required by
+                calling RenderTarget::update.
+            @note
+                This frees up the CPU to do other things in between
+                refreshes, since in this case frame rate is less important.
+            @note
+                This method can only be called after Root::initialise has
+                been called.
+        */
+        void startRendering(void);
+
+        /** Render one frame. 
+        @remarks
+            Updates all the render targets automatically and then returns,
+            raising frame events before and after.
+        */
+        bool renderOneFrame(void);
+        /** Shuts down the system manually.
+            @remarks
+                This is normally done by Ogre automatically so don't think
+                you have to call this yourself. However this is here for
+                convenience, especially for dealing with unexpected errors or
+                for systems which need to shut down Ogre on demand.
+        */
+        void shutdown(void);
+
+        /** Adds a location to the list of searchable locations for a
+            Resource type.
+            @remarks
+                Resource files (textures, models etc) need to be loaded from
+                specific locations. By calling this method, you add another 
+				search location to the list. Locations added first are preferred
+				over locations added later.
+            @par
+                Locations can be folders, compressed archives, even perhaps
+                remote locations. Facilities for loading from different
+                locations are provided by plugins which provide
+                implementations of the Archive class.
+                All the application user has to do is specify a 'loctype'
+                string in order to indicate the type of location, which
+                should map onto one of the provided plugins. Ogre comes
+                configured with the 'FileSystem' (folders) and 'Zip' (archive
+                compressed with the pkzip / WinZip etc utilities) types.
+            @par
+				You can also supply the name of a resource group which should
+				have this location applied to it. The 
+				ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME group is the
+				default, and one resource group which will always exist. You
+				should consider defining resource groups for your more specific
+				resources (e.g. per level) so that you can control loading /
+				unloading better.
+            @param
+                name The name of the location, e.g. './data' or
+                '/compressed/gamedata.zip'
+            @param
+                locType A string identifying the location type, e.g.
+                'FileSystem' (for folders), 'Zip' etc. Must map to a
+                registered plugin which deals with this type (FileSystem and
+                Zip should always be available)
+            @param
+                groupName Type of name of the resource group which this location
+				should apply to; defaults to the General group which applies to
+				all non-specific resources.
+			@param
+				recursive If the resource location has a concept of recursive
+				directory traversal, enabling this option will mean you can load
+				resources in subdirectories using only their unqualified name.
+				The default is to disable this so that resources in subdirectories
+				with the same name are still unique.
+            @see
+                Archive
+        */
+        void addResourceLocation(const String& name, const String& locType, 
+			const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 
+			bool recursive = false);
+
+		/** Removes a resource location from the list.
+		@see addResourceLocation
+		@param name The name of the resource location as specified in addResourceLocation
+		@param groupName The name of the resource group to which this location 
+			was assigned.
+		*/
+		void removeResourceLocation(const String& name, 
+			const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+
+        /** Generates a packed data version of the passed in ColourValue suitable for
+            use with the current RenderSystem.
+        @remarks
+            Since different render systems have different colour data formats (eg
+            RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all.
+        @param colour The colour to convert
+        @param pDest Pointer to location to put the result.
+        */
+        void convertColourValue(const ColourValue& colour, uint32* pDest);
+
+        /** Retrieves a pointer to the window that was created automatically
+            @remarks
+                When Root is initialised an optional window is created. This
+                method retreives a pointer to that window.
+            @note
+                returns a null pointer when Root has not been initialised with
+                the option of creating a window.
+        */
+        RenderWindow* getAutoCreatedWindow(void);
+
+        /** @copydoc RenderSystem::createRenderWindow
+        */
+		RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 
+			bool fullScreen, const NameValuePairList *miscParams = 0) ;
+
+        /** Destroys a rendering window.
+        */
+        void detachRenderTarget( RenderTarget* pWin );
+
+        /** Destroys a named rendering window.
+        */
+        void detachRenderTarget( const String & name );
+
+        /** Retrieves a pointer to the a named render window.
+        */
+        RenderTarget * getRenderTarget(const String &name);
+
+        /** Sets whether or not the debug overlay is shown.
+        @remarks
+            The debug overlay displays frame rate stats and various other debug
+            information. You can enable it or disable it using this method.
+            Alternatively you could access the overlay directly using mSceneManager::getOverlay
+            but this is simpler.
+        void showDebugOverlay(bool show);
+        */
+
+		/** Manually load a plugin.
+		 @remarks
+		 	Plugins are loaded at startup using the plugin configuration
+			file specified when you create Root (default: plugins.cfg).
+			This method allows you to load plugins in code.
+		@param pluginName Name of the plugin library to load
+		*/
+		void loadPlugin(const String& pluginName);
+
+		/** Manually unloads a plugin.
+		 @remarks
+		 	Plugins are unloaded at shutdown automatically.
+			This method allows you to unload plugins in code, but
+			make sure their dependencies are decoupled frist.
+		@param pluginName Name of the plugin library to unload
+		*/
+		void unloadPlugin(const String& pluginName);
+
+        /** Gets a pointer to the central timer used for all OGRE timings */
+        Timer* getTimer(void);
+
+        /** Method for raising frame started events. 
+        @remarks
+            This method is only for internal use when you use OGRE's inbuilt rendering
+            loop (Root::startRendering). However, if you run your own rendering loop then
+            you should call this method to ensure that FrameListener objects are notified
+            of frame events; processes like texture animation and particle systems rely on 
+            this.
+        @par
+            Calling this method also increments the frame number, which is
+            important for keeping some elements of the engine up to date.
+        @note
+            This method takes an event object as a parameter, so you can specify the times
+            yourself. If you are happy for OGRE to automatically calculate the frame time
+            for you, then call the other version of this method with no parameters.
+        @param evt Event object which includes all the timing information which you have 
+            calculated for yourself
+        @returns False if one or more frame listeners elected that the rendering loop should
+            be terminated, true otherwise.
+        */
+        bool _fireFrameStarted(FrameEvent& evt);
+        /** Method for raising frame ended events. 
+        @remarks
+            This method is only for internal use when you use OGRE's inbuilt rendering
+            loop (Root::startRendering). However, if you run your own rendering loop then
+            you should call this method to ensure that FrameListener objects are notified
+            of frame events; processes like texture animation and particle systems rely on 
+            this.
+        @note
+            This method takes an event object as a parameter, so you can specify the times
+            yourself. If you are happy for OGRE to automatically calculate the frame time
+            for you, then call the other version of this method with no parameters.
+        @param evt Event object which includes all the timing information which you have 
+            calculated for yourself
+        @returns False if one or more frame listeners elected that the rendering loop should
+            be terminated, true otherwise.
+        */
+        bool _fireFrameEnded(FrameEvent& evt);
+        /** Method for raising frame started events. 
+        @remarks
+            This method is only for internal use when you use OGRE's inbuilt rendering
+            loop (Root::startRendering). However, if you run your own rendering loop then
+            you should call this method to ensure that FrameListener objects are notified
+            of frame events; processes like texture animation and particle systems rely on 
+            this.
+        @par
+            Calling this method also increments the frame number, which is
+            important for keeping some elements of the engine up to date.
+        @note
+            This method calculates the frame timing information for you based on the elapsed
+            time. If you want to specify elapsed times yourself you should call the other 
+            version of this method which takes event details as a parameter.
+        @returns False if one or more frame listeners elected that the rendering loop should
+            be terminated, true otherwise.
+        */
+        bool _fireFrameStarted();
+        /** Method for raising frame ended events. 
+        @remarks
+            This method is only for internal use when you use OGRE's inbuilt rendering
+            loop (Root::startRendering). However, if you run your own rendering loop then
+            you should call this method to ensure that FrameListener objects are notified
+            of frame events; processes like texture animation and particle systems rely on 
+            this.
+        @note
+            This method calculates the frame timing information for you based on the elapsed
+            time. If you want to specify elapsed times yourself you should call the other 
+            version of this method which takes event details as a parameter.
+        @returns False if one or more frame listeners elected that the rendering loop should
+            be terminated, true otherwise.
+        */
+        bool _fireFrameEnded();
+
+        /** Gets the number of the current frame. */
+        unsigned long getCurrentFrameNumber(void) const { return mCurrentFrame; }
+
+        /** Returns the scene manager currently being used to render a frame.
+        @remarks
+            This is only intended for internal use; it is only valid during the
+            rendering of a frame.
+        */
+        SceneManager* _getCurrentSceneManager(void) const { return mCurrentSceneManager; }
+        /** Sets the scene manager currently being used to render a frame.
+        @remarks
+            This is only intended for internal use.
+        */
+        void _setCurrentSceneManager(SceneManager* sm);
+
+        /** Internal method used for updating all RenderTarget objects (windows, 
+            renderable textures etc) which are set to auto-update.
+        @remarks
+            You don't need to use this method if you're using Ogre's own internal
+            rendering loop (Root::startRendering). If you're running your own loop
+            you may wish to call it to update all the render targets which are
+            set to auto update (RenderTarget::setAutoUpdated). You can also update
+            individual RenderTarget instances using their own update() method.
+        */
+        void _updateAllRenderTargets(void);
+
+		/** Create a new RenderQueueInvocationSequence, useful for linking to
+			Viewport instances to perform custom rendering.
+		@param name The name to give the new sequence
+		*/
+		RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
+			const String& name);
+
+		/** Get a RenderQueueInvocationSequence. 
+		@param name The name to identify the sequence
+		*/
+		RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
+			const String& name);
+
+		/** Destroy a RenderQueueInvocationSequence. 
+		@remarks
+			You must ensure that no Viewports are using this sequence.
+		@param name The name to identify the sequence
+		*/
+		void destroyRenderQueueInvocationSequence(
+			const String& name);
+
+		/** Destroy all RenderQueueInvocationSequences. 
+		@remarks
+			You must ensure that no Viewports are using custom sequences.
+		@param name The name to identify the sequence
+		*/
+		void destroyAllRenderQueueInvocationSequences(void);
+
+        /** Override standard Singleton retrieval.
+            @remarks
+                Why do we do this? Well, it's because the Singleton
+                implementation is in a .h file, which means it gets compiled
+                into anybody who includes it. This is needed for the
+                Singleton template to work, but we actually only want it
+                compiled into the implementation of the class based on the
+                Singleton, not all of them. If we don't change this, we get
+                link errors when trying to use the Singleton-based class from
+                an outside dll.
+            @par
+                This method just delegates to the template version anyway,
+                but the implementation stays in this single compilation unit,
+                preventing link errors.
+        */
+        static Root& getSingleton(void);
+        /** Override standard Singleton retrieval.
+            @remarks
+                Why do we do this? Well, it's because the Singleton
+                implementation is in a .h file, which means it gets compiled
+                into anybody who includes it. This is needed for the
+                Singleton template to work, but we actually only want it
+                compiled into the implementation of the class based on the
+                Singleton, not all of them. If we don't change this, we get
+                link errors when trying to use the Singleton-based class from
+                an outside dll.
+            @par
+                This method just delegates to the template version anyway,
+                but the implementation stays in this single compilation unit,
+                preventing link errors.
+        */
+        static Root* getSingletonPtr(void);
+
+		/** Clears the history of all event times. 
+		@remarks
+			OGRE stores a history of the last few event times in order to smooth
+			out any inaccuracies and temporary fluctuations. However, if you 
+			pause or don't render for a little while this can cause a lurch, so
+			if you're resuming rendering after a break, call this method to reset
+			the stored times
+		*/
+		void clearEventTimes(void);
+
+		/** Sets the period over which OGRE smooths out fluctuations in frame times.
+		@remarks
+			OGRE by default gives you the raw frame time, but can optionally
+			smooths it out over several frames, in order to reduce the 
+			noticeable effect of occasional hiccups in framerate.
+			These smoothed values are passed back as parameters to FrameListener
+			calls.
+		@par
+			This method allow you to tweak the smoothing period, and is expressed
+			in seconds. Setting it to 0 will result in completely unsmoothed
+			frame times (the default).
+		*/
+		void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
+		/** Gets the period over which OGRE smooths out fluctuations in frame times. */
+		Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
+
+		/** Register a new MovableObjectFactory which will create new MovableObject
+			instances of a particular type, as identified by the getType() method.
+		@remarks
+			Plugin creators can create subclasses of MovableObjectFactory which 
+			construct custom subclasses of MovableObject for insertion in the 
+			scene. This is the primary way that plugins can make custom objects
+			available.
+		@param fact Pointer to the factory instance
+		@param overrideExisting Set this to true to override any existing 
+			factories which are registered for the same type. You should only
+			change this if you are very sure you know what you're doing. 
+		*/
+		void addMovableObjectFactory(MovableObjectFactory* fact, 
+			bool overrideExisting = false);
+		/** Removes a previously registered MovableObjectFactory.
+		@remarks
+			All instances of objects created by this factory will be destroyed
+			before removing the factory (by calling back the factories 
+			'destroyInstance' method). The plugin writer is responsible for actually
+			destroying the factory.
+		*/
+		void removeMovableObjectFactory(MovableObjectFactory* fact);
+		/// Checks whether a factory is registered for a given MovableObject type
+		bool hasMovableObjectFactory(const String& typeName) const;
+		/// Get a MovableObjectFactory for the given type
+		MovableObjectFactory* getMovableObjectFactory(const String& typeName);
+		/** Allocate the next MovableObject type flag.
+		@remarks
+			This is done automatically if MovableObjectFactory::requestTypeFlags
+			returns true; don't call this manually unless you're sure you need to.
+		*/
+		uint32 _allocateNextMovableObjectTypeFlag(void);
+
+		typedef ConstMapIterator<MovableObjectFactoryMap> MovableObjectFactoryIterator;
+		/** Return an iterator over all the MovableObjectFactory instances currently
+			registered.
+		*/
+		MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
+    };
+} // Namespace Ogre
+#endif
Index: /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgreFrameListener.h
===================================================================
--- /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgreFrameListener.h	(revision 1591)
+++ /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgreFrameListener.h	(revision 1591)
@@ -0,0 +1,117 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+#ifndef __FrameListener_H__
+#define __FrameListener_H__
+
+
+#include "OgrePrerequisites.h"
+
+namespace Ogre {
+
+    /** Struct containing information about a frame event.
+    */
+    struct FrameEvent
+    {
+        /** Elapsed time in seconds since the last event.
+            This gives you time between frame start & frame end,
+            and between frame end and next frame start.
+            @remarks
+                This may not be the elapsed time but the average
+                elapsed time between recently fired events.
+        */
+        Real timeSinceLastEvent;
+        /** Elapsed time in seconds since the last event of the same type,
+            i.e. time for a complete frame.
+            @remarks
+                This may not be the elapsed time but the average
+                elapsed time between recently fired events of the same type.
+        */
+        Real timeSinceLastFrame;
+    };
+
+
+    /** A interface class defining a listener which can be used to receive
+        notifications of frame events.
+        @remarks
+            A 'listener' is an interface designed to be called back when
+            particular events are called. This class defines the
+            interface relating to frame events. In order to receive
+            notifications of frame events, you should create a subclass of
+            FrameListener and override the methods for which you would like
+            to customise the resulting processing. You should then call
+            Root::addFrameListener passing an instance of this class.
+            There is no limit to the number of frame listeners you can register,
+            allowing you to register multiple listeners for different purposes.
+            Frame events only occur when Ogre is in continuous rendering mode,
+            ie. after Root::startRendering is called. If the application is
+            doing ad-hoc rendering without entering a rendering loop, frame
+            events are not generated. Note that a frame event occurs once for
+            all rendering targets, not once per target.
+    */
+    class _OgreExport FrameListener
+    {
+        /*
+        Note that this could have been an abstract class, but I made
+        the explicit choice not to do this, because I wanted to give
+        people the option of only implementing the methods they wanted,
+        rather than having to create 'do nothing' implementations for
+        those they weren't interested in. As such this class follows
+        the 'Adapter' classes in Java rather than pure interfaces.
+        */
+	    
+#ifdef GAMETOOLS_ILLUMINATION_MODULE
+	protected:
+		int priority;
+
+	public:
+		bool compare(const FrameListener* l)const
+		{
+			return priority < l->priority;
+		}
+		int getPriority(){return priority;}
+		void setPriority(int p){priority = p;}
+		FrameListener(){priority = 0;}
+#endif
+		public:
+
+        /** Called when a frame is about to begin rendering.
+            @return
+                True to go ahead, false to abort rendering and drop
+                out of the rendering loop.
+        */
+        virtual bool frameStarted(const FrameEvent& evt) { return true; }
+        /** Called just after a frame has been rendered.
+            @return
+                True to continue with the next frame, false to drop
+                out of the rendering loop.
+        */
+        virtual bool frameEnded(const FrameEvent& evt) { return true; }
+
+		virtual ~FrameListener() {}
+		
+    };
+}
+
+#endif
Index: /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/src/OgreRoot.cpp
===================================================================
--- /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/src/OgreRoot.cpp	(revision 1591)
+++ /OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/src/OgreRoot.cpp	(revision 1591)
@@ -0,0 +1,1175 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+(Object-oriented Graphics Rendering Engine)
+For the latest info, see http://ogre.sourceforge.net/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+// Ogre includes
+#include "OgreStableHeaders.h"
+
+#include "OgreRoot.h"
+
+#include "OgreRenderSystem.h"
+#include "OgreRenderWindow.h"
+#include "OgreException.h"
+#include "OgreControllerManager.h"
+#include "OgreLogManager.h"
+#include "OgreMath.h"
+#include "OgreDynLibManager.h"
+#include "OgreDynLib.h"
+#include "OgreConfigFile.h"
+#include "OgreMaterialManager.h"
+#include "OgreMeshManager.h"
+#include "OgreTextureManager.h"
+#include "OgreParticleSystemManager.h"
+#include "OgreSkeletonManager.h"
+#include "OgreOverlayElementFactory.h"
+#include "OgreOverlayManager.h"
+#include "OgreProfiler.h"
+#include "OgreErrorDialog.h"
+#include "OgreConfigDialog.h"
+#include "OgreStringConverter.h"
+#include "OgrePlatformManager.h"
+#include "OgreArchiveManager.h"
+#include "OgreZip.h"
+#include "OgreFileSystem.h"
+#include "OgreShadowVolumeExtrudeProgram.h"
+#include "OgreResourceBackgroundQueue.h"
+#include "OgreEntity.h"
+#include "OgreBillboardSet.h"
+#include "OgreBillboardChain.h"
+#include "OgreRibbonTrail.h"
+#include "OgreLight.h"
+#include "OgreManualObject.h"
+#include "OgreRenderQueueInvocation.h"
+
+#if OGRE_NO_DEVIL == 0
+#include "OgreILCodecs.h"
+#endif
+
+#include "OgreFontManager.h"
+#include "OgreHardwareBufferManager.h"
+
+#include "OgreOverlay.h"
+#include "OgreHighLevelGpuProgramManager.h"
+
+#include "OgreExternalTextureSourceManager.h"
+#include "OgreCompositorManager.h"
+
+namespace Ogre {
+    //-----------------------------------------------------------------------
+    template<> Root* Singleton<Root>::ms_Singleton = 0;
+    Root* Root::getSingletonPtr(void)
+    {
+        return ms_Singleton;
+    }
+    Root& Root::getSingleton(void)
+    {
+        assert( ms_Singleton );  return ( *ms_Singleton );
+    }
+
+    typedef void (*DLL_START_PLUGIN)(void);
+	typedef void (*DLL_INIT_PLUGIN)(void);
+    typedef void (*DLL_STOP_PLUGIN)(void);
+
+
+    //-----------------------------------------------------------------------
+    // Termination handler
+    extern "C" _OgreExport void handleTerminate(void)
+    {
+        LogManager::getSingleton().logMessage("Termination handler: uncaught exception!", LML_CRITICAL);
+
+        Root::getSingleton().shutdown();
+
+        ErrorDialog* dlg = PlatformManager::getSingleton().createErrorDialog();
+
+        Exception* e = Exception::getLastException();
+
+        if (e)
+            dlg->display(e->getFullDescription());
+        else
+            dlg->display("Unknown");
+
+        // Abort
+        exit(-1);
+
+    }
+
+    void Root::termHandler()
+    {
+        handleTerminate();
+    }
+
+
+    //-----------------------------------------------------------------------
+    Root::Root(const String& pluginFileName, const String& configFileName, const String& logFileName)
+      : mLogManager(0), mCurrentFrame(0), mFrameSmoothingTime(0.0f),
+	  mNextMovableObjectTypeFlag(1), mIsInitialised(false)
+    {
+        // First create new exception handler
+        SET_TERM_HANDLER;
+
+        // superclass will do singleton checking
+        String msg;
+
+        // Init
+        mActiveRenderer = 0;
+        mVersion = StringConverter::toString(OGRE_VERSION_MAJOR) + "." +
+            StringConverter::toString(OGRE_VERSION_MINOR) + "." +
+            StringConverter::toString(OGRE_VERSION_PATCH) + " " +
+            "(" + OGRE_VERSION_NAME + ")";
+		mConfigFileName = configFileName;
+
+		// Create log manager and default log file if there is no log manager yet
+		if(LogManager::getSingletonPtr() == 0)
+		{
+			mLogManager = new LogManager();
+			mLogManager->createLog(logFileName, true, true);
+		}
+
+        // Dynamic library manager
+        mDynLibManager = new DynLibManager();
+
+        mArchiveManager = new ArchiveManager();
+
+		// ResourceGroupManager
+		mResourceGroupManager = new ResourceGroupManager();
+
+		// ResourceBackgroundQueue
+		mResourceBackgroundQueue = new ResourceBackgroundQueue();
+
+		// Create SceneManager enumerator (note - will be managed by singleton)
+        mSceneManagerEnum = new SceneManagerEnumerator();
+        mCurrentSceneManager = NULL;
+
+        // ..material manager
+        mMaterialManager = new MaterialManager();
+
+        // Mesh manager
+        mMeshManager = new MeshManager();
+
+        // Skeleton manager
+        mSkeletonManager = new SkeletonManager();
+
+        // ..particle system manager
+        mParticleManager = new ParticleSystemManager();
+
+        // Platform manager
+        mPlatformManager = new PlatformManager();
+
+        // Timer
+        mTimer = mPlatformManager->createTimer();
+
+        // Overlay manager
+        mOverlayManager = new OverlayManager();
+
+        mPanelFactory = new PanelOverlayElementFactory();
+        mOverlayManager->addOverlayElementFactory(mPanelFactory);
+
+        mBorderPanelFactory = new BorderPanelOverlayElementFactory();
+        mOverlayManager->addOverlayElementFactory(mBorderPanelFactory);
+
+        mTextAreaFactory = new TextAreaOverlayElementFactory();
+        mOverlayManager->addOverlayElementFactory(mTextAreaFactory);
+        // Font manager
+        mFontManager = new FontManager();
+
+#if OGRE_PROFILING
+        // Profiler
+        mProfiler = new Profiler();
+		Profiler::getSingleton().setTimer(mTimer);
+#endif
+        mFileSystemArchiveFactory = new FileSystemArchiveFactory();
+        ArchiveManager::getSingleton().addArchiveFactory( mFileSystemArchiveFactory );
+        mZipArchiveFactory = new ZipArchiveFactory();
+        ArchiveManager::getSingleton().addArchiveFactory( mZipArchiveFactory );
+#if OGRE_NO_DEVIL == 0
+	    // Register image codecs
+	    ILCodecs::registerCodecs();
+#endif
+
+        mHighLevelGpuProgramManager = new HighLevelGpuProgramManager();
+
+		mExternalTextureSourceManager = new ExternalTextureSourceManager();
+        mCompositorManager = new CompositorManager();
+
+        // Auto window
+        mAutoWindow = 0;
+
+		// instantiate and register base movable factories
+		mEntityFactory = new EntityFactory();
+		addMovableObjectFactory(mEntityFactory);
+		mLightFactory = new LightFactory();
+		addMovableObjectFactory(mLightFactory);
+		mBillboardSetFactory = new BillboardSetFactory();
+		addMovableObjectFactory(mBillboardSetFactory);
+		mManualObjectFactory = new ManualObjectFactory();
+		addMovableObjectFactory(mManualObjectFactory);
+		mBillboardChainFactory = new BillboardChainFactory();
+		addMovableObjectFactory(mBillboardChainFactory);
+		mRibbonTrailFactory = new RibbonTrailFactory();
+		addMovableObjectFactory(mRibbonTrailFactory);
+
+		// Load plugins
+        if (!pluginFileName.empty())
+            loadPlugins(pluginFileName);
+
+		LogManager::getSingleton().logMessage("*-*-* OGRE Initialising");
+        msg = "*-*-* Version " + mVersion;
+        LogManager::getSingleton().logMessage(msg);
+
+        // Can't create managers until initialised
+        mControllerManager = 0;
+
+        mFirstTimePostWindowInit = false;
+
+    }
+
+    //-----------------------------------------------------------------------
+    Root::~Root()
+    {
+        shutdown();
+        delete mSceneManagerEnum;
+
+		destroyAllRenderQueueInvocationSequences();
+        delete mCompositorManager;
+		delete mExternalTextureSourceManager;
+#if OGRE_NO_DEVIL == 0
+        ILCodecs::deleteCodecs();
+#endif
+#if OGRE_PROFILING
+        delete mProfiler;
+#endif
+        delete mOverlayManager;
+        delete mFontManager;
+        delete mArchiveManager;
+        delete mZipArchiveFactory;
+        delete mFileSystemArchiveFactory;
+        delete mSkeletonManager;
+        delete mMeshManager;
+        delete mParticleManager;
+
+        if( mControllerManager )
+            delete mControllerManager;
+        if (mHighLevelGpuProgramManager)
+            delete mHighLevelGpuProgramManager;
+
+        delete mTextAreaFactory;
+        delete mBorderPanelFactory;
+        delete mPanelFactory;
+
+        unloadPlugins();
+        delete mMaterialManager;
+        Pass::processPendingPassUpdates(); // make sure passes are cleaned
+		delete mResourceBackgroundQueue;
+        delete mResourceGroupManager;
+
+		delete mEntityFactory;
+		delete mLightFactory;
+		delete mBillboardSetFactory;
+		delete mManualObjectFactory;
+		delete mBillboardChainFactory;
+		delete mRibbonTrailFactory;
+
+
+        mPlatformManager->destroyTimer(mTimer);
+        delete mPlatformManager;
+        delete mDynLibManager;
+        delete mLogManager;
+
+
+        StringInterface::cleanupDictionary ();
+    }
+
+    //-----------------------------------------------------------------------
+    void Root::saveConfig(void)
+    {
+		std::ofstream of(mConfigFileName.c_str());
+
+        if (!of)
+            OGRE_EXCEPT(Exception::ERR_CANNOT_WRITE_TO_FILE, "Cannot create settings file.",
+            "Root::saveConfig");
+
+        if (mActiveRenderer)
+        {
+            of << "Render System=" << mActiveRenderer->getName() << std::endl;
+        }
+        else
+        {
+            of << "Render System=" << std::endl;
+        }
+
+        for (RenderSystemList::const_iterator pRend = getAvailableRenderers()->begin(); pRend != getAvailableRenderers()->end(); ++pRend)
+        {
+            RenderSystem* rs = *pRend;
+            of << std::endl;
+            of << "[" << rs->getName() << "]" << std::endl;
+            const ConfigOptionMap& opts = rs->getConfigOptions();
+            for (ConfigOptionMap::const_iterator pOpt = opts.begin(); pOpt != opts.end(); ++pOpt)
+            {
+				of << pOpt->first << "=" << pOpt->second.currentValue << std::endl;
+            }
+        }
+
+        of.close();
+
+    }
+    //-----------------------------------------------------------------------
+    bool Root::restoreConfig(void)
+    {
+        // Restores configuration from saved state
+        // Returns true if a valid saved configuration is
+        //   available, and false if no saved config is
+        //   stored, or if there has been a problem
+        ConfigFile cfg;
+        //RenderSystemList::iterator pRend;
+
+        try {
+            // Don't trim whitespace
+            cfg.load(mConfigFileName, "\t:=", false);
+        }
+        catch (Exception& e)
+        {
+            if (e.getNumber() == Exception::ERR_FILE_NOT_FOUND)
+            {
+                return false;
+            }
+            else
+            {
+                throw;
+            }
+        }
+
+        ConfigFile::SectionIterator iSection = cfg.getSectionIterator();
+        while (iSection.hasMoreElements())
+        {
+            const String& renderSystem = iSection.peekNextKey();
+            const ConfigFile::SettingsMultiMap& settings = *iSection.getNext();
+
+            RenderSystem* rs = getRenderSystemByName(renderSystem);
+            if (!rs)
+            {
+                // Unrecognised render system
+                continue;
+            }
+
+            ConfigFile::SettingsMultiMap::const_iterator i;
+            for (i = settings.begin(); i != settings.end(); ++i)
+            {
+                rs->setConfigOption(i->first, i->second);
+            }
+        }
+
+        RenderSystem* rs = getRenderSystemByName(cfg.getSetting("Render System"));
+        if (!rs)
+        {
+            // Unrecognised render system
+            return false;
+        }
+
+        setRenderSystem(rs);
+
+        // Successful load
+        return true;
+
+    }
+
+    //-----------------------------------------------------------------------
+    bool Root::showConfigDialog(void)
+    {
+        // Displays the standard config dialog
+        // Will use stored defaults if available
+        ConfigDialog* dlg;
+        bool isOk;
+
+        dlg = mPlatformManager->createConfigDialog();
+
+        isOk = dlg->display();
+
+        mPlatformManager->destroyConfigDialog(dlg);
+
+        return isOk;
+
+    }
+
+    //-----------------------------------------------------------------------
+    RenderSystemList* Root::getAvailableRenderers(void)
+    {
+        // Returns a vector of renders
+
+        return &mRenderers;
+
+    }
+
+    //-----------------------------------------------------------------------
+    RenderSystem* Root::getRenderSystemByName(const String& name)
+    {
+        if (name.empty())
+        {
+            // No render system
+            return NULL;
+        }
+
+        RenderSystemList::const_iterator pRend;
+        for (pRend = getAvailableRenderers()->begin(); pRend != getAvailableRenderers()->end(); ++pRend)
+        {
+            RenderSystem* rs = *pRend;
+            if (rs->getName() == name)
+                return rs;
+        }
+
+        // Unrecognised render system
+        return NULL;
+    }
+
+    //-----------------------------------------------------------------------
+    void Root::setRenderSystem(RenderSystem* system)
+    {
+        // Sets the active rendering system
+        // Can be called direct or will be called by
+        //   standard config dialog
+
+        // Is there already an active renderer?
+        // If so, disable it and init the new one
+        if( mActiveRenderer && mActiveRenderer != system )
+        {
+            mActiveRenderer->shutdown();
+        }
+
+        mActiveRenderer = system;
+        // Tell scene managers
+        SceneManagerEnumerator::getSingleton().setRenderSystem(system);
+
+    }
+    //-----------------------------------------------------------------------
+    void Root::addRenderSystem(RenderSystem *newRend)
+    {
+        mRenderers.push_back(newRend);
+    }
+    //-----------------------------------------------------------------------
+	void Root::_setCurrentSceneManager(SceneManager* sm)
+	{
+		mCurrentSceneManager = sm;
+	}
+    //-----------------------------------------------------------------------
+    RenderSystem* Root::getRenderSystem(void)
+    {
+        // Gets the currently active renderer
+        return mActiveRenderer;
+
+    }
+
+    //-----------------------------------------------------------------------
+    RenderWindow* Root::initialise(bool autoCreateWindow, const String& windowTitle)
+    {
+        if (!mActiveRenderer)
+            OGRE_EXCEPT(Exception::ERR_NO_RENDERSYSTEM_SELECTED,
+            "Cannot initialise - no render "
+            "system has been selected.", "Root::initialise");
+
+        if (!mControllerManager)
+			mControllerManager = new ControllerManager();
+
+        mAutoWindow =  mActiveRenderer->initialise(autoCreateWindow, windowTitle);
+
+		mResourceBackgroundQueue->initialise();
+
+        if (autoCreateWindow && !mFirstTimePostWindowInit)
+        {
+            oneTimePostWindowInit();
+            mAutoWindow->_setPrimary();
+        }
+
+        // Initialise timer
+        mTimer->reset();
+
+		// Init plugins
+		initialisePlugins();
+
+		mIsInitialised = true;
+
+        return mAutoWindow;
+
+    }
+    //-----------------------------------------------------------------------
+    String Root::getErrorDescription(long errorNumber)
+    {
+
+        // Pass to render system
+        if (mActiveRenderer)
+            return mActiveRenderer->getErrorDescription(errorNumber);
+        else
+            return "";
+
+    }
+	//-----------------------------------------------------------------------
+	void Root::addSceneManagerFactory(SceneManagerFactory* fact)
+	{
+		mSceneManagerEnum->addFactory(fact);
+	}
+	//-----------------------------------------------------------------------
+	void Root::removeSceneManagerFactory(SceneManagerFactory* fact)
+	{
+		mSceneManagerEnum->removeFactory(fact);
+	}
+	//-----------------------------------------------------------------------
+	const SceneManagerMetaData* Root::getSceneManagerMetaData(const String& typeName) const
+	{
+		return mSceneManagerEnum->getMetaData(typeName);
+	}
+	//-----------------------------------------------------------------------
+	SceneManagerEnumerator::MetaDataIterator 
+	Root::getSceneManagerMetaDataIterator(void) const
+	{
+		return mSceneManagerEnum->getMetaDataIterator();
+
+	}
+	//-----------------------------------------------------------------------
+	SceneManager* Root::createSceneManager(const String& typeName, 
+		const String& instanceName)
+	{
+		return mSceneManagerEnum->createSceneManager(typeName, instanceName);
+	}
+	//-----------------------------------------------------------------------
+	SceneManager* Root::createSceneManager(SceneTypeMask typeMask, 
+		const String& instanceName)
+	{
+		return mSceneManagerEnum->createSceneManager(typeMask, instanceName);
+	}
+	//-----------------------------------------------------------------------
+	void Root::destroySceneManager(SceneManager* sm)
+	{
+		mSceneManagerEnum->destroySceneManager(sm);
+	}
+	//-----------------------------------------------------------------------
+	SceneManager* Root::getSceneManager(const String& instanceName) const
+	{
+		return mSceneManagerEnum->getSceneManager(instanceName);
+	}
+	//-----------------------------------------------------------------------
+	SceneManagerEnumerator::SceneManagerIterator Root::getSceneManagerIterator(void)
+	{
+		return mSceneManagerEnum->getSceneManagerIterator();
+	}
+    //-----------------------------------------------------------------------
+    TextureManager* Root::getTextureManager(void)
+    {
+        return &TextureManager::getSingleton();
+    }
+    //-----------------------------------------------------------------------
+    MeshManager* Root::getMeshManager(void)
+    {
+        return &MeshManager::getSingleton();
+    }
+    //-----------------------------------------------------------------------
+    void Root::addFrameListener(FrameListener* newListener)
+    {
+        // Insert, unique only (set)
+        mFrameListeners.insert(newListener);
+
+    }
+
+    //-----------------------------------------------------------------------
+    void Root::removeFrameListener(FrameListener* oldListener)
+    {
+        // Remove, 1 only (set)
+        mRemovedFrameListeners.insert(oldListener);
+    }
+    //-----------------------------------------------------------------------
+    bool Root::_fireFrameStarted(FrameEvent& evt)
+    {
+        // Increment frame number
+        ++mCurrentFrame;
+
+        // Remove all marked listeners
+        std::set<FrameListener*>::iterator i;
+        for (i = mRemovedFrameListeners.begin();
+            i != mRemovedFrameListeners.end(); i++)
+        {
+            mFrameListeners.erase(*i);
+        }
+        mRemovedFrameListeners.clear();
+		
+		#ifdef GAMETOOLS_ILLUMINATION_MODULE
+			{
+				std::set<FrameListener*, FrameListenerComparer>::iterator i;
+				for (i= mFrameListeners.begin(); i != mFrameListeners.end(); ++i)
+				{
+					if (!(*i)->frameStarted(evt))
+						return false;
+				}
+			}
+		#else
+			// Tell all listeners
+			for (i= mFrameListeners.begin(); i != mFrameListeners.end(); ++i)
+			{
+				if (!(*i)->frameStarted(evt))
+					return false;
+			}
+		#endif
+
+        return true;
+
+    }
+    //-----------------------------------------------------------------------
+    bool Root::_fireFrameEnded(FrameEvent& evt)
+    {
+        // Remove all marked listeners
+        std::set<FrameListener*>::iterator i;
+        for (i = mRemovedFrameListeners.begin();
+            i != mRemovedFrameListeners.end(); i++)
+        {
+            mFrameListeners.erase(*i);
+        }
+        mRemovedFrameListeners.clear();
+		
+		// Tell all listeners
+		bool ret = true;
+		
+		#ifdef GAMETOOLS_ILLUMINATION_MODULE
+			{				
+				std::set<FrameListener*, FrameListenerComparer>::iterator i;
+				for (i= mFrameListeners.begin(); i != mFrameListeners.end(); ++i)
+				{
+					if (!(*i)->frameEnded(evt))
+					{
+						ret = false;
+						break;
+					}
+				}
+			}
+		#else
+			for (i= mFrameListeners.begin(); i != mFrameListeners.end(); ++i)
+			{
+				if (!(*i)->frameEnded(evt))
+				{
+					ret = false;
+					break;
+				}
+			}
+		#endif
+
+        // Tell buffer manager to free temp buffers used this frame
+        if (HardwareBufferManager::getSingletonPtr())
+            HardwareBufferManager::getSingleton()._releaseBufferCopies();
+
+        return ret;
+    }
+    //-----------------------------------------------------------------------
+    bool Root::_fireFrameStarted()
+    {
+        unsigned long now = mTimer->getMilliseconds();
+        FrameEvent evt;
+        evt.timeSinceLastEvent = calculateEventTime(now, FETT_ANY);
+        evt.timeSinceLastFrame = calculateEventTime(now, FETT_STARTED);
+
+        return _fireFrameStarted(evt);
+    }
+    //-----------------------------------------------------------------------
+    bool Root::_fireFrameEnded()
+    {
+        unsigned long now = mTimer->getMilliseconds();
+        FrameEvent evt;
+        evt.timeSinceLastEvent = calculateEventTime(now, FETT_ANY);
+        evt.timeSinceLastFrame = calculateEventTime(now, FETT_ENDED);
+
+        return _fireFrameEnded(evt);
+    }
+    //-----------------------------------------------------------------------
+    Real Root::calculateEventTime(unsigned long now, FrameEventTimeType type)
+    {
+        // Calculate the average time passed between events of the given type
+        // during the last mFrameSmoothingTime seconds.
+
+        std::deque<unsigned long>& times = mEventTimes[type];
+        times.push_back(now);
+
+        if(times.size() == 1)
+            return 0;
+
+        // Times up to mFrameSmoothingTime seconds old should be kept
+        unsigned long discardThreshold =
+			static_cast<unsigned long>(mFrameSmoothingTime * 1000.0f);
+
+        // Find the oldest time to keep
+        std::deque<unsigned long>::iterator it = times.begin(),
+            end = times.end()-2; // We need at least two times
+        while(it != end)
+        {
+            if (now - *it > discardThreshold)
+                ++it;
+            else
+                break;
+        }
+
+        // Remove old times
+        times.erase(times.begin(), it);
+
+        return Real(times.back() - times.front()) / ((times.size()-1) * 1000);
+    }
+    //-----------------------------------------------------------------------
+    void Root::queueEndRendering(void)
+    {
+	    mQueuedEnd = true;
+    }
+    //-----------------------------------------------------------------------
+    void Root::startRendering(void)
+    {
+        assert(mActiveRenderer != 0);
+
+        mActiveRenderer->_initRenderTargets();
+
+        // Clear event times
+        for(int i=0; i!=3; ++i)
+            mEventTimes[i].clear();
+
+        // Infinite loop, until broken out of by frame listeners
+        // or break out by calling queueEndRendering()
+        mQueuedEnd = false;
+
+        while( !mQueuedEnd )
+        {
+            //Allow platform to pump/create/etc messages/events once per frame
+            mPlatformManager->messagePump(mAutoWindow);
+
+            if (!renderOneFrame())
+                break;
+        }
+    }
+    //-----------------------------------------------------------------------
+    bool Root::renderOneFrame(void)
+    {
+        if(!_fireFrameStarted())
+            return false;
+
+        _updateAllRenderTargets();
+
+        return _fireFrameEnded();
+    }
+    //-----------------------------------------------------------------------
+    void Root::shutdown(void)
+    {
+		SceneManagerEnumerator::getSingleton().shutdownAll();
+		shutdownPlugins();
+
+        ShadowVolumeExtrudeProgram::shutdown();
+		mResourceBackgroundQueue->shutdown();
+        ResourceGroupManager::getSingleton().shutdownAll();
+
+		mIsInitialised = false;
+
+		LogManager::getSingleton().logMessage("*-*-* OGRE Shutdown");
+    }
+    //-----------------------------------------------------------------------
+    void Root::loadPlugins( const String& pluginsfile )
+    {
+        StringVector pluginList;
+        String pluginDir;
+        ConfigFile cfg;
+
+		try {
+        	cfg.load( pluginsfile );
+		}
+		catch (Exception)
+		{
+			LogManager::getSingleton().logMessage(pluginsfile + " not found, automatic plugin loading disabled.");
+			return;
+		}
+
+        pluginDir = cfg.getSetting("PluginFolder"); // Ignored on Mac OS X, uses Resources/ directory
+        pluginList = cfg.getMultiSetting("Plugin");
+
+        char last_char = pluginDir[pluginDir.length()-1];
+        if (last_char != '/' && last_char != '\\')
+        {
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+            pluginDir += "\\";
+#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
+            pluginDir += "/";
+#endif
+        }
+
+        for( StringVector::iterator it = pluginList.begin(); it != pluginList.end(); ++it )
+        {
+			loadPlugin(pluginDir + (*it));
+        }
+
+    }
+    //-----------------------------------------------------------------------
+	void Root::shutdownPlugins(void)
+	{
+		std::vector<DynLib*>::reverse_iterator i;
+
+		// NB Shutdown plugins in reverse order to enforce dependencies
+		for (i = mPluginLibs.rbegin(); i != mPluginLibs.rend(); ++i)
+		{
+			// Call plugin shutdown (optional)
+			DLL_STOP_PLUGIN pFunc = (DLL_STOP_PLUGIN)(*i)->getSymbol("dllShutdownPlugin");
+			if (pFunc)
+			{
+				pFunc();
+			}
+
+		}
+	}
+	//-----------------------------------------------------------------------
+	void Root::initialisePlugins(void)
+	{
+		std::vector<DynLib*>::iterator i;
+
+		for (i = mPluginLibs.begin(); i != mPluginLibs.end(); ++i)
+		{
+			// Call plugin initialise (optional)
+			DLL_INIT_PLUGIN pFunc = (DLL_INIT_PLUGIN)(*i)->getSymbol("dllInitialisePlugin");
+			if (pFunc)
+			{
+				pFunc();
+			}
+
+		}
+	}
+	//-----------------------------------------------------------------------
+	void Root::unloadPlugins(void)
+    {
+        std::vector<DynLib*>::reverse_iterator i;
+
+        // NB Unload plugins in reverse order to enforce dependencies
+        for (i = mPluginLibs.rbegin(); i != mPluginLibs.rend(); ++i)
+        {
+            // Call plugin shutdown
+            DLL_STOP_PLUGIN pFunc = (DLL_STOP_PLUGIN)(*i)->getSymbol("dllStopPlugin");
+            pFunc();
+            // Unload library & destroy
+            DynLibManager::getSingleton().unload(*i);
+
+        }
+
+        mPluginLibs.clear();
+
+    }
+    //-----------------------------------------------------------------------
+    void Root::addResourceLocation(const String& name, const String& locType,
+		const String& groupName, bool recursive)
+    {
+		ResourceGroupManager::getSingleton().addResourceLocation(
+			name, locType, groupName, recursive);
+    }
+	//-----------------------------------------------------------------------
+	void Root::removeResourceLocation(const String& name, const String& groupName)
+	{
+		ResourceGroupManager::getSingleton().removeResourceLocation(
+			name, groupName);
+	}
+    //-----------------------------------------------------------------------
+    void Root::convertColourValue(const ColourValue& colour, uint32* pDest)
+    {
+        assert(mActiveRenderer != 0);
+        mActiveRenderer->convertColourValue(colour, pDest);
+    }
+    //-----------------------------------------------------------------------
+    RenderWindow* Root::getAutoCreatedWindow(void)
+    {
+        return mAutoWindow;
+    }
+    //-----------------------------------------------------------------------
+	RenderWindow* Root::createRenderWindow(const String &name, unsigned int width, unsigned int height,
+			bool fullScreen, const NameValuePairList *miscParams)
+	{
+        if (!mActiveRenderer)
+        {
+            OGRE_EXCEPT(Exception::ERR_NO_RENDERSYSTEM_SELECTED,
+            "Cannot create window - no render "
+            "system has been selected.", "Root::createRenderWindow");
+        }
+        RenderWindow* ret;
+        ret = mActiveRenderer->createRenderWindow(name, width, height, fullScreen, miscParams);
+
+        // Initialisation for classes dependent on first window created
+        if(!mFirstTimePostWindowInit)
+        {
+            oneTimePostWindowInit();
+            ret->_setPrimary();
+        }
+
+        return ret;
+
+    }
+    //-----------------------------------------------------------------------
+    void Root::detachRenderTarget(RenderTarget* target)
+    {
+        if (!mActiveRenderer)
+        {
+            OGRE_EXCEPT(Exception::ERR_NO_RENDERSYSTEM_SELECTED,
+            "Cannot create window - no render "
+            "system has been selected.", "Root::destroyRenderWindow");
+        }
+
+        mActiveRenderer->detachRenderTarget( target->getName() );
+    }
+    //-----------------------------------------------------------------------
+    void Root::detachRenderTarget(const String &name)
+    {
+        if (!mActiveRenderer)
+        {
+            OGRE_EXCEPT(Exception::ERR_NO_RENDERSYSTEM_SELECTED,
+            "Cannot create window - no render "
+            "system has been selected.", "Root::destroyRenderWindow");
+        }
+
+        mActiveRenderer->detachRenderTarget( name );
+    }
+    //-----------------------------------------------------------------------
+    RenderTarget* Root::getRenderTarget(const String &name)
+    {
+        if (!mActiveRenderer)
+        {
+            OGRE_EXCEPT(Exception::ERR_NO_RENDERSYSTEM_SELECTED,
+            "Cannot create window - no render "
+            "system has been selected.", "Root::getRenderWindow");
+        }
+
+        return mActiveRenderer->getRenderTarget(name);
+    }
+    //-----------------------------------------------------------------------
+	void Root::loadPlugin(const String& pluginName)
+	{
+		// Load plugin library
+        DynLib* lib = DynLibManager::getSingleton().load( pluginName );
+		// Store for later unload
+		mPluginLibs.push_back(lib);
+
+		// Call startup function
+		DLL_START_PLUGIN pFunc = (DLL_START_PLUGIN)lib->getSymbol("dllStartPlugin");
+
+		if (!pFunc)
+			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Cannot find symbol dllStartPlugin in library " + pluginName,
+				"Root::loadPlugins");
+		pFunc();
+
+		if (mIsInitialised)
+		{
+			// initialise too
+			DLL_INIT_PLUGIN pFunc = (DLL_INIT_PLUGIN)lib->getSymbol("dllInitialisePlugin");
+			if (pFunc)
+			{
+				pFunc();
+			}
+		}
+	}
+    //-----------------------------------------------------------------------
+	void Root::unloadPlugin(const String& pluginName)
+	{
+        std::vector<DynLib*>::iterator i;
+
+        for (i = mPluginLibs.begin(); i != mPluginLibs.end(); ++i)
+        {
+			if ((*i)->getName() == pluginName)
+			{
+				// Call plugin shutdown
+				DLL_STOP_PLUGIN pFunc = (DLL_STOP_PLUGIN)(*i)->getSymbol("dllStopPlugin");
+				pFunc();
+				// Unload library (destroyed by DynLibManager)
+				DynLibManager::getSingleton().unload(*i);
+				mPluginLibs.erase(i);
+				return;
+			}
+
+        }
+	}
+    //-----------------------------------------------------------------------
+    Timer* Root::getTimer(void)
+    {
+        return mTimer;
+    }
+    //-----------------------------------------------------------------------
+    void Root::oneTimePostWindowInit(void)
+    {
+        if (!mFirstTimePostWindowInit)
+        {
+			// Initialise material manager
+			mMaterialManager->initialise();
+            // Init particle systems manager
+            mParticleManager->_initialise();
+			// Init mesh manager
+			MeshManager::getSingleton()._initialise();
+            mFirstTimePostWindowInit = true;
+        }
+
+    }
+    //-----------------------------------------------------------------------
+    void Root::_updateAllRenderTargets(void)
+    {
+        // delegate
+        mActiveRenderer->_updateAllRenderTargets();
+    }
+	//-----------------------------------------------------------------------
+	void Root::clearEventTimes(void)
+	{
+		// Clear event times
+		for(int i=0; i<3; ++i)
+			mEventTimes[i].clear();
+	}
+	//---------------------------------------------------------------------
+	void Root::addMovableObjectFactory(MovableObjectFactory* fact,
+		bool overrideExisting)
+	{
+		MovableObjectFactoryMap::iterator facti = mMovableObjectFactoryMap.find(
+			fact->getType());
+		if (!overrideExisting && facti != mMovableObjectFactoryMap.end())
+		{
+			OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM,
+				"A factory of type '" + fact->getType() + "' already exists.",
+				"Root::addMovableObjectFactory");
+		}
+
+		if (fact->requestTypeFlags())
+		{
+			if (facti != mMovableObjectFactoryMap.end() && facti->second->requestTypeFlags())
+			{
+				// Copy type flags from the factory we're replacing
+				fact->_notifyTypeFlags(facti->second->getTypeFlags());
+			}
+			else
+			{
+				// Allocate new
+				fact->_notifyTypeFlags(_allocateNextMovableObjectTypeFlag());
+			}
+		}
+
+		// Save
+		mMovableObjectFactoryMap[fact->getType()] = fact;
+
+		LogManager::getSingleton().logMessage("MovableObjectFactory for type '" +
+			fact->getType() + "' registered.");
+
+	}
+	//---------------------------------------------------------------------
+	bool Root::hasMovableObjectFactory(const String& typeName) const
+	{
+		return !(mMovableObjectFactoryMap.find(typeName) == mMovableObjectFactoryMap.end());
+	}
+	//---------------------------------------------------------------------
+	MovableObjectFactory* Root::getMovableObjectFactory(const String& typeName)
+	{
+		MovableObjectFactoryMap::iterator i =
+			mMovableObjectFactoryMap.find(typeName);
+		if (i == mMovableObjectFactoryMap.end())
+		{
+			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
+				"MovableObjectFactory of type " + typeName + " does not exist",
+				"Root::getMovableObjectFactory");
+		}
+		return i->second;
+	}
+	//---------------------------------------------------------------------
+	uint32 Root::_allocateNextMovableObjectTypeFlag(void)
+	{
+		if (mNextMovableObjectTypeFlag == SceneManager::USER_TYPE_MASK_LIMIT)
+		{
+			OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM,
+				"Cannot allocate a type flag since "
+				"all the available flags have been used.",
+				"Root::_allocateNextMovableObjectTypeFlag");
+
+		}
+		uint32 ret = mNextMovableObjectTypeFlag;
+		mNextMovableObjectTypeFlag <<= 1;
+		return ret;
+
+	}
+	//---------------------------------------------------------------------
+	void Root::removeMovableObjectFactory(MovableObjectFactory* fact)
+	{
+		MovableObjectFactoryMap::iterator i = mMovableObjectFactoryMap.find(
+			fact->getType());
+		if (i != mMovableObjectFactoryMap.end())
+		{
+			mMovableObjectFactoryMap.erase(i);
+		}
+
+	}
+	//---------------------------------------------------------------------
+	Root::MovableObjectFactoryIterator
+	Root::getMovableObjectFactoryIterator(void) const
+	{
+		return MovableObjectFactoryIterator(mMovableObjectFactoryMap.begin(),
+			mMovableObjectFactoryMap.end());
+
+	}
+	//---------------------------------------------------------------------
+	RenderQueueInvocationSequence* Root::createRenderQueueInvocationSequence(
+		const String& name)
+	{
+		RenderQueueInvocationSequenceMap::iterator i =
+			mRQSequenceMap.find(name);
+		if (i != mRQSequenceMap.end())
+		{
+			OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM,
+				"RenderQueueInvocationSequence with the name " + name +
+					" already exists.",
+				"Root::createRenderQueueInvocationSequence");
+		}
+		RenderQueueInvocationSequence* ret = new RenderQueueInvocationSequence(name);
+		mRQSequenceMap[name] = ret;
+		return ret;
+	}
+	//---------------------------------------------------------------------
+	RenderQueueInvocationSequence* Root::getRenderQueueInvocationSequence(
+		const String& name)
+	{
+		RenderQueueInvocationSequenceMap::iterator i =
+			mRQSequenceMap.find(name);
+		if (i == mRQSequenceMap.end())
+		{
+			OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
+				"RenderQueueInvocationSequence with the name " + name +
+				" not found.",
+				"Root::getRenderQueueInvocationSequence");
+		}
+		return i->second;
+	}
+	//---------------------------------------------------------------------
+	void Root::destroyRenderQueueInvocationSequence(
+		const String& name)
+	{
+		RenderQueueInvocationSequenceMap::iterator i =
+			mRQSequenceMap.find(name);
+		if (i != mRQSequenceMap.end())
+		{
+			delete i->second;
+			mRQSequenceMap.erase(i);
+		}
+	}
+	//---------------------------------------------------------------------
+	void Root::destroyAllRenderQueueInvocationSequences(void)
+	{
+		for (RenderQueueInvocationSequenceMap::iterator i = mRQSequenceMap.begin();
+			i != mRQSequenceMap.end(); ++i)
+		{
+			delete i->second;
+		}
+		mRQSequenceMap.clear();
+	}
+	//---------------------------------------------------------------------
+
+
+
+}
