# 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>, public RootAlloc
    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         RenderSystemCapabilitiesManager* mRenderSystemCapabilitiesManager;
    00095         ScriptCompilerManager *mCompilerManager;
    00096
    00097         Timer* mTimer;
    00098         RenderWindow* mAutoWindow;
    00099         Profiler* mProfiler;
    00100         HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
    00101         ExternalTextureSourceManager* mExternalTextureSourceManager;
    00102         CompositorManager* mCompositorManager;
    00103         unsigned long mNextFrame;
    00104         Real mFrameSmoothingTime;
    00105
    00106     public:
    00107         typedef std::vector<DynLib*> PluginLibList;
    00108         typedef std::vector<Plugin*> PluginInstanceList;
    00109     protected:
    00111         PluginLibList mPluginLibs;
    00113         PluginInstanceList mPlugins;
    00114
    00115         typedef std::map<String, MovableObjectFactory*> MovableObjectFactoryMap;
    00116         MovableObjectFactoryMap mMovableObjectFactoryMap;
    00117         uint32 mNextMovableObjectTypeFlag;
    00118         // stock movable factories
    00119         MovableObjectFactory* mEntityFactory;
    00120         MovableObjectFactory* mLightFactory;
    00121         MovableObjectFactory* mBillboardSetFactory;
    00122         MovableObjectFactory* mManualObjectFactory;
    00123         MovableObjectFactory* mBillboardChainFactory;
    00124         MovableObjectFactory* mRibbonTrailFactory;
    00125
    00126         typedef std::map<String, RenderQueueInvocationSequence*> RenderQueueInvocationSequenceMap;
    00127         RenderQueueInvocationSequenceMap mRQSequenceMap;
    00128
    00130         bool mIsInitialised;
    00131
    00138         void loadPlugins( const String& pluginsfile = "plugins.cfg" );
    00142         void initialisePlugins();
    00146         void shutdownPlugins();
    00147
    00150         void unloadPlugins();
    00151
    00152         // Internal method for one-time tasks after first window creation
    00153         void oneTimePostWindowInit(void);
    00154
    00156         std::set<FrameListener*> mFrameListeners;
    00157
    00159         std::set<FrameListener*> mRemovedFrameListeners;
    00160
    00162         enum FrameEventTimeType {
    00163             FETT_ANY = 0,
    00164             FETT_STARTED = 1,
    00165             FETT_QUEUED = 2,
    00166             FETT_ENDED = 3,
    00167             FETT_COUNT = 4
    00168         };
    00169
    00171         std::deque<unsigned long> mEventTimes[FETT_COUNT];
    00172
    00177         Real calculateEventTime(unsigned long now, FrameEventTimeType type);
    00178     public:
    00179
    00188         Root(const String& pluginFileName = "plugins.cfg",
    00189             const String& configFileName = "ogre.cfg",
    00190             const String& logFileName = "Ogre.log");
    00191         ~Root();
    00192
    00198         void saveConfig(void);
    00199
    00212         bool restoreConfig(void);
    00213
    00230         bool showConfigDialog(void);
    00231
    00243         void addRenderSystem(RenderSystem* newRend);
    00244
    00251         RenderSystemList* getAvailableRenderers(void);
    00252
    00259         RenderSystem* getRenderSystemByName(const String& name);
    00260
    00278         void setRenderSystem(RenderSystem* system);
    00279
    00282         RenderSystem* getRenderSystem(void);
    00283
    00299         RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
    00300                                     const String& customCapabilitiesConfig = StringUtil::BLANK);
    00301
    00303         bool isInitialised(void) const { return mIsInitialised; }
    00304
    00310         void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities);
    00311
    00317         void addSceneManagerFactory(SceneManagerFactory* fact);
    00318
    00321         void removeSceneManagerFactory(SceneManagerFactory* fact);
    00322
    00332         const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
    00333
    00337         SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
    00338
    00350         SceneManager* createSceneManager(const String& typeName,
    00351             const String& instanceName = StringUtil::BLANK);
    00352
    00365         SceneManager* createSceneManager(SceneTypeMask typeMask,
    00366             const String& instanceName = StringUtil::BLANK);
    00367
    00369         void destroySceneManager(SceneManager* sm);
    00370
    00375         SceneManager* getSceneManager(const String& instanceName) const;
    00376
    00378         SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
    00379
    00395         TextureManager* getTextureManager(void);
    00396
    00402         MeshManager* getMeshManager(void);
    00403
    00407         String getErrorDescription(long errorNumber);
    00408
    00425         void addFrameListener(FrameListener* newListener);
    00426
    00431         void removeFrameListener(FrameListener* oldListener);
    00432
    00441         void queueEndRendering(void);
    00442
    00470         void startRendering(void);
    00471
    00477         bool renderOneFrame(void);
    00485         void shutdown(void);
    00486
    00533         void addResourceLocation(const String& name, const String& locType,
    00534             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    00535             bool recursive = false);
    00536
    00543         void removeResourceLocation(const String& name,
    00544             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    00545
    00554         void convertColourValue(const ColourValue& colour, uint32* pDest);
    00555
    00564         RenderWindow* getAutoCreatedWindow(void);
    00565
    00568         RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
    00569             bool fullScreen, const NameValuePairList *miscParams = 0) ;
    00570
    00573         void detachRenderTarget( RenderTarget* pWin );
    00574
    00577         void detachRenderTarget( const String & name );
    00578
    00581         RenderTarget * getRenderTarget(const String &name);
    00582
    00593         void loadPlugin(const String& pluginName);
    00594
    00604         void unloadPlugin(const String& pluginName);
    00605
    00616         void installPlugin(Plugin* plugin);
    00617
    00626         void uninstallPlugin(Plugin* plugin);
    00627
    00629         const PluginInstanceList& getInstalledPlugins() const { return mPlugins; }
    00630
    00632         Timer* getTimer(void);
    00633
    00653         bool _fireFrameStarted(FrameEvent& evt);
    00663         bool _fireFrameRenderingQueued(FrameEvent& evt);
    00664
    00681         bool _fireFrameEnded(FrameEvent& evt);
    00699         bool _fireFrameStarted();
    00710         bool _fireFrameRenderingQueued();
    00725         bool _fireFrameEnded();
    00726
    00735         unsigned long getNextFrameNumber(void) const { return mNextFrame; }
    00736
    00742         SceneManager* _getCurrentSceneManager(void) const { return mCurrentSceneManager; }
    00747         void _setCurrentSceneManager(SceneManager* sm);
    00748
    00759         bool _updateAllRenderTargets(void);
    00760
    00765         RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
    00766             const String& name);
    00767
    00771         RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
    00772             const String& name);
    00773
    00779         void destroyRenderQueueInvocationSequence(
    00780             const String& name);
    00781
    00787         void destroyAllRenderQueueInvocationSequences(void);
    00788
    00804         static Root& getSingleton(void);
    00820         static Root* getSingletonPtr(void);
    00821
    00830         void clearEventTimes(void);
    00831
    00844         void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
    00846         Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
    00847
    00860         void addMovableObjectFactory(MovableObjectFactory* fact,
    00861             bool overrideExisting = false);
    00869         void removeMovableObjectFactory(MovableObjectFactory* fact);
    00871         bool hasMovableObjectFactory(const String& typeName) const;
    00873         MovableObjectFactory* getMovableObjectFactory(const String& typeName);
    00879         uint32 _allocateNextMovableObjectTypeFlag(void);
    00880
    00881         typedef ConstMapIterator<MovableObjectFactoryMap> MovableObjectFactoryIterator;
    00885         MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
    00886     };
    00887 } // Namespace Ogre
    00888 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat Apr 11 14:26:46 2009