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 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
43 #endif
44 
45 #include <exception>
46 
47 namespace Ogre
48 {
57 
71  class _OgreExport Root : public Singleton<Root>, public RootAlloc
72  {
73  // To allow update of active renderer if
74  // RenderSystem::initialise is used directly
75  friend class RenderSystem;
76  protected:
81  bool mQueuedEnd;
84 
85  // Singletons
97 
101 
102 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
103  AndroidLogListener* mAndroidLogger;
104 #endif
105 
114 
121  unsigned long mNextFrame;
125 
126  public:
129  protected:
134 
138  // stock movable factories
145 
148 
151 
153 
158 
166  void loadPlugins(const String& pluginsfile = "plugins" OGRE_BUILD_SUFFIX ".cfg");
170  void initialisePlugins();
174  void shutdownPlugins();
175 
178  void unloadPlugins();
179 
181  void oneTimePostWindowInit(void);
182 
185 
188 
191  FETT_ANY = 0,
192  FETT_STARTED = 1,
193  FETT_QUEUED = 2,
194  FETT_ENDED = 3,
195  FETT_COUNT = 4
196  };
197 
200  EventTimesQueue mEventTimes[FETT_COUNT];
201 
206  Real calculateEventTime(unsigned long now, FrameEventTimeType type);
207 
209  void populateFrameEvent(FrameEventTimeType type, FrameEvent& evtToUpdate);
210 
211  public:
212 
222  Root(const String& pluginFileName = "plugins" OGRE_BUILD_SUFFIX ".cfg",
223  const String& configFileName = "ogre.cfg",
224  const String& logFileName = "Ogre.log");
225  ~Root();
226 
232  void saveConfig(void);
233 
246  bool restoreConfig(void);
247 
264  bool showConfigDialog(void);
265 
277  void addRenderSystem(RenderSystem* newRend);
278 
285  const RenderSystemList& getAvailableRenderers(void);
286 
293  RenderSystem* getRenderSystemByName(const String& name);
294 
312  void setRenderSystem(RenderSystem* system);
313 
316  RenderSystem* getRenderSystem(void);
317 
333  RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window",
334  const String& customCapabilitiesConfig = StringUtil::BLANK);
335 
337  bool isInitialised(void) const { return mIsInitialised; }
338 
344  void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities);
345 
349  bool getRemoveRenderQueueStructuresOnClear() const { return mRemoveQueueStructuresOnClear; }
350 
354  void setRemoveRenderQueueStructuresOnClear(bool r) { mRemoveQueueStructuresOnClear = r; }
355 
361  void addSceneManagerFactory(SceneManagerFactory* fact);
362 
365  void removeSceneManagerFactory(SceneManagerFactory* fact);
366 
376  const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
377 
381  SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
382 
394  SceneManager* createSceneManager(const String& typeName,
395  const String& instanceName = StringUtil::BLANK);
396 
409  SceneManager* createSceneManager(SceneTypeMask typeMask,
410  const String& instanceName = StringUtil::BLANK);
411 
413  void destroySceneManager(SceneManager* sm);
414 
419  SceneManager* getSceneManager(const String& instanceName) const;
420 
424  bool hasSceneManager(const String& instanceName) const;
426  SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
427 
443  TextureManager* getTextureManager(void);
444 
450  MeshManager* getMeshManager(void);
451 
455  String getErrorDescription(long errorNumber);
456 
473  void addFrameListener(FrameListener* newListener);
474 
479  void removeFrameListener(FrameListener* oldListener);
480 
489  void queueEndRendering(bool state = true);
490 
497  bool endRenderingQueued(void);
498 
526  void startRendering(void);
527 
533  bool renderOneFrame(void);
534 
541  bool renderOneFrame(Real timeSinceLastFrame);
542 
550  void shutdown(void);
551 
598  void addResourceLocation(const String& name, const String& locType,
600  bool recursive = false);
601 
608  void removeResourceLocation(const String& name,
610 
632  DataStreamPtr createFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
633  bool overwrite = false, const String& locationPattern = StringUtil::BLANK);
634 
649  DataStreamPtr openFileStream(const String& filename, const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
650  const String& locationPattern = StringUtil::BLANK);
651 
660  void convertColourValue(const ColourValue& colour, uint32* pDest);
661 
670  RenderWindow* getAutoCreatedWindow(void);
671 
674  RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
675  bool fullScreen, const NameValuePairList *miscParams = 0) ;
676 
679  bool createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions,
680  RenderWindowList& createdWindows);
681 
687  RenderTarget* detachRenderTarget( RenderTarget* pWin );
688 
694  RenderTarget* detachRenderTarget( const String & name );
695 
698  void destroyRenderTarget(RenderTarget* target);
699 
702  void destroyRenderTarget(const String &name);
703 
706  RenderTarget * getRenderTarget(const String &name);
707 
718  void loadPlugin(const String& pluginName);
719 
729  void unloadPlugin(const String& pluginName);
730 
741  void installPlugin(Plugin* plugin);
742 
751  void uninstallPlugin(Plugin* plugin);
752 
754  const PluginInstanceList& getInstalledPlugins() const { return mPlugins; }
755 
757  Timer* getTimer(void);
758 
778  bool _fireFrameStarted(FrameEvent& evt);
788  bool _fireFrameRenderingQueued(FrameEvent& evt);
789 
806  bool _fireFrameEnded(FrameEvent& evt);
824  bool _fireFrameStarted();
835  bool _fireFrameRenderingQueued();
850  bool _fireFrameEnded();
851 
860  unsigned long getNextFrameNumber(void) const { return mNextFrame; }
861 
867  SceneManager* _getCurrentSceneManager(void) const;
872  void _pushCurrentSceneManager(SceneManager* sm);
877  void _popCurrentSceneManager(SceneManager* sm);
878 
889  bool _updateAllRenderTargets(void);
890 
902  bool _updateAllRenderTargets(FrameEvent& evt);
903 
908  RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
909  const String& name);
910 
914  RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
915  const String& name);
916 
922  void destroyRenderQueueInvocationSequence(
923  const String& name);
924 
929  void destroyAllRenderQueueInvocationSequences(void);
930 
946  static Root& getSingleton(void);
962  static Root* getSingletonPtr(void);
963 
972  void clearEventTimes(void);
973 
986  void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
988  Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
989 
1002  void addMovableObjectFactory(MovableObjectFactory* fact,
1003  bool overrideExisting = false);
1011  void removeMovableObjectFactory(MovableObjectFactory* fact);
1013  bool hasMovableObjectFactory(const String& typeName) const;
1015  MovableObjectFactory* getMovableObjectFactory(const String& typeName);
1021  uint32 _allocateNextMovableObjectTypeFlag(void);
1022 
1027  MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
1028 
1032  unsigned int getDisplayMonitorCount() const;
1033 
1040  WorkQueue* getWorkQueue() const { return mWorkQueue; }
1041 
1050  void setWorkQueue(WorkQueue* queue);
1051 
1058  void setBlendIndicesGpuRedundant(bool redundant) { mIsBlendIndicesGpuRedundant = redundant; }
1062  bool isBlendIndicesGpuRedundant() const { return mIsBlendIndicesGpuRedundant; }
1063 
1070  void setBlendWeightsGpuRedundant(bool redundant) { mIsBlendWeightsGpuRedundant = redundant; }
1074  bool isBlendWeightsGpuRedundant() const { return mIsBlendWeightsGpuRedundant; }
1075 
1080  void setDefaultMinPixelSize(Real pixelSize) { mDefaultMinPixelSize = pixelSize; }
1081 
1084  Real getDefaultMinPixelSize() { return mDefaultMinPixelSize; }
1085 
1086 
1087  };
1090 } // Namespace Ogre
1091 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 23 2013 06:57:25