# 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-2005 The OGRE Team
    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 */
    00025 #ifndef __ROOT__
    00026 #define __ROOT__
    00027
    00028 // Precompiler options
    00029 #include "OgrePrerequisites.h"
    00030
    00031 #include "OgreSingleton.h"
    00032 #include "OgreString.h"
    00033 #include "OgreSceneManagerEnumerator.h"
    00034 #include "OgreResourceGroupManager.h"
    00035
    00036 #include <exception>
    00037
    00038 #if OGRE_COMPILER == OGRE_COMPILER_MSVC || OGRE_COMPILER == OGRE_COMPILER_BORL
    00039 #   define SET_TERM_HANDLER { set_terminate( &Ogre::Root::termHandler ); }
    00040 #else
    00041 #   define SET_TERM_HANDLER { std::set_terminate( &Ogre::Root::termHandler ); }
    00042 #endif
    00043
    00044 namespace Ogre
    00045 {
    00046     typedef std::vector<RenderSystem*> RenderSystemList;
    00047
    00061     class _OgreExport Root : public Singleton<Root>
    00062     {
    00063         // To allow update of active renderer if
    00064         // RenderSystem::initialise is used directly
    00065         friend class RenderSystem;
    00066     private:
    00067         RenderSystemList mRenderers;
    00068         RenderSystem* mActiveRenderer;
    00069         String mVersion;
    00070         String mConfigFileName;
    00071         bool mQueuedEnd;
    00072         // In case multiple render windows are created, only once are the resources loaded.
    00073         bool mFirstTimePostWindowInit;
    00074
    00075         // Singletons
    00076         LogManager* mLogManager;
    00077         ControllerManager* mControllerManager;
    00078         SceneManagerEnumerator* mSceneManagerEnum;
    00079         SceneManager* mCurrentSceneManager;
    00080         DynLibManager* mDynLibManager;
    00081         PlatformManager* mPlatformManager;
    00082         ArchiveManager* mArchiveManager;
    00083         MaterialManager* mMaterialManager;
    00084         MeshManager* mMeshManager;
    00085         ParticleSystemManager* mParticleManager;
    00086         SkeletonManager* mSkeletonManager;
    00087         OverlayElementFactory* mPanelFactory;
    00088         OverlayElementFactory* mBorderPanelFactory;
    00089         OverlayElementFactory* mTextAreaFactory;
    00090         OverlayManager* mOverlayManager;
    00091         FontManager* mFontManager;
    00092         ArchiveFactory *mZipArchiveFactory;
    00093         ArchiveFactory *mFileSystemArchiveFactory;
    00094         ResourceGroupManager* mResourceGroupManager;
    00095         ResourceBackgroundQueue* mResourceBackgroundQueue;
    00096
    00097         Timer* mTimer;
    00098         RenderWindow* mAutoWindow;
    00099         Profiler* mProfiler;
    00100         HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
    00101         ExternalTextureSourceManager* mExternalTextureSourceManager;
    00102         CompositorManager* mCompositorManager;
    00103         unsigned long mCurrentFrame;
    00104         Real mFrameSmoothingTime;
    00105
    00106         std::vector<DynLib*> mPluginLibs;
    00107
    00108         typedef std::map<String, MovableObjectFactory*> MovableObjectFactoryMap;
    00109         MovableObjectFactoryMap mMovableObjectFactoryMap;
    00110         uint32 mNextMovableObjectTypeFlag;
    00111         // stock movable factories
    00112         MovableObjectFactory* mEntityFactory;
    00113         MovableObjectFactory* mLightFactory;
    00114         MovableObjectFactory* mBillboardSetFactory;
    00115         MovableObjectFactory* mManualObjectFactory;
    00116         MovableObjectFactory* mBillboardChainFactory;
    00117         MovableObjectFactory* mRibbonTrailFactory;
    00118
    00119         typedef std::map<String, RenderQueueInvocationSequence*> RenderQueueInvocationSequenceMap;
    00120         RenderQueueInvocationSequenceMap mRQSequenceMap;
    00121
    00123         bool mIsInitialised;
    00124
    00131         void loadPlugins( const String& pluginsfile = "plugins.cfg" );
    00135         void initialisePlugins();
    00139         void shutdownPlugins();
    00140
    00143         void unloadPlugins();
    00144
    00145         // Internal method for one-time tasks after first window creation
    00146         void oneTimePostWindowInit(void);
    00147
    00149         std::set<FrameListener*> mFrameListeners;
    00150
    00152         std::set<FrameListener*> mRemovedFrameListeners;
    00153
    00155         enum FrameEventTimeType {
    00156             FETT_ANY, FETT_STARTED, FETT_ENDED
    00157         };
    00158
    00160         std::deque<unsigned long> mEventTimes[3];
    00161
    00166         Real calculateEventTime(unsigned long now, FrameEventTimeType type);
    00167     public:
    00168
    00169         static void termHandler();
    00170
    00176         Root(const String& pluginFileName = "plugins.cfg", const String& configFileName = "ogre.cfg", const String& logFileName = "Ogre.log");
    00177         ~Root();
    00178
    00184         void saveConfig(void);
    00185
    00198         bool restoreConfig(void);
    00199
    00216         bool showConfigDialog(void);
    00217
    00229         void addRenderSystem(RenderSystem* newRend);
    00230
    00237         RenderSystemList* getAvailableRenderers(void);
    00238
    00245         RenderSystem* getRenderSystemByName(const String& name);
    00246
    00264         void setRenderSystem(RenderSystem* system);
    00265
    00268         RenderSystem* getRenderSystem(void);
    00269
    00285         RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
    00286
    00288         bool isInitialised(void) const { return mIsInitialised; }
    00289
    00295         void addSceneManagerFactory(SceneManagerFactory* fact);
    00296
    00299         void removeSceneManagerFactory(SceneManagerFactory* fact);
    00300
    00310         const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
    00311
    00315         SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
    00316
    00328         SceneManager* createSceneManager(const String& typeName,
    00329             const String& instanceName = StringUtil::BLANK);
    00330
    00343         SceneManager* createSceneManager(SceneTypeMask typeMask,
    00344             const String& instanceName = StringUtil::BLANK);
    00345
    00347         void destroySceneManager(SceneManager* sm);
    00348
    00353         SceneManager* getSceneManager(const String& instanceName) const;
    00354
    00356         SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
    00357
    00373         TextureManager* getTextureManager(void);
    00374
    00380         MeshManager* getMeshManager(void);
    00381
    00385         String getErrorDescription(long errorNumber);
    00386
    00403         void addFrameListener(FrameListener* newListener);
    00404
    00409         void removeFrameListener(FrameListener* oldListener);
    00410
    00419         void queueEndRendering(void);
    00420
    00446         void startRendering(void);
    00447
    00453         bool renderOneFrame(void);
    00461         void shutdown(void);
    00462
    00509         void addResourceLocation(const String& name, const String& locType,
    00510             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    00511             bool recursive = false);
    00512
    00519         void removeResourceLocation(const String& name,
    00520             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    00521
    00530         void convertColourValue(const ColourValue& colour, uint32* pDest);
    00531
    00540         RenderWindow* getAutoCreatedWindow(void);
    00541
    00544         RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
    00545             bool fullScreen, const NameValuePairList *miscParams = 0) ;
    00546
    00549         void detachRenderTarget( RenderTarget* pWin );
    00550
    00553         void detachRenderTarget( const String & name );
    00554
    00557         RenderTarget * getRenderTarget(const String &name);
    00558
    00575         void loadPlugin(const String& pluginName);
    00576
    00584         void unloadPlugin(const String& pluginName);
    00585
    00587         Timer* getTimer(void);
    00588
    00608         bool _fireFrameStarted(FrameEvent& evt);
    00625         bool _fireFrameEnded(FrameEvent& evt);
    00643         bool _fireFrameStarted();
    00658         bool _fireFrameEnded();
    00659
    00661         unsigned long getCurrentFrameNumber(void) const { return mCurrentFrame; }
    00662
    00668         SceneManager* _getCurrentSceneManager(void) const { return mCurrentSceneManager; }
    00673         void _setCurrentSceneManager(SceneManager* sm);
    00674
    00684         void _updateAllRenderTargets(void);
    00685
    00690         RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
    00691             const String& name);
    00692
    00696         RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
    00697             const String& name);
    00698
    00704         void destroyRenderQueueInvocationSequence(
    00705             const String& name);
    00706
    00712         void destroyAllRenderQueueInvocationSequences(void);
    00713
    00729         static Root& getSingleton(void);
    00745         static Root* getSingletonPtr(void);
    00746
    00755         void clearEventTimes(void);
    00756
    00769         void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
    00771         Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
    00772
    00785         void addMovableObjectFactory(MovableObjectFactory* fact,
    00786             bool overrideExisting = false);
    00794         void removeMovableObjectFactory(MovableObjectFactory* fact);
    00796         bool hasMovableObjectFactory(const String& typeName) const;
    00798         MovableObjectFactory* getMovableObjectFactory(const String& typeName);
    00804         uint32 _allocateNextMovableObjectTypeFlag(void);
    00805
    00806         typedef ConstMapIterator<MovableObjectFactoryMap> MovableObjectFactoryIterator;
    00810         MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
    00811     };
    00812 } // Namespace Ogre
    00813 #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 17 15:39:11 2006