OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreRoot.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __ROOT__
29 #define __ROOT__
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreSingleton.h"
35 #include "OgreString.h"
38 #include "OgreLodStrategyManager.h"
39 #include "OgreWorkQueue.h"
40 
41 #include <exception>
42 
43 namespace Ogre
44 {
53 
67  class _OgreExport Root : public Singleton<Root>, public RootAlloc
68  {
69  // To allow update of active renderer if
70  // RenderSystem::initialise is used directly
71  friend class RenderSystem;
72  protected:
77  bool mQueuedEnd;
78  // In case multiple render windows are created, only once are the resources loaded.
80 
81  // Singletons
107 
114  unsigned long mNextFrame;
118 
119  public:
122  protected:
127 
131  // stock movable factories
138 
141 
144 
146 
151 
158  void loadPlugins( const String& pluginsfile = "plugins.cfg" );
162  void initialisePlugins();
166  void shutdownPlugins();
167 
170  void unloadPlugins();
171 
172  // Internal method for one-time tasks after first window creation
173  void oneTimePostWindowInit(void);
174 
177 
180 
183  FETT_ANY = 0,
184  FETT_STARTED = 1,
185  FETT_QUEUED = 2,
186  FETT_ENDED = 3,
187  FETT_COUNT = 4
188  };
189 
192  EventTimesQueue mEventTimes[FETT_COUNT];
193 
198  Real calculateEventTime(unsigned long now, FrameEventTimeType type);
199 
201  void populateFrameEvent(FrameEventTimeType type, FrameEvent& evtToUpdate);
202 
203  public:
204 
213  Root(const String& pluginFileName = "plugins.cfg",
214  const String& configFileName = "ogre.cfg",
215  const String& logFileName = "Ogre.log");
216  ~Root();
217 
223  void saveConfig(void);
224 
237  bool restoreConfig(void);
238 
255  bool showConfigDialog(void);
256 
268  void addRenderSystem(RenderSystem* newRend);
269 
276  const RenderSystemList& getAvailableRenderers(void);
277 
284  RenderSystem* getRenderSystemByName(const String& name);
285 
303  void setRenderSystem(RenderSystem* system);
304 
307  RenderSystem* getRenderSystem(void);
308 
324  RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
325  const String& customCapabilitiesConfig = StringUtil::BLANK);
326 
328  bool isInitialised(void) const { return mIsInitialised; }
329 
335  void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities);
336 
340  bool getRemoveRenderQueueStructuresOnClear() const { return mRemoveQueueStructuresOnClear; }
341 
345  void setRemoveRenderQueueStructuresOnClear(bool r) { mRemoveQueueStructuresOnClear = r; }
346 
352  void addSceneManagerFactory(SceneManagerFactory* fact);
353 
356  void removeSceneManagerFactory(SceneManagerFactory* fact);
357 
367  const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
368 
372  SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
373 
385  SceneManager* createSceneManager(const String& typeName,
386  const String& instanceName = StringUtil::BLANK);
387 
400  SceneManager* createSceneManager(SceneTypeMask typeMask,
401  const String& instanceName = StringUtil::BLANK);
402 
404  void destroySceneManager(SceneManager* sm);
405 
410  SceneManager* getSceneManager(const String& instanceName) const;
411 
415  bool hasSceneManager(const String& instanceName) const;
417  SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
418 
434  TextureManager* getTextureManager(void);
435 
441  MeshManager* getMeshManager(void);
442 
446  String getErrorDescription(long errorNumber);
447 
464  void addFrameListener(FrameListener* newListener);
465 
470  void removeFrameListener(FrameListener* oldListener);
471 
480  void queueEndRendering(void);
481 
509  void startRendering(void);
510 
516  bool renderOneFrame(void);
517 
524  bool renderOneFrame(Real timeSinceLastFrame);
525 
533  void shutdown(void);
534 
581  void addResourceLocation(const String& name, const String& locType,
583  bool recursive = false);
584 
591  void removeResourceLocation(const String& name,
593 
615  DataStreamPtr createFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
616  bool overwrite = false, const String& locationPattern = StringUtil::BLANK);
617 
632  DataStreamPtr openFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
633  const String& locationPattern = StringUtil::BLANK);
634 
643  void convertColourValue(const ColourValue& colour, uint32* pDest);
644 
653  RenderWindow* getAutoCreatedWindow(void);
654 
657  RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
658  bool fullScreen, const NameValuePairList *miscParams = 0) ;
659 
662  bool createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions,
663  RenderWindowList& createdWindows);
664 
670  RenderTarget* detachRenderTarget( RenderTarget* pWin );
671 
677  RenderTarget* detachRenderTarget( const String & name );
678 
681  void destroyRenderTarget(RenderTarget* target);
682 
685  void destroyRenderTarget(const String &name);
686 
689  RenderTarget * getRenderTarget(const String &name);
690 
701  void loadPlugin(const String& pluginName);
702 
712  void unloadPlugin(const String& pluginName);
713 
724  void installPlugin(Plugin* plugin);
725 
734  void uninstallPlugin(Plugin* plugin);
735 
737  const PluginInstanceList& getInstalledPlugins() const { return mPlugins; }
738 
740  Timer* getTimer(void);
741 
761  bool _fireFrameStarted(FrameEvent& evt);
771  bool _fireFrameRenderingQueued(FrameEvent& evt);
772 
789  bool _fireFrameEnded(FrameEvent& evt);
807  bool _fireFrameStarted();
818  bool _fireFrameRenderingQueued();
833  bool _fireFrameEnded();
834 
843  unsigned long getNextFrameNumber(void) const { return mNextFrame; }
844 
850  SceneManager* _getCurrentSceneManager(void) const;
855  void _pushCurrentSceneManager(SceneManager* sm);
860  void _popCurrentSceneManager(SceneManager* sm);
861 
872  bool _updateAllRenderTargets(void);
873 
885  bool _updateAllRenderTargets(FrameEvent& evt);
886 
891  RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
892  const String& name);
893 
897  RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
898  const String& name);
899 
905  void destroyRenderQueueInvocationSequence(
906  const String& name);
907 
913  void destroyAllRenderQueueInvocationSequences(void);
914 
930  static Root& getSingleton(void);
946  static Root* getSingletonPtr(void);
947 
956  void clearEventTimes(void);
957 
970  void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
972  Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
973 
986  void addMovableObjectFactory(MovableObjectFactory* fact,
987  bool overrideExisting = false);
995  void removeMovableObjectFactory(MovableObjectFactory* fact);
997  bool hasMovableObjectFactory(const String& typeName) const;
999  MovableObjectFactory* getMovableObjectFactory(const String& typeName);
1005  uint32 _allocateNextMovableObjectTypeFlag(void);
1006 
1011  MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
1012 
1016  unsigned int getDisplayMonitorCount() const;
1017 
1024  WorkQueue* getWorkQueue() const { return mWorkQueue; }
1025 
1034  void setWorkQueue(WorkQueue* queue);
1035 
1042  void setBlendIndicesGpuRedundant(bool redundant) { mIsBlendIndicesGpuRedundant = redundant; }
1046  bool isBlendIndicesGpuRedundant() const { return mIsBlendIndicesGpuRedundant; }
1047 
1054  void setBlendWeightsGpuRedundant(bool redundant) { mIsBlendWeightsGpuRedundant = redundant; }
1058  bool isBlendWeightsGpuRedundant() const { return mIsBlendWeightsGpuRedundant; }
1059 
1064  void setDefaultMinPixelSize(Real pixelSize) { mDefaultMinPixelSize = pixelSize; }
1065 
1068  Real getDefaultMinPixelSize() { return mDefaultMinPixelSize; }
1069 
1070 
1071  };
1074 } // Namespace Ogre
1075 #endif
Manages the target rendering window.
PluginLibList mPluginLibs
List of plugin DLLs loaded.
Definition: OgreRoot.h:124
map< String, RenderQueueInvocationSequence * >::type RenderQueueInvocationSequenceMap
Definition: OgreRoot.h:139
A 'canvas' which can receive the results of a rendering operation.
ParticleSystemManager * mParticleManager
Definition: OgreRoot.h:91
Profiler * mProfiler
Definition: OgreRoot.h:110
float Real
Software floating point type.
unsigned long mNextFrame
Definition: OgreRoot.h:114
unsigned int uint32
Definition: OgrePlatform.h:270
MovableObjectFactory * mRibbonTrailFactory
Definition: OgreRoot.h:137
The root class of the Ogre system.
Definition: OgreRoot.h:67
#define _OgreExport
Definition: OgrePlatform.h:233
set< FrameListener * >::type mRemovedFrameListeners
Set of frame listeners marked for removal.
Definition: OgreRoot.h:179
MovableObjectFactory * mLightFactory
Definition: OgreRoot.h:133
CompositorManager * mCompositorManager
Definition: OgreRoot.h:113
bool mIsBlendIndicesGpuRedundant
Tells whether blend indices information needs to be passed to the GPU.
Definition: OgreRoot.h:148
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:553
Singleton Class which handles the registering and control of texture plugins.
const PluginInstanceList & getInstalledPlugins() const
Gets a read-only list of the currently installed plugins.
Definition: OgreRoot.h:737
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Class for loading & managing textures.
void setDefaultMinPixelSize(Real pixelSize)
Set the default minimum pixel size for object to be rendered by.
Definition: OgreRoot.h:1064
map< String, MovableObjectFactory * >::type MovableObjectFactoryMap
Definition: OgreRoot.h:128
LogManager * mLogManager
Definition: OgreRoot.h:82
Class representing colour.
Real getFrameSmoothingPeriod(void) const
Gets the period over which OGRE smooths out fluctuations in frame times.
Definition: OgreRoot.h:972
LodStrategyManager * mLodStrategyManager
Definition: OgreRoot.h:106
deque< unsigned long >::type EventTimesQueue
Contains the times of recently fired events.
Definition: OgreRoot.h:191
Manages the organisation and rendering of a 'scene' i.e.
OverlayElementFactory * mTextAreaFactory
Definition: OgreRoot.h:95
Defines the interface which all components wishing to supply OverlayElement subclasses must implement...
vector< RenderSystem * >::type RenderSystemList
Definition: OgreRoot.h:52
set< FrameListener * >::type mFrameListeners
Set of registered frame listeners.
Definition: OgreRoot.h:176
vector< Plugin * >::type PluginInstanceList
Definition: OgreRoot.h:121
RenderSystem * mActiveRenderer
Definition: OgreRoot.h:74
WorkQueue * mWorkQueue
Definition: OgreRoot.h:145
ResourceBackgroundQueue * mResourceBackgroundQueue
Definition: OgreRoot.h:102
void setBlendIndicesGpuRedundant(bool redundant)
Sets whether blend indices information needs to be passed to the GPU.
Definition: OgreRoot.h:1042
RenderSystemCapabilitiesManager * mRenderSystemCapabilitiesManager
Definition: OgreRoot.h:104
Class for managing RenderSystemCapabilities database for Ogre.
This ResourceManager manages high-level vertex and fragment programs.
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
Class to manage the available shadow textures which may be shared between many SceneManager instances...
Timer * mTimer
Definition: OgreRoot.h:108
HighLevelGpuProgramManager * mHighLevelGpuProgramManager
Definition: OgreRoot.h:111
uint32 mNextMovableObjectTypeFlag
Definition: OgreRoot.h:130
Manager for lod strategies.
Manager for Dynamic-loading Libraries.
RenderSystemList mRenderers
Definition: OgreRoot.h:73
ExternalTextureSourceManager * mExternalTextureSourceManager
Definition: OgreRoot.h:112
std::set< T, P, A > type
The log manager handles the creation and retrieval of logs for the application.
Concrete IteratorWrapper for nonconst access to the underlying key-value container.
Class to hold a linear sequence of RenderQueueInvocation objects.
Class for managing Material settings for Ogre.
Manages Overlay objects, parsing them from .overlay files and storing a lookup library of them...
vector< RenderWindow * >::type RenderWindowList
Render window container.
Definition: OgreCommon.h:767
bool mFirstTimePostWindowInit
Definition: OgreRoot.h:79
Manages Font resources, parsing .fontdef files and generally organising them.
OverlayElementFactory * mPanelFactory
Definition: OgreRoot.h:93
The profiler allows you to measure the performance of your code.
Definition: OgreProfiler.h:134
MovableObjectFactory * mBillboardSetFactory
Definition: OgreRoot.h:134
SkeletonManager * mSkeletonManager
Definition: OgreRoot.h:92
ScriptCompilerManager * mCompilerManager
Definition: OgreRoot.h:105
Timer class.
This class manages the available ArchiveFactory plugins.
DynLibManager * mDynLibManager
Definition: OgreRoot.h:87
MovableObjectFactoryMap mMovableObjectFactoryMap
Definition: OgreRoot.h:129
SceneManagerStack mSceneManagerStack
Definition: OgreRoot.h:86
ConstMapIterator< MovableObjectFactoryMap > MovableObjectFactoryIterator
Definition: OgreRoot.h:1007
static OGRE_AUTO_MUTEX String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
Class defining a generic OGRE plugin.
Definition: OgrePlugin.h:79
PluginInstanceList mPlugins
List of Plugin instances registered.
Definition: OgreRoot.h:126
ResourceGroupManager * mResourceGroupManager
Definition: OgreRoot.h:101
MovableObjectFactory * mManualObjectFactory
Definition: OgreRoot.h:135
vector< DynLib * >::type PluginLibList
Definition: OgreRoot.h:120
Concrete IteratorWrapper for const access to the underlying container.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ArchiveFactory * mEmbeddedZipArchiveFactory
Definition: OgreRoot.h:99
A interface class defining a listener which can be used to receive notifications of frame events...
RenderWindow * mAutoWindow
Definition: OgreRoot.h:109
MaterialManager * mMaterialManager
Definition: OgreRoot.h:89
Manages threaded compilation of scripts.
void setFrameSmoothingPeriod(Real period)
Sets the period over which OGRE smooths out fluctuations in frame times.
Definition: OgreRoot.h:970
Real getDefaultMinPixelSize()
Get the default minimum pixel size for object to be rendered by.
Definition: OgreRoot.h:1068
ArchiveFactory * mZipArchiveFactory
Definition: OgreRoot.h:98
void setBlendWeightsGpuRedundant(bool redundant)
Sets whether blend weights information needs to be passed to the GPU.
Definition: OgreRoot.h:1054
Handles the management of skeleton resources.
Manages particle systems, particle system scripts (templates) and the available emitter & affector fa...
ArchiveManager * mArchiveManager
Definition: OgreRoot.h:88
bool mQueuedEnd
Definition: OgreRoot.h:77
Abstract factory class, archive codec plugins can register concrete subclasses of this...
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
RenderQueueInvocationSequenceMap mRQSequenceMap
Definition: OgreRoot.h:140
FontManager * mFontManager
Definition: OgreRoot.h:97
String mVersion
Definition: OgreRoot.h:75
uint16 SceneTypeMask
Bitmask containing scene types.
Class for managing Compositor settings for Ogre.
ShadowTextureManager * mShadowTextureManager
Definition: OgreRoot.h:103
MovableObjectFactory * mEntityFactory
Definition: OgreRoot.h:132
void setRemoveRenderQueueStructuresOnClear(bool r)
Set whether the entire render queue structure should be emptied on clearing, or whether just the obje...
Definition: OgreRoot.h:345
This class is used to perform Resource operations in a background thread.
This singleton class manages the list of resource groups, and notifying the various resource managers...
Concrete IteratorWrapper for const access to the underlying key-value container.
bool isBlendIndicesGpuRedundant() const
Returns whether blend indices information needs to be passed to the GPU see setBlendIndicesGpuRedunda...
Definition: OgreRoot.h:1046
Handles the management of mesh resources.
OverlayManager * mOverlayManager
Definition: OgreRoot.h:96
ControllerManager * mControllerManager
Definition: OgreRoot.h:83
Struct containing information about a frame event.
bool mIsBlendWeightsGpuRedundant
Tells whether blend weights information needs to be passed to the GPU.
Definition: OgreRoot.h:150
bool getRemoveRenderQueueStructuresOnClear() const
Get whether the entire render queue structure should be emptied on clearing, or whether just the obje...
Definition: OgreRoot.h:340
singleton class for storing the capabilities of the graphics card.
Enumerates the SceneManager classes available to applications.
_StringBase String
deque< SceneManager * >::type SceneManagerStack
Definition: OgreRoot.h:85
Real mFrameSmoothingTime
Definition: OgreRoot.h:115
vector< RenderWindowDescription >::type RenderWindowDescriptionList
Render window creation parameters container.
Definition: OgreCommon.h:764
MeshManager * mMeshManager
Definition: OgreRoot.h:90
bool isInitialised(void) const
Returns whether the system is initialised or not.
Definition: OgreRoot.h:328
ArchiveFactory * mFileSystemArchiveFactory
Definition: OgreRoot.h:100
bool isBlendWeightsGpuRedundant() const
Returns whether blend weights information needs to be passed to the GPU see setBlendWeightsGpuRedunda...
Definition: OgreRoot.h:1058
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:69
Defines the functionality of a 3D API.
WorkQueue * getWorkQueue() const
Get the WorkQueue for processing background tasks.
Definition: OgreRoot.h:1024
Structure containing information about a scene manager.
String mConfigFileName
Definition: OgreRoot.h:76
OverlayElementFactory * mBorderPanelFactory
Definition: OgreRoot.h:94
unsigned long getNextFrameNumber(void) const
Gets the number of the next frame to be rendered.
Definition: OgreRoot.h:843
Real mDefaultMinPixelSize
Definition: OgreRoot.h:117
Class which will create instances of a given SceneManager.
bool mIsInitialised
Are we initialised yet?
Definition: OgreRoot.h:143
SceneManagerEnumerator * mSceneManagerEnum
Definition: OgreRoot.h:84
MovableObjectFactory * mBillboardChainFactory
Definition: OgreRoot.h:136
FrameEventTimeType
Indicates the type of event to be considered by calculateEventTime().
Definition: OgreRoot.h:182
bool mRemoveQueueStructuresOnClear
Definition: OgreRoot.h:116
Class for managing Controller instances.