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-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028 #ifndef __ROOT__
    00029 #define __ROOT__
    00030
    00031 // Precompiler options
    00032 #include "OgrePrerequisites.h"
    00033
    00034 #include "OgreSingleton.h"
    00035 #include "OgreString.h"
    00036 #include "OgreSceneManagerEnumerator.h"
    00037 #include "OgreResourceGroupManager.h"
    00038 #include "OgreLodStrategyManager.h"
    00039 #include "OgreWorkQueue.h"
    00040
    00041 #include <exception>
    00042
    00043 namespace Ogre
    00044 {
    00052     typedef vector<RenderSystem*>::type RenderSystemList;
    00053
    00067     class _OgreExport Root : public Singleton<Root>, public RootAlloc
    00068     {
    00069         // To allow update of active renderer if
    00070         // RenderSystem::initialise is used directly
    00071         friend class RenderSystem;
    00072     protected:
    00073         RenderSystemList mRenderers;
    00074         RenderSystem* mActiveRenderer;
    00075         String mVersion;
    00076         String mConfigFileName;
    00077         bool mQueuedEnd;
    00078         // In case multiple render windows are created, only once are the resources loaded.
    00079         bool mFirstTimePostWindowInit;
    00080
    00081         // Singletons
    00082         LogManager* mLogManager;
    00083         ControllerManager* mControllerManager;
    00084         SceneManagerEnumerator* mSceneManagerEnum;
    00085         typedef deque<SceneManager*>::type SceneManagerStack;
    00086         SceneManagerStack mSceneManagerStack;
    00087         DynLibManager* mDynLibManager;
    00088         ArchiveManager* mArchiveManager;
    00089         MaterialManager* mMaterialManager;
    00090         MeshManager* mMeshManager;
    00091         ParticleSystemManager* mParticleManager;
    00092         SkeletonManager* mSkeletonManager;
    00093         OverlayElementFactory* mPanelFactory;
    00094         OverlayElementFactory* mBorderPanelFactory;
    00095         OverlayElementFactory* mTextAreaFactory;
    00096         OverlayManager* mOverlayManager;
    00097         FontManager* mFontManager;
    00098         ArchiveFactory *mZipArchiveFactory;
    00099         ArchiveFactory *mEmbeddedZipArchiveFactory;
    00100         ArchiveFactory *mFileSystemArchiveFactory;
    00101         ResourceGroupManager* mResourceGroupManager;
    00102         ResourceBackgroundQueue* mResourceBackgroundQueue;
    00103         ShadowTextureManager* mShadowTextureManager;
    00104         RenderSystemCapabilitiesManager* mRenderSystemCapabilitiesManager;
    00105         ScriptCompilerManager *mCompilerManager;
    00106         LodStrategyManager *mLodStrategyManager;
    00107
    00108         Timer* mTimer;
    00109         RenderWindow* mAutoWindow;
    00110         Profiler* mProfiler;
    00111         HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
    00112         ExternalTextureSourceManager* mExternalTextureSourceManager;
    00113         CompositorManager* mCompositorManager;
    00114         unsigned long mNextFrame;
    00115         Real mFrameSmoothingTime;
    00116         bool mRemoveQueueStructuresOnClear;
    00117         Real mDefaultMinPixelSize;
    00118
    00119     public:
    00120         typedef vector<DynLib*>::type PluginLibList;
    00121         typedef vector<Plugin*>::type PluginInstanceList;
    00122     protected:
    00124         PluginLibList mPluginLibs;
    00126         PluginInstanceList mPlugins;
    00127
    00128         typedef map<String, MovableObjectFactory*>::type MovableObjectFactoryMap;
    00129         MovableObjectFactoryMap mMovableObjectFactoryMap;
    00130         uint32 mNextMovableObjectTypeFlag;
    00131         // stock movable factories
    00132         MovableObjectFactory* mEntityFactory;
    00133         MovableObjectFactory* mLightFactory;
    00134         MovableObjectFactory* mBillboardSetFactory;
    00135         MovableObjectFactory* mManualObjectFactory;
    00136         MovableObjectFactory* mBillboardChainFactory;
    00137         MovableObjectFactory* mRibbonTrailFactory;
    00138
    00139         typedef map<String, RenderQueueInvocationSequence*>::type RenderQueueInvocationSequenceMap;
    00140         RenderQueueInvocationSequenceMap mRQSequenceMap;
    00141
    00143         bool mIsInitialised;
    00144
    00145         WorkQueue* mWorkQueue;
    00146
    00148         bool mIsBlendIndicesGpuRedundant;
    00150         bool mIsBlendWeightsGpuRedundant;
    00151
    00158         void loadPlugins( const String& pluginsfile = "plugins.cfg" );
    00162         void initialisePlugins();
    00166         void shutdownPlugins();
    00167
    00170         void unloadPlugins();
    00171
    00172         // Internal method for one-time tasks after first window creation
    00173         void oneTimePostWindowInit(void);
    00174
    00176         set<FrameListener*>::type mFrameListeners;
    00177
    00179         set<FrameListener*>::type mRemovedFrameListeners;
    00180
    00182         enum FrameEventTimeType {
    00183             FETT_ANY = 0,
    00184             FETT_STARTED = 1,
    00185             FETT_QUEUED = 2,
    00186             FETT_ENDED = 3,
    00187             FETT_COUNT = 4
    00188         };
    00189
    00191         typedef deque<unsigned long>::type EventTimesQueue;
    00192         EventTimesQueue mEventTimes[FETT_COUNT];
    00193
    00198         Real calculateEventTime(unsigned long now, FrameEventTimeType type);
    00199
    00201         void populateFrameEvent(FrameEventTimeType type, FrameEvent& evtToUpdate);
    00202
    00203     public:
    00204
    00213         Root(const String& pluginFileName = "plugins.cfg",
    00214             const String& configFileName = "ogre.cfg",
    00215             const String& logFileName = "Ogre.log");
    00216         ~Root();
    00217
    00223         void saveConfig(void);
    00224
    00237         bool restoreConfig(void);
    00238
    00255         bool showConfigDialog(void);
    00256
    00268         void addRenderSystem(RenderSystem* newRend);
    00269
    00276         const RenderSystemList& getAvailableRenderers(void);
    00277
    00284         RenderSystem* getRenderSystemByName(const String& name);
    00285
    00303         void setRenderSystem(RenderSystem* system);
    00304
    00307         RenderSystem* getRenderSystem(void);
    00308
    00324         RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
    00325                                     const String& customCapabilitiesConfig = StringUtil::BLANK);
    00326
    00328         bool isInitialised(void) const { return mIsInitialised; }
    00329
    00335         void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities);
    00336
    00340         bool getRemoveRenderQueueStructuresOnClear() const { return mRemoveQueueStructuresOnClear; }
    00341
    00345         void setRemoveRenderQueueStructuresOnClear(bool r) { mRemoveQueueStructuresOnClear = r; }
    00346
    00352         void addSceneManagerFactory(SceneManagerFactory* fact);
    00353
    00356         void removeSceneManagerFactory(SceneManagerFactory* fact);
    00357
    00367         const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
    00368
    00372         SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
    00373
    00385         SceneManager* createSceneManager(const String& typeName,
    00386             const String& instanceName = StringUtil::BLANK);
    00387
    00400         SceneManager* createSceneManager(SceneTypeMask typeMask,
    00401             const String& instanceName = StringUtil::BLANK);
    00402
    00404         void destroySceneManager(SceneManager* sm);
    00405
    00410         SceneManager* getSceneManager(const String& instanceName) const;
    00411
    00415         bool hasSceneManager(const String& instanceName) const;
    00417         SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
    00418
    00434         TextureManager* getTextureManager(void);
    00435
    00441         MeshManager* getMeshManager(void);
    00442
    00446         String getErrorDescription(long errorNumber);
    00447
    00464         void addFrameListener(FrameListener* newListener);
    00465
    00470         void removeFrameListener(FrameListener* oldListener);
    00471
    00480         void queueEndRendering(void);
    00481
    00509         void startRendering(void);
    00510
    00516         bool renderOneFrame(void);
    00517
    00524         bool renderOneFrame(Real timeSinceLastFrame);
    00525
    00533         void shutdown(void);
    00534
    00581         void addResourceLocation(const String& name, const String& locType,
    00582             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    00583             bool recursive = false);
    00584
    00591         void removeResourceLocation(const String& name,
    00592             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    00593
    00615         DataStreamPtr createFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    00616             bool overwrite = false, const String& locationPattern = StringUtil::BLANK);
    00617
    00632         DataStreamPtr openFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
    00633             const String& locationPattern = StringUtil::BLANK);
    00634
    00643         void convertColourValue(const ColourValue& colour, uint32* pDest);
    00644
    00653         RenderWindow* getAutoCreatedWindow(void);
    00654
    00657         RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
    00658             bool fullScreen, const NameValuePairList *miscParams = 0) ;
    00659
    00662         bool createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions,
    00663             RenderWindowList& createdWindows);
    00664
    00670         RenderTarget* detachRenderTarget( RenderTarget* pWin );
    00671
    00677         RenderTarget* detachRenderTarget( const String & name );
    00678
    00681         void destroyRenderTarget(RenderTarget* target);
    00682
    00685         void destroyRenderTarget(const String &name);
    00686
    00689         RenderTarget * getRenderTarget(const String &name);
    00690
    00701         void loadPlugin(const String& pluginName);
    00702
    00712         void unloadPlugin(const String& pluginName);
    00713
    00724         void installPlugin(Plugin* plugin);
    00725
    00734         void uninstallPlugin(Plugin* plugin);
    00735
    00737         const PluginInstanceList& getInstalledPlugins() const { return mPlugins; }
    00738
    00740         Timer* getTimer(void);
    00741
    00761         bool _fireFrameStarted(FrameEvent& evt);
    00771         bool _fireFrameRenderingQueued(FrameEvent& evt);
    00772
    00789         bool _fireFrameEnded(FrameEvent& evt);
    00807         bool _fireFrameStarted();
    00818         bool _fireFrameRenderingQueued();
    00833         bool _fireFrameEnded();
    00834
    00843         unsigned long getNextFrameNumber(void) const { return mNextFrame; }
    00844
    00850         SceneManager* _getCurrentSceneManager(void) const;
    00855         void _pushCurrentSceneManager(SceneManager* sm);
    00860         void _popCurrentSceneManager(SceneManager* sm);
    00861
    00872         bool _updateAllRenderTargets(void);
    00873
    00885         bool _updateAllRenderTargets(FrameEvent& evt);
    00886
    00891         RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
    00892             const String& name);
    00893
    00897         RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
    00898             const String& name);
    00899
    00905         void destroyRenderQueueInvocationSequence(
    00906             const String& name);
    00907
    00913         void destroyAllRenderQueueInvocationSequences(void);
    00914
    00930         static Root& getSingleton(void);
    00946         static Root* getSingletonPtr(void);
    00947
    00956         void clearEventTimes(void);
    00957
    00970         void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
    00972         Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
    00973
    00986         void addMovableObjectFactory(MovableObjectFactory* fact,
    00987             bool overrideExisting = false);
    00995         void removeMovableObjectFactory(MovableObjectFactory* fact);
    00997         bool hasMovableObjectFactory(const String& typeName) const;
    00999         MovableObjectFactory* getMovableObjectFactory(const String& typeName);
    01005         uint32 _allocateNextMovableObjectTypeFlag(void);
    01006
    01007         typedef ConstMapIterator<MovableObjectFactoryMap> MovableObjectFactoryIterator;
    01011         MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
    01012
    01016         unsigned int getDisplayMonitorCount() const;
    01017
    01024         WorkQueue* getWorkQueue() const { return mWorkQueue; }
    01025
    01034         void setWorkQueue(WorkQueue* queue);
    01035
    01042         void setBlendIndicesGpuRedundant(bool redundant) {  mIsBlendIndicesGpuRedundant = redundant; }
    01046         bool isBlendIndicesGpuRedundant() const { return mIsBlendIndicesGpuRedundant; }
    01047
    01054         void setBlendWeightsGpuRedundant(bool redundant) {  mIsBlendWeightsGpuRedundant = redundant; }
    01058         bool isBlendWeightsGpuRedundant() const { return mIsBlendWeightsGpuRedundant; }
    01059
    01064         void setDefaultMinPixelSize(Real pixelSize) { mDefaultMinPixelSize = pixelSize; }
    01065
    01068         Real getDefaultMinPixelSize() { return mDefaultMinPixelSize; }
    01069
    01070
    01071     };
    01074 } // Namespace Ogre
    01075 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:23