OGRE  2.0
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-2014 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 
35 
36 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
38 #endif
39 
40 #include <exception>
41 
42 namespace Ogre
43 {
51  class FrameStats;
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;
80 
81  // Singletons
94 
98 
99 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
100  AndroidLogListener* mAndroidLogger;
101 #endif
102 
109 
117  unsigned long mNextFrame;
122 
123  public:
126  protected:
131 
135  // stock movable factories
142 
145 
148 
150 
155 
163  void loadPlugins(const String& pluginsfile = "plugins" OGRE_BUILD_SUFFIX ".cfg");
167  void initialisePlugins();
171  void shutdownPlugins();
172 
175  void unloadPlugins();
176 
178  void oneTimePostWindowInit(void);
179 
182 
186  void _syncAddedRemovedFrameListeners();
187 
190  FETT_ANY = 0,
191  FETT_STARTED = 1,
192  FETT_QUEUED = 2,
193  FETT_ENDED = 3,
194  FETT_COUNT = 4
195  };
196 
199  EventTimesQueue mEventTimes[FETT_COUNT];
200 
205  Real calculateEventTime(unsigned long now, FrameEventTimeType type);
206 
208  void populateFrameEvent(FrameEventTimeType type, FrameEvent& evtToUpdate);
209 
210  public:
211 
221  Root(const String& pluginFileName = "plugins" OGRE_BUILD_SUFFIX ".cfg",
222  const String& configFileName = "ogre.cfg",
223  const String& logFileName = "Ogre.log");
224  ~Root();
225 
231  void saveConfig(void);
232 
245  bool restoreConfig(void);
246 
263  bool showConfigDialog(void);
264 
276  void addRenderSystem(RenderSystem* newRend);
277 
284  const RenderSystemList& getAvailableRenderers(void);
285 
292  RenderSystem* getRenderSystemByName(const String& name);
293 
311  void setRenderSystem(RenderSystem* system);
312 
315  RenderSystem* getRenderSystem(void);
316 
317  CompositorManager2* getCompositorManager2() const { return mCompositorManager2; }
318 
334  RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
335  const String& customCapabilitiesConfig = BLANKSTRING);
336 
338  bool isInitialised(void) const { return mIsInitialised; }
339 
345  void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities);
346 
350  bool getRemoveRenderQueueStructuresOnClear() const { return mRemoveQueueStructuresOnClear; }
351 
355  void setRemoveRenderQueueStructuresOnClear(bool r) { mRemoveQueueStructuresOnClear = r; }
356 
362  void addSceneManagerFactory(SceneManagerFactory* fact);
363 
366  void removeSceneManagerFactory(SceneManagerFactory* fact);
367 
377  const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
378 
382  SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
383 
405  SceneManager* createSceneManager(const String& typeName, size_t numWorkerThreads,
406  InstancingTheadedCullingMethod threadedCullingMethod,
407  const String& instanceName = BLANKSTRING);
408 
431  SceneManager* createSceneManager(SceneTypeMask typeMask, size_t numWorkerThreads,
432  InstancingTheadedCullingMethod threadedCullingMethod,
433  const String& instanceName = BLANKSTRING);
434 
436  void destroySceneManager(SceneManager* sm);
437 
442  SceneManager* getSceneManager(const String& instanceName) const;
443 
447  bool hasSceneManager(const String& instanceName) const;
449  SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
450 
466  TextureManager* getTextureManager(void);
467 
473  MeshManager* getMeshManager(void);
474 
478  String getErrorDescription(long errorNumber);
479 
496  void addFrameListener(FrameListener* newListener);
497 
502  void removeFrameListener(FrameListener* oldListener);
503 
512  void queueEndRendering(bool state = true);
513 
520  bool endRenderingQueued(void);
521 
522  const FrameStats* getFrameStats(void) const { return mFrameStats; }
523 
551  void startRendering(void);
552 
558  bool renderOneFrame(void);
559 
566  bool renderOneFrame(Real timeSinceLastFrame);
567 
575  void shutdown(void);
576 
623  void addResourceLocation(const String& name, const String& locType,
625  bool recursive = false);
626 
633  void removeResourceLocation(const String& name,
635 
657  DataStreamPtr createFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
658  bool overwrite = false, const String& locationPattern = BLANKSTRING);
659 
674  DataStreamPtr openFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
675  const String& locationPattern = BLANKSTRING);
676 
685  void convertColourValue(const ColourValue& colour, uint32* pDest);
686 
695  RenderWindow* getAutoCreatedWindow(void);
696 
699  RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
700  bool fullScreen, const NameValuePairList *miscParams = 0) ;
701 
704  bool createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions,
705  RenderWindowList& createdWindows);
706 
712  RenderTarget* detachRenderTarget( RenderTarget* pWin );
713 
719  RenderTarget* detachRenderTarget( const String & name );
720 
723  void destroyRenderTarget(RenderTarget* target);
724 
727  void destroyRenderTarget(const String &name);
728 
731  RenderTarget * getRenderTarget(const String &name);
732 
743  void loadPlugin(const String& pluginName);
744 
754  void unloadPlugin(const String& pluginName);
755 
766  void installPlugin(Plugin* plugin);
767 
776  void uninstallPlugin(Plugin* plugin);
777 
779  const PluginInstanceList& getInstalledPlugins() const { return mPlugins; }
780 
782  Timer* getTimer(void);
783 
803  bool _fireFrameStarted(FrameEvent& evt);
813  bool _fireFrameRenderingQueued(FrameEvent& evt);
814 
831  bool _fireFrameEnded(FrameEvent& evt);
849  bool _fireFrameStarted();
860  bool _fireFrameRenderingQueued();
875  bool _fireFrameEnded();
876 
885  unsigned long getNextFrameNumber(void) const { return mNextFrame; }
886 
892  SceneManager* _getCurrentSceneManager(void) const;
897  void _pushCurrentSceneManager(SceneManager* sm);
902  void _popCurrentSceneManager(SceneManager* sm);
903 
914  bool _updateAllRenderTargets(void);
915 
927  bool _updateAllRenderTargets(FrameEvent& evt);
928 
933  RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
934  const String& name);
935 
939  RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
940  const String& name);
941 
947  void destroyRenderQueueInvocationSequence(
948  const String& name);
949 
954  void destroyAllRenderQueueInvocationSequences(void);
955 
971  static Root& getSingleton(void);
987  static Root* getSingletonPtr(void);
988 
997  void clearEventTimes(void);
998 
1011  void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
1013  Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
1014 
1027  void addMovableObjectFactory(MovableObjectFactory* fact,
1028  bool overrideExisting = false);
1036  void removeMovableObjectFactory(MovableObjectFactory* fact);
1038  bool hasMovableObjectFactory(const String& typeName) const;
1040  MovableObjectFactory* getMovableObjectFactory(const String& typeName);
1041 
1046  MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
1047 
1051  unsigned int getDisplayMonitorCount() const;
1052 
1059  WorkQueue* getWorkQueue() const { return mWorkQueue; }
1060 
1069  void setWorkQueue(WorkQueue* queue);
1070 
1077  void setBlendIndicesGpuRedundant(bool redundant) { mIsBlendIndicesGpuRedundant = redundant; }
1081  bool isBlendIndicesGpuRedundant() const { return mIsBlendIndicesGpuRedundant; }
1082 
1089  void setBlendWeightsGpuRedundant(bool redundant) { mIsBlendWeightsGpuRedundant = redundant; }
1093  bool isBlendWeightsGpuRedundant() const { return mIsBlendWeightsGpuRedundant; }
1094 
1099  void setDefaultMinPixelSize(Real pixelSize) { mDefaultMinPixelSize = pixelSize; }
1100 
1103  Real getDefaultMinPixelSize() { return mDefaultMinPixelSize; }
1104 
1110  void setFreqUpdatedBuffersUploadOption(HardwareBuffer::UploadOptions uploadOp) { mFreqUpdatedBuffersUploadOption = uploadOp; }
1115  HardwareBuffer::UploadOptions getFreqUpdatedBuffersUploadOption() const { return mFreqUpdatedBuffersUploadOption; }
1116 
1117  };
1120 } // Namespace Ogre
1121 #endif
Manages the target rendering window.
PluginLibList mPluginLibs
List of plugin DLLs loaded.
Definition: OgreRoot.h:128
map< String, RenderQueueInvocationSequence * >::type RenderQueueInvocationSequenceMap
Definition: OgreRoot.h:143
A 'canvas' which can receive the results of a rendering operation.
void setFreqUpdatedBuffersUploadOption(HardwareBuffer::UploadOptions uploadOp)
Set the default upload option for buffers that frequently changed Setting upload option to HBU_ON_DEM...
Definition: OgreRoot.h:1110
ParticleSystemManager * mParticleManager
Definition: OgreRoot.h:91
Profiler * mProfiler
Definition: OgreRoot.h:113
float Real
Software floating point type.
unsigned long mNextFrame
Definition: OgreRoot.h:117
OldSkeletonManager * mOldSkeletonManager
Definition: OgreRoot.h:92
unsigned int uint32
Definition: OgrePlatform.h:420
MovableObjectFactory * mRibbonTrailFactory
Definition: OgreRoot.h:141
The root class of the Ogre system.
Definition: OgreRoot.h:67
#define _OgreExport
Definition: OgrePlatform.h:255
set< FrameListener * >::type mRemovedFrameListeners
Set of frame listeners marked for removal and addition.
Definition: OgreRoot.h:184
MovableObjectFactory * mLightFactory
Definition: OgreRoot.h:137
bool mIsBlendIndicesGpuRedundant
Tells whether blend indices information needs to be passed to the GPU.
Definition: OgreRoot.h:152
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
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:779
const FrameStats * getFrameStats(void) const
Definition: OgreRoot.h:522
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:1099
map< String, MovableObjectFactory * >::type MovableObjectFactoryMap
Definition: OgreRoot.h:132
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:1013
LodStrategyManager * mLodStrategyManager
Definition: OgreRoot.h:108
deque< unsigned long >::type EventTimesQueue
Contains the times of recently fired events.
Definition: OgreRoot.h:198
Manages the organisation and rendering of a 'scene' i.e.
vector< RenderSystem * >::type RenderSystemList
Definition: OgreRoot.h:51
static String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
set< FrameListener * >::type mFrameListeners
Set of registered frame listeners.
Definition: OgreRoot.h:181
InstancingTheadedCullingMethod
There are two Instancing techniques that perform culling of their own: HW Basic HW VTF Frustum cullin...
vector< Plugin * >::type PluginInstanceList
Definition: OgreRoot.h:125
RenderSystem * mActiveRenderer
Definition: OgreRoot.h:74
WorkQueue * mWorkQueue
Definition: OgreRoot.h:149
ResourceBackgroundQueue * mResourceBackgroundQueue
Definition: OgreRoot.h:104
void setBlendIndicesGpuRedundant(bool redundant)
Sets whether blend indices information needs to be passed to the GPU.
Definition: OgreRoot.h:1077
RenderSystemCapabilitiesManager * mRenderSystemCapabilitiesManager
Definition: OgreRoot.h:106
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:111
HighLevelGpuProgramManager * mHighLevelGpuProgramManager
Definition: OgreRoot.h:114
uint32 mNextMovableObjectTypeFlag
Definition: OgreRoot.h:134
Manager for LOD strategies.
Manager for Dynamic-loading Libraries.
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
RenderSystemList mRenderers
Definition: OgreRoot.h:73
ExternalTextureSourceManager * mExternalTextureSourceManager
Definition: OgreRoot.h:115
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.
vector< RenderWindow * >::type RenderWindowList
Render window container.
Definition: OgreCommon.h:794
bool mFirstTimePostWindowInit
In case multiple render windows are created, only once are the resources loaded.
Definition: OgreRoot.h:79
The profiler allows you to measure the performance of your code.
Definition: OgreProfiler.h:279
MovableObjectFactory * mBillboardSetFactory
Definition: OgreRoot.h:138
SkeletonManager * mSkeletonManager
Definition: OgreRoot.h:93
ScriptCompilerManager * mCompilerManager
Definition: OgreRoot.h:107
Timer class.
All return values are either in milliseconds or frames per second; but they're internally stored in m...
This class manages the available ArchiveFactory plugins.
DynLibManager * mDynLibManager
Definition: OgreRoot.h:87
MovableObjectFactoryMap mMovableObjectFactoryMap
Definition: OgreRoot.h:133
SceneManagerStack mSceneManagerStack
Definition: OgreRoot.h:86
ConstMapIterator< MovableObjectFactoryMap > MovableObjectFactoryIterator
Definition: OgreRoot.h:1042
Class defining a generic OGRE plugin.
Definition: OgrePlugin.h:79
PluginInstanceList mPlugins
List of Plugin instances registered.
Definition: OgreRoot.h:130
ResourceGroupManager * mResourceGroupManager
Definition: OgreRoot.h:103
MovableObjectFactory * mManualObjectFactory
Definition: OgreRoot.h:139
vector< DynLib * >::type PluginLibList
Definition: OgreRoot.h:124
Concrete IteratorWrapper for const access to the underlying container.
Handles the management of skeleton resources.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ArchiveFactory * mEmbeddedZipArchiveFactory
Definition: OgreRoot.h:96
A interface class defining a listener which can be used to receive notifications of frame events...
RenderWindow * mAutoWindow
Definition: OgreRoot.h:112
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:1011
Real getDefaultMinPixelSize()
Get the default minimum pixel size for object to be rendered by.
Definition: OgreRoot.h:1103
UploadOptions
Device load options The following enum is used to controls how data is loaded to devices in a multi d...
ArchiveFactory * mZipArchiveFactory
Definition: OgreRoot.h:95
void setBlendWeightsGpuRedundant(bool redundant)
Sets whether blend weights information needs to be passed to the GPU.
Definition: OgreRoot.h:1089
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...
#define OGRE_BUILD_SUFFIX
Definition: OgrePlatform.h:359
RenderQueueInvocationSequenceMap mRQSequenceMap
Definition: OgreRoot.h:144
CompositorManager2 * mCompositorManager2
Definition: OgreRoot.h:116
String mVersion
Definition: OgreRoot.h:75
uint16 SceneTypeMask
Bitmask containing scene types.
ShadowTextureManager * mShadowTextureManager
Definition: OgreRoot.h:105
MovableObjectFactory * mEntityFactory
Definition: OgreRoot.h:136
void setRemoveRenderQueueStructuresOnClear(bool r)
Set whether the entire render queue structure should be emptied on clearing, or whether just the obje...
Definition: OgreRoot.h:355
This class is used to perform Resource operations in a background thread.
set< FrameListener * >::type mAddedFrameListeners
Definition: OgreRoot.h:185
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:1081
Handles the management of mesh resources.
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:154
bool getRemoveRenderQueueStructuresOnClear() const
Get whether the entire render queue structure should be emptied on clearing, or whether just the obje...
Definition: OgreRoot.h:350
singleton class for storing the capabilities of the graphics card.
Enumerates the SceneManager classes available to applications.
_StringBase String
Definition: OgreCommon.h:53
deque< SceneManager * >::type SceneManagerStack
Definition: OgreRoot.h:85
Real mFrameSmoothingTime
Definition: OgreRoot.h:118
HardwareBuffer::UploadOptions mFreqUpdatedBuffersUploadOption
Definition: OgreRoot.h:121
vector< RenderWindowDescription >::type RenderWindowDescriptionList
Render window creation parameters container.
Definition: OgreCommon.h:791
MeshManager * mMeshManager
Definition: OgreRoot.h:90
bool isInitialised(void) const
Returns whether the system is initialised or not.
Definition: OgreRoot.h:338
ArchiveFactory * mFileSystemArchiveFactory
Definition: OgreRoot.h:97
HardwareBuffer::UploadOptions getFreqUpdatedBuffersUploadOption() const
Get the default upload option for buffers that frequently changed.
Definition: OgreRoot.h:1115
bool isBlendWeightsGpuRedundant() const
Returns whether blend weights information needs to be passed to the GPU see setBlendWeightsGpuRedunda...
Definition: OgreRoot.h:1093
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:71
Defines the functionality of a 3D API.
WorkQueue * getWorkQueue() const
Get the WorkQueue for processing background tasks.
Definition: OgreRoot.h:1059
Structure containing information about a scene manager.
Main system for managing Render Targets through the use of nodes.
CompositorManager2 * getCompositorManager2() const
Definition: OgreRoot.h:317
String mConfigFileName
Definition: OgreRoot.h:76
FrameStats * mFrameStats
Definition: OgreRoot.h:110
unsigned long getNextFrameNumber(void) const
Gets the number of the next frame to be rendered.
Definition: OgreRoot.h:885
Real mDefaultMinPixelSize
Definition: OgreRoot.h:120
Class which will create instances of a given SceneManager.
bool mIsInitialised
Are we initialised yet?
Definition: OgreRoot.h:147
SceneManagerEnumerator * mSceneManagerEnum
Definition: OgreRoot.h:84
MovableObjectFactory * mBillboardChainFactory
Definition: OgreRoot.h:140
FrameEventTimeType
Indicates the type of event to be considered by calculateEventTime().
Definition: OgreRoot.h:189
bool mRemoveQueueStructuresOnClear
Definition: OgreRoot.h:119
Class for managing Controller instances.