Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# OgreRoot.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __ROOT__
    00030 #define __ROOT__
    00031
    00032 // Precompiler options
    00033 #include "OgrePrerequisites.h"
    00034
    00035 #include "OgreSingleton.h"
    00036 #include "OgreString.h"
    00037 #include "OgreSceneManagerEnumerator.h"
    00038 #include "OgreResourceGroupManager.h"
    00039
    00040 #include <exception>
    00041
    00042 namespace Ogre
    00043 {
    00044     typedef std::vector<RenderSystem*> RenderSystemList;
    00045
    00059     class _OgreExport Root : public Singleton<Root>
    00060     {
    00061         // To allow update of active renderer if
    00062         // RenderSystem::initialise is used directly
    00063         friend class RenderSystem;
    00064     private:
    00065         RenderSystemList mRenderers;
    00066         RenderSystem* mActiveRenderer;
    00067         String mVersion;
    00068         String mConfigFileName;
    00069         bool mQueuedEnd;
    00070         // In case multiple render windows are created, only once are the resources loaded.
    00071         bool mFirstTimePostWindowInit;
    00072
    00073         // Singletons
    00074         LogManager* mLogManager;
    00075         ControllerManager* mControllerManager;
    00076         SceneManagerEnumerator* mSceneManagerEnum;
    00077         SceneManager* mCurrentSceneManager;
    00078         DynLibManager* mDynLibManager;
    00079         ArchiveManager* mArchiveManager;
    00080         MaterialManager* mMaterialManager;
    00081         MeshManager* mMeshManager;
    00082         ParticleSystemManager* mParticleManager;
    00083         SkeletonManager* mSkeletonManager;
    00084         OverlayElementFactory* mPanelFactory;
    00085         OverlayElementFactory* mBorderPanelFactory;
    00086         OverlayElementFactory* mTextAreaFactory;
    00087         OverlayManager* mOverlayManager;
    00088         FontManager* mFontManager;
    00089         ArchiveFactory *mZipArchiveFactory;
    00090         ArchiveFactory *mFileSystemArchiveFactory;
    00091         ResourceGroupManager* mResourceGroupManager;
    00092         ResourceBackgroundQueue* mResourceBackgroundQueue;
    00093         ShadowTextureManager* mShadowTextureManager;
    00094
    00095         Timer* mTimer;
    00096         RenderWindow* mAutoWindow;
    00097         Profiler* mProfiler;
    00098         HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
    00099         ExternalTextureSourceManager* mExternalTextureSourceManager;
    00100         CompositorManager* mCompositorManager;
    00101         unsigned long mCurrentFrame;
    00102         Real mFrameSmoothingTime;
    00103
    00104     public:
    00105         typedef std::vector<DynLib*> PluginLibList;
    00106         typedef std::vector<Plugin*> PluginInstanceList;
    00107     protected:
    00109         PluginLibList mPluginLibs;
    00111         PluginInstanceList mPlugins;
    00112
    00113         typedef std::map<String, MovableObjectFactory*> MovableObjectFactoryMap;
    00114         MovableObjectFactoryMap mMovableObjectFactoryMap;
    00115         uint32 mNextMovableObjectTypeFlag;
    00116         // stock movable factories
    00117         MovableObjectFactory* mEntityFactory;
    00118         MovableObjectFactory* mLightFactory;
    00119         MovableObjectFactory* mBillboardSetFactory;
    00120         MovableObjectFactory* mManualObjectFactory;
    00121         MovableObjectFactory* mBillboardChainFactory;
    00122         MovableObjectFactory* mRibbonTrailFactory;
    00123
    00124         typedef std::map<String, RenderQueueInvocationSequence*> RenderQueueInvocationSequenceMap;
    00125         RenderQueueInvocationSequenceMap mRQSequenceMap;
    00126
    00128         bool mIsInitialised;
    00129
    00136         void loadPlugins( const String& pluginsfile = "plugins.cfg" );
    00140         void initialisePlugins();
    00144         void shutdownPlugins();
    00145
    00148         void unloadPlugins();
    00149
    00150         // Internal method for one-time tasks after first window creation
    00151         void oneTimePostWindowInit(void);
    00152
    00154         std::set<FrameListener*> mFrameListeners;
    00155
    00157         std::set<FrameListener*> mRemovedFrameListeners;
    00158
    00160         enum FrameEventTimeType {
    00161             FETT_ANY, FETT_STARTED, FETT_ENDED
    00162         };
    00163
    00165         std::deque<unsigned long> mEventTimes[3];
    00166
    00171         Real calculateEventTime(unsigned long now, FrameEventTimeType type);
    00172     public:
    00173
    00182         Root(const String& pluginFileName = "plugins.cfg",
    00183             const String& configFileName = "ogre.cfg",
    00184             const String& logFileName = "Ogre.log");
    00185         ~Root();
    00186
    00192         void saveConfig(void);
    00193
    00206         bool restoreConfig(void);
    00207
    00224         bool showConfigDialog(void);
    00225
    00237         void addRenderSystem(RenderSystem* newRend);
    00238
    00245         RenderSystemList* getAvailableRenderers(void);
    00246
    00253         RenderSystem* getRenderSystemByName(const String& name);
    00254
    00272         void setRenderSystem(RenderSystem* system);
    00273
    00276         RenderSystem* getRenderSystem(void);
    00277
    00293         RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
    00294
    00296         bool isInitialised(void) const { return mIsInitialised; }
    00297
    00303         void addSceneManagerFactory(SceneManagerFactory* fact);
    00304
    00307         void removeSceneManagerFactory(SceneManagerFactory* fact);
    00308
    00318         const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
    00319
    00323         SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
    00324
    00336         SceneManager* createSceneManager(const String& typeName,
    00337             const String& instanceName = StringUtil::BLANK);
    00338
    00351         SceneManager* createSceneManager(SceneTypeMask typeMask,
    00352             const String& instanceName = StringUtil::BLANK);
    00353
    00355         void destroySceneManager(SceneManager* sm);
    00356
    00361         SceneManager* getSceneManager(const String& instanceName) const;
    00362
    00364         SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
    00365
    00381         TextureManager* getTextureManager(void);
    00382
    00388         MeshManager* getMeshManager(void);
    00389
    00393         String getErrorDescription(long errorNumber);
    00394
    00411         void addFrameListener(FrameListener* newListener);
    00412
    00417         void removeFrameListener(FrameListener* oldListener);
    00418
    00427         void queueEndRendering(void);
    00428
    00456         void startRendering(void);
    00457
    00463         bool renderOneFrame(void);
    00471         void shutdown(void);
    00472
    00519         void addResourceLocation(const String& name, const String& locType,
    00520             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    00521             bool recursive = false);
    00522
    00529         void removeResourceLocation(const String& name,
    00530             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    00531
    00540         void convertColourValue(const ColourValue& colour, uint32* pDest);
    00541
    00550         RenderWindow* getAutoCreatedWindow(void);
    00551
    00554         RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
    00555             bool fullScreen, const NameValuePairList *miscParams = 0) ;
    00556
    00559         void detachRenderTarget( RenderTarget* pWin );
    00560
    00563         void detachRenderTarget( const String & name );
    00564
    00567         RenderTarget * getRenderTarget(const String &name);
    00568
    00579         void loadPlugin(const String& pluginName);
    00580
    00590         void unloadPlugin(const String& pluginName);
    00591
    00602         void installPlugin(Plugin* plugin);
    00603
    00612         void uninstallPlugin(Plugin* plugin);
    00613
    00615         const PluginInstanceList& getInstalledPlugins() const { return mPlugins; }
    00616
    00618         Timer* getTimer(void);
    00619
    00639         bool _fireFrameStarted(FrameEvent& evt);
    00656         bool _fireFrameEnded(FrameEvent& evt);
    00674         bool _fireFrameStarted();
    00689         bool _fireFrameEnded();
    00690
    00692         unsigned long getCurrentFrameNumber(void) const { return mCurrentFrame; }
    00693
    00699         SceneManager* _getCurrentSceneManager(void) const { return mCurrentSceneManager; }
    00704         void _setCurrentSceneManager(SceneManager* sm);
    00705
    00715         void _updateAllRenderTargets(void);
    00716
    00721         RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
    00722             const String& name);
    00723
    00727         RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
    00728             const String& name);
    00729
    00735         void destroyRenderQueueInvocationSequence(
    00736             const String& name);
    00737
    00743         void destroyAllRenderQueueInvocationSequences(void);
    00744
    00760         static Root& getSingleton(void);
    00776         static Root* getSingletonPtr(void);
    00777
    00786         void clearEventTimes(void);
    00787
    00800         void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
    00802         Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
    00803
    00816         void addMovableObjectFactory(MovableObjectFactory* fact,
    00817             bool overrideExisting = false);
    00825         void removeMovableObjectFactory(MovableObjectFactory* fact);
    00827         bool hasMovableObjectFactory(const String& typeName) const;
    00829         MovableObjectFactory* getMovableObjectFactory(const String& typeName);
    00835         uint32 _allocateNextMovableObjectTypeFlag(void);
    00836
    00837         typedef ConstMapIterator<MovableObjectFactoryMap> MovableObjectFactoryIterator;
    00841         MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
    00842     };
    00843 } // Namespace Ogre
    00844 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 30 10:50:57 2007