source: OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgreRoot.h @ 1591

Revision 1591, 37.2 KB checked in by szirmay, 18 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __ROOT__
26#define __ROOT__
27
28// Precompiler options
29#include "OgrePrerequisites.h"
30
31#include "OgreSingleton.h"
32#include "OgreString.h"
33#include "OgreSceneManagerEnumerator.h"
34#include "OgreResourceGroupManager.h"
35
36#ifdef GAMETOOLS_ILLUMINATION_MODULE
37#include "OgreFrameListener.h"
38#endif
39
40
41#include <exception>
42
43#if OGRE_COMPILER == OGRE_COMPILER_MSVC || OGRE_COMPILER == OGRE_COMPILER_BORL
44#   define SET_TERM_HANDLER { set_terminate( &Ogre::Root::termHandler ); }
45#else
46#   define SET_TERM_HANDLER { std::set_terminate( &Ogre::Root::termHandler ); }
47#endif
48
49namespace Ogre
50{
51#ifdef GAMETOOLS_ILLUMINATION_MODULE
52        struct FrameListenerComparer
53        {
54                bool operator()(const FrameListener* s1, const FrameListener* s2) const
55                {
56                        return s1->compare(s2);
57                }
58        };
59#endif
60
61
62    typedef std::vector<RenderSystem*> RenderSystemList;
63       
64    /** The root class of the Ogre system.
65        @remarks
66            The Ogre::Root class represents a starting point for the client
67            application. From here, the application can gain access to the
68            fundamentals of the system, namely the rendering systems
69            available, management of saved configurations, logging, and
70            access to other classes in the system. Acts as a hub from which
71            all other objects may be reached. An instance of Root must be
72            created before any other Ogre operations are called. Once an
73            instance has been created, the same instance is accessible
74            throughout the life of that object by using Root::getSingleton
75            (as a reference) or Root::getSingletonPtr (as a pointer).
76    */
77    class _OgreExport Root : public Singleton<Root>
78    {
79        // To allow update of active renderer if
80        // RenderSystem::initialise is used directly
81        friend class RenderSystem;
82    private:
83        RenderSystemList mRenderers;
84        RenderSystem* mActiveRenderer;
85        String mVersion;
86                String mConfigFileName;
87            bool mQueuedEnd;
88        // In case multiple render windows are created, only once are the resources loaded.
89        bool mFirstTimePostWindowInit;
90
91        // Singletons
92        LogManager* mLogManager;
93        ControllerManager* mControllerManager;
94        SceneManagerEnumerator* mSceneManagerEnum;
95        SceneManager* mCurrentSceneManager;
96        DynLibManager* mDynLibManager;
97        PlatformManager* mPlatformManager;
98        ArchiveManager* mArchiveManager;
99        MaterialManager* mMaterialManager;
100        MeshManager* mMeshManager;
101        ParticleSystemManager* mParticleManager;
102        SkeletonManager* mSkeletonManager;
103        OverlayElementFactory* mPanelFactory;
104        OverlayElementFactory* mBorderPanelFactory;
105        OverlayElementFactory* mTextAreaFactory;
106        OverlayManager* mOverlayManager;
107        FontManager* mFontManager;
108        ArchiveFactory *mZipArchiveFactory;
109        ArchiveFactory *mFileSystemArchiveFactory;
110                ResourceGroupManager* mResourceGroupManager;
111                ResourceBackgroundQueue* mResourceBackgroundQueue;
112
113        Timer* mTimer;
114        RenderWindow* mAutoWindow;
115        Profiler* mProfiler;
116        HighLevelGpuProgramManager* mHighLevelGpuProgramManager;
117                ExternalTextureSourceManager* mExternalTextureSourceManager;
118        CompositorManager* mCompositorManager;     
119        unsigned long mCurrentFrame;
120                Real mFrameSmoothingTime;
121
122        std::vector<DynLib*> mPluginLibs;
123
124                typedef std::map<String, MovableObjectFactory*> MovableObjectFactoryMap;
125                MovableObjectFactoryMap mMovableObjectFactoryMap;
126                uint32 mNextMovableObjectTypeFlag;
127                // stock movable factories
128                MovableObjectFactory* mEntityFactory;
129                MovableObjectFactory* mLightFactory;
130                MovableObjectFactory* mBillboardSetFactory;
131                MovableObjectFactory* mManualObjectFactory;
132                MovableObjectFactory* mBillboardChainFactory;
133                MovableObjectFactory* mRibbonTrailFactory;
134
135                typedef std::map<String, RenderQueueInvocationSequence*> RenderQueueInvocationSequenceMap;
136                RenderQueueInvocationSequenceMap mRQSequenceMap;
137
138                /// Are we initialised yet?
139                bool mIsInitialised;
140
141        /** Method reads a plugins configuration file and instantiates all
142            plugins.
143            @param
144                pluginsfile The file that contains plugins information.
145                Defaults to "plugins.cfg".
146        */
147        void loadPlugins( const String& pluginsfile = "plugins.cfg" );
148                /** Initialise all loaded plugins - allows plugins to perform actions
149                        once the renderer is initialised.
150                */
151                void initialisePlugins();
152                /** Shuts down all loaded plugins - allows things to be tidied up whilst
153                        all plugins are still loaded.
154                */
155                void shutdownPlugins();
156
157                /** Unloads all loaded plugins.
158        */
159        void unloadPlugins();
160
161        // Internal method for one-time tasks after first window creation
162        void oneTimePostWindowInit(void);
163#ifdef GAMETOOLS_ILLUMINATION_MODULE   
164                std::set<FrameListener*, FrameListenerComparer> mFrameListeners;
165#else
166        /** Set of registered frame listeners */
167        std::set<FrameListener*> mFrameListeners;
168#endif
169
170        /** Set of frame listeners marked for removal*/
171        std::set<FrameListener*> mRemovedFrameListeners;
172
173        /** Indicates the type of event to be considered by calculateEventTime(). */
174        enum FrameEventTimeType {
175            FETT_ANY, FETT_STARTED, FETT_ENDED
176        };
177
178        /// Contains the times of recently fired events
179        std::deque<unsigned long> mEventTimes[3];
180
181        /** Internal method for calculating the average time between recently fired events.
182        @param now The current time in ms.
183        @param type The type of event to be considered.
184        */
185        Real calculateEventTime(unsigned long now, FrameEventTimeType type);
186    public:
187
188        static void termHandler();
189
190        /** Constructor
191            @param
192                pluginFileName The file that contains plugins information.
193                Defaults to "plugins.cfg".
194                */
195        Root(const String& pluginFileName = "plugins.cfg", const String& configFileName = "ogre.cfg", const String& logFileName = "Ogre.log");
196        ~Root();
197
198        /** Saves the details of the current configuration
199            @remarks
200                Stores details of the current configuration so it may be
201                restored later on.
202        */
203        void saveConfig(void);
204
205        /** Checks for saved video/sound/etc settings
206            @remarks
207                This method checks to see if there is a valid saved configuration
208                from a previous run. If there is, the state of the system will
209                be restored to that configuration.
210
211            @returns
212                If a valid configuration was found, <b>true</b> is returned.
213            @par
214                If there is no saved configuration, or if the system failed
215                with the last config settings, <b>false</b> is returned.
216        */
217        bool restoreConfig(void);
218
219        /** Displays a dialog asking the user to choose system settings.
220            @remarks
221                This method displays the default dialog allowing the user to
222                choose the renderering system, video mode etc. If there is are
223                any settings saved already, they will be restored automatically
224                before displaying the dialogue. When the user accepts a group of
225                settings, this will automatically call Root::setRenderSystem,
226                RenderSystem::setConfigOption and Root::saveConfig with the
227                user's choices. This is the easiest way to get the system
228                configured.
229            @returns
230                If the user clicked 'Ok', <b>true</b> is returned.
231            @par
232                If they clicked 'Cancel' (in which case the app should
233                strongly consider terminating), <b>false</b> is returned.
234         */
235        bool showConfigDialog(void);
236
237        /** Adds a new rendering subsystem to the list of available renderers.
238            @remarks
239                Intended for use by advanced users and plugin writers only!
240                Calling this method with a pointer to a valid RenderSystem
241                (sublcass) adds a rendering API implementation to the list of
242                available ones. Typical examples would be an OpenGL
243                implementation and a Direct3D implementation.
244            @note
245                <br>This should usually be called from the dllStartPlugin()
246                function of an extension plug-in.
247        */
248        void addRenderSystem(RenderSystem* newRend);
249
250        /** Retrieve a list of the available render systems.
251            @remarks
252                Retrieves a pointer to the list of available renderers as a
253                list of RenderSystem subclasses. Can be used to build a
254                custom settings dialog.
255        */
256        RenderSystemList* getAvailableRenderers(void);
257
258        /** Retrieve a pointer to the render system by the given name
259            @param
260                name Name of the render system intend to retrieve.
261            @returns
262                A pointer to the render system, <b>NULL</b> if no found.
263        */
264        RenderSystem* getRenderSystemByName(const String& name);
265
266        /** Sets the rendering subsystem to be used.
267            @remarks
268                This method indicates to OGRE which rendering system is to be
269                used (e.g. Direct3D, OpenGL etc). This is called
270                automatically by the default config dialog, and when settings
271                are restored from a previous configuraion. If used manually
272                it could be used to set the renderer from a custom settings
273                dialog. Once this has been done, the renderer can be
274                initialised using Root::initialise.
275            @par
276                This method is also called by render systems if they are
277                initialised directly.
278            @param
279                system Pointer to the render system to use.
280            @see
281                RenderSystem
282        */
283        void setRenderSystem(RenderSystem* system);
284
285        /** Retrieve a pointer to the currently selected render system.
286        */
287        RenderSystem* getRenderSystem(void);
288
289        /** Initialises the renderer.
290            @remarks
291                This method can only be called after a renderer has been
292                selected with Root::setRenderSystem, and it will initialise
293                the selected rendering system ready for use.
294            @param
295                autoCreateWindow If true, a rendering window will
296                automatically be created (saving a call to
297                RenderSystem::createRenderWindow). The window will be
298                created based on the options currently set on the render
299                system.
300            @returns
301                A pointer to the automatically created window, if
302                requested, otherwise <b>NULL</b>.
303        */
304            RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
305
306                /** Returns whether the system is initialised or not. */
307                bool isInitialised(void) const { return mIsInitialised; }
308
309                /** Register a new SceneManagerFactory, a factory object for creating instances
310                        of specific SceneManagers.
311                @remarks
312                        Plugins should call this to register as new SceneManager providers.
313                */
314                void addSceneManagerFactory(SceneManagerFactory* fact);
315
316                /** Unregister a SceneManagerFactory.
317                */
318                void removeSceneManagerFactory(SceneManagerFactory* fact);
319
320                /** Get more information about a given type of SceneManager.
321                @remarks
322                        The metadata returned tells you a few things about a given type
323                        of SceneManager, which can be created using a factory that has been
324                        registered already.
325                @param typeName The type name of the SceneManager you want to enquire on.
326                        If you don't know the typeName already, you can iterate over the
327                        metadata for all types using getMetaDataIterator.
328                */
329                const SceneManagerMetaData* getSceneManagerMetaData(const String& typeName) const;
330
331                /** Iterate over all types of SceneManager available for construction,
332                        providing some information about each one.
333                */
334                SceneManagerEnumerator::MetaDataIterator getSceneManagerMetaDataIterator(void) const;
335
336                /** Create a SceneManager instance of a given type.
337                @remarks
338                        You can use this method to create a SceneManager instance of a
339                        given specific type. You may know this type already, or you may
340                        have discovered it by looking at the results from getMetaDataIterator.
341                @note
342                        This method throws an exception if the named type is not found.
343                @param typeName String identifying a unique SceneManager type
344                @param instanceName Optional name to given the new instance that is
345                        created. If you leave this blank, an auto name will be assigned.
346                */
347                SceneManager* createSceneManager(const String& typeName,
348                        const String& instanceName = StringUtil::BLANK);
349
350                /** Create a SceneManager instance based on scene type support.
351                @remarks
352                        Creates an instance of a SceneManager which supports the scene types
353                        identified in the parameter. If more than one type of SceneManager
354                        has been registered as handling that combination of scene types,
355                        in instance of the last one registered is returned.
356                @note This method always succeeds, if a specific scene manager is not
357                        found, the default implementation is always returned.
358                @param typeMask A mask containing one or more SceneType flags
359                @param instanceName Optional name to given the new instance that is
360                        created. If you leave this blank, an auto name will be assigned.
361                */
362                SceneManager* createSceneManager(SceneTypeMask typeMask,
363                        const String& instanceName = StringUtil::BLANK);
364
365                /** Destroy an instance of a SceneManager. */
366                void destroySceneManager(SceneManager* sm);
367
368                /** Get an existing SceneManager instance that has already been created,
369                        identified by the instance name.
370                @param instanceName The name of the instance to retrieve.
371                */
372                SceneManager* getSceneManager(const String& instanceName) const;
373
374                /** Get an iterator over all the existing SceneManager instances. */
375                SceneManagerEnumerator::SceneManagerIterator getSceneManagerIterator(void);
376
377        /** Retrieves a reference to the current TextureManager.
378            @remarks
379                This performs the same function as
380                TextureManager::getSingleton, but is provided for convenience
381                particularly to scripting engines.
382            @par
383                Note that a TextureManager will NOT be available until the
384                Ogre system has been initialised by selecting a RenderSystem,
385                calling Root::initialise and a window having been created
386                (this may have been done by initialise if required). This is
387                because the exact runtime subclass which will be implementing
388                the calls will differ depending on the rendering engine
389                selected, and these typically require a window upon which to
390                base texture format decisions.
391        */
392        TextureManager* getTextureManager(void);
393
394        /** Retrieves a reference to the current MeshManager.
395            @remarks
396                This performs the same function as MeshManager::getSingleton
397                and is provided for convenience to scripting engines.
398        */
399        MeshManager* getMeshManager(void);
400
401        /** Utility function for getting a better description of an error
402            code.
403        */
404        String getErrorDescription(long errorNumber);
405
406        /** Registers a FrameListener which will be called back every frame.
407            @remarks
408                A FrameListener is a class which implements methods which
409                will be called every frame.
410            @par
411                See the FrameListener class for more details on the specifics
412                It is imperitive that the instance passed to this method is
413                not destroyed before either the rendering loop ends, or the
414                class is removed from the listening list using
415                removeFrameListener.
416            @note
417                <br>This method can only be called after Root::initialise has
418                been called.
419            @see
420                FrameListener, Root::removeFrameListener
421        */
422        void addFrameListener(FrameListener* newListener);
423
424        /** Removes a FrameListener from the list of listening classes.
425            @see
426                FrameListener, Root::addFrameListener
427        */
428        void removeFrameListener(FrameListener* oldListener);
429
430        /** Queues the end of rendering.
431            @remarks
432                This method will do nothing unless startRendering() has
433                been called, in which case before the next frame is rendered
434                the rendering loop will bail out.
435            @see
436                Root, Root::startRendering
437        */
438        void queueEndRendering(void);
439
440        /** Starts / restarts the automatic rendering cycle.
441            @remarks
442                This method begins the automatic rendering of the scene. It
443                will <b>NOT</b> return until the rendering cycle is halted.
444            @par
445                During rendering, any FrameListener classes registered using
446                addFrameListener will be called back for each frame that is
447                to be rendered, These classes can tell OGRE to halt the
448                rendering if required, which will cause this method to
449                return.
450            @note
451                <br>Users of the OGRE library do not have to use this
452                automatic rendering loop. It is there as a convenience and is
453                most useful for high frame rate applications e.g. games. For
454                applications that don't need to constantly refresh the
455                rendering targets (e.g. an editor utility), it is better to
456                manually refresh each render target only when required by
457                calling RenderTarget::update.
458            @note
459                This frees up the CPU to do other things in between
460                refreshes, since in this case frame rate is less important.
461            @note
462                This method can only be called after Root::initialise has
463                been called.
464        */
465        void startRendering(void);
466
467        /** Render one frame.
468        @remarks
469            Updates all the render targets automatically and then returns,
470            raising frame events before and after.
471        */
472        bool renderOneFrame(void);
473        /** Shuts down the system manually.
474            @remarks
475                This is normally done by Ogre automatically so don't think
476                you have to call this yourself. However this is here for
477                convenience, especially for dealing with unexpected errors or
478                for systems which need to shut down Ogre on demand.
479        */
480        void shutdown(void);
481
482        /** Adds a location to the list of searchable locations for a
483            Resource type.
484            @remarks
485                Resource files (textures, models etc) need to be loaded from
486                specific locations. By calling this method, you add another
487                                search location to the list. Locations added first are preferred
488                                over locations added later.
489            @par
490                Locations can be folders, compressed archives, even perhaps
491                remote locations. Facilities for loading from different
492                locations are provided by plugins which provide
493                implementations of the Archive class.
494                All the application user has to do is specify a 'loctype'
495                string in order to indicate the type of location, which
496                should map onto one of the provided plugins. Ogre comes
497                configured with the 'FileSystem' (folders) and 'Zip' (archive
498                compressed with the pkzip / WinZip etc utilities) types.
499            @par
500                                You can also supply the name of a resource group which should
501                                have this location applied to it. The
502                                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME group is the
503                                default, and one resource group which will always exist. You
504                                should consider defining resource groups for your more specific
505                                resources (e.g. per level) so that you can control loading /
506                                unloading better.
507            @param
508                name The name of the location, e.g. './data' or
509                '/compressed/gamedata.zip'
510            @param
511                locType A string identifying the location type, e.g.
512                'FileSystem' (for folders), 'Zip' etc. Must map to a
513                registered plugin which deals with this type (FileSystem and
514                Zip should always be available)
515            @param
516                groupName Type of name of the resource group which this location
517                                should apply to; defaults to the General group which applies to
518                                all non-specific resources.
519                        @param
520                                recursive If the resource location has a concept of recursive
521                                directory traversal, enabling this option will mean you can load
522                                resources in subdirectories using only their unqualified name.
523                                The default is to disable this so that resources in subdirectories
524                                with the same name are still unique.
525            @see
526                Archive
527        */
528        void addResourceLocation(const String& name, const String& locType,
529                        const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
530                        bool recursive = false);
531
532                /** Removes a resource location from the list.
533                @see addResourceLocation
534                @param name The name of the resource location as specified in addResourceLocation
535                @param groupName The name of the resource group to which this location
536                        was assigned.
537                */
538                void removeResourceLocation(const String& name,
539                        const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
540
541        /** Generates a packed data version of the passed in ColourValue suitable for
542            use with the current RenderSystem.
543        @remarks
544            Since different render systems have different colour data formats (eg
545            RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all.
546        @param colour The colour to convert
547        @param pDest Pointer to location to put the result.
548        */
549        void convertColourValue(const ColourValue& colour, uint32* pDest);
550
551        /** Retrieves a pointer to the window that was created automatically
552            @remarks
553                When Root is initialised an optional window is created. This
554                method retreives a pointer to that window.
555            @note
556                returns a null pointer when Root has not been initialised with
557                the option of creating a window.
558        */
559        RenderWindow* getAutoCreatedWindow(void);
560
561        /** @copydoc RenderSystem::createRenderWindow
562        */
563                RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
564                        bool fullScreen, const NameValuePairList *miscParams = 0) ;
565
566        /** Destroys a rendering window.
567        */
568        void detachRenderTarget( RenderTarget* pWin );
569
570        /** Destroys a named rendering window.
571        */
572        void detachRenderTarget( const String & name );
573
574        /** Retrieves a pointer to the a named render window.
575        */
576        RenderTarget * getRenderTarget(const String &name);
577
578        /** Sets whether or not the debug overlay is shown.
579        @remarks
580            The debug overlay displays frame rate stats and various other debug
581            information. You can enable it or disable it using this method.
582            Alternatively you could access the overlay directly using mSceneManager::getOverlay
583            but this is simpler.
584        void showDebugOverlay(bool show);
585        */
586
587                /** Manually load a plugin.
588                 @remarks
589                        Plugins are loaded at startup using the plugin configuration
590                        file specified when you create Root (default: plugins.cfg).
591                        This method allows you to load plugins in code.
592                @param pluginName Name of the plugin library to load
593                */
594                void loadPlugin(const String& pluginName);
595
596                /** Manually unloads a plugin.
597                 @remarks
598                        Plugins are unloaded at shutdown automatically.
599                        This method allows you to unload plugins in code, but
600                        make sure their dependencies are decoupled frist.
601                @param pluginName Name of the plugin library to unload
602                */
603                void unloadPlugin(const String& pluginName);
604
605        /** Gets a pointer to the central timer used for all OGRE timings */
606        Timer* getTimer(void);
607
608        /** Method for raising frame started events.
609        @remarks
610            This method is only for internal use when you use OGRE's inbuilt rendering
611            loop (Root::startRendering). However, if you run your own rendering loop then
612            you should call this method to ensure that FrameListener objects are notified
613            of frame events; processes like texture animation and particle systems rely on
614            this.
615        @par
616            Calling this method also increments the frame number, which is
617            important for keeping some elements of the engine up to date.
618        @note
619            This method takes an event object as a parameter, so you can specify the times
620            yourself. If you are happy for OGRE to automatically calculate the frame time
621            for you, then call the other version of this method with no parameters.
622        @param evt Event object which includes all the timing information which you have
623            calculated for yourself
624        @returns False if one or more frame listeners elected that the rendering loop should
625            be terminated, true otherwise.
626        */
627        bool _fireFrameStarted(FrameEvent& evt);
628        /** Method for raising frame ended events.
629        @remarks
630            This method is only for internal use when you use OGRE's inbuilt rendering
631            loop (Root::startRendering). However, if you run your own rendering loop then
632            you should call this method to ensure that FrameListener objects are notified
633            of frame events; processes like texture animation and particle systems rely on
634            this.
635        @note
636            This method takes an event object as a parameter, so you can specify the times
637            yourself. If you are happy for OGRE to automatically calculate the frame time
638            for you, then call the other version of this method with no parameters.
639        @param evt Event object which includes all the timing information which you have
640            calculated for yourself
641        @returns False if one or more frame listeners elected that the rendering loop should
642            be terminated, true otherwise.
643        */
644        bool _fireFrameEnded(FrameEvent& evt);
645        /** Method for raising frame started events.
646        @remarks
647            This method is only for internal use when you use OGRE's inbuilt rendering
648            loop (Root::startRendering). However, if you run your own rendering loop then
649            you should call this method to ensure that FrameListener objects are notified
650            of frame events; processes like texture animation and particle systems rely on
651            this.
652        @par
653            Calling this method also increments the frame number, which is
654            important for keeping some elements of the engine up to date.
655        @note
656            This method calculates the frame timing information for you based on the elapsed
657            time. If you want to specify elapsed times yourself you should call the other
658            version of this method which takes event details as a parameter.
659        @returns False if one or more frame listeners elected that the rendering loop should
660            be terminated, true otherwise.
661        */
662        bool _fireFrameStarted();
663        /** Method for raising frame ended events.
664        @remarks
665            This method is only for internal use when you use OGRE's inbuilt rendering
666            loop (Root::startRendering). However, if you run your own rendering loop then
667            you should call this method to ensure that FrameListener objects are notified
668            of frame events; processes like texture animation and particle systems rely on
669            this.
670        @note
671            This method calculates the frame timing information for you based on the elapsed
672            time. If you want to specify elapsed times yourself you should call the other
673            version of this method which takes event details as a parameter.
674        @returns False if one or more frame listeners elected that the rendering loop should
675            be terminated, true otherwise.
676        */
677        bool _fireFrameEnded();
678
679        /** Gets the number of the current frame. */
680        unsigned long getCurrentFrameNumber(void) const { return mCurrentFrame; }
681
682        /** Returns the scene manager currently being used to render a frame.
683        @remarks
684            This is only intended for internal use; it is only valid during the
685            rendering of a frame.
686        */
687        SceneManager* _getCurrentSceneManager(void) const { return mCurrentSceneManager; }
688        /** Sets the scene manager currently being used to render a frame.
689        @remarks
690            This is only intended for internal use.
691        */
692        void _setCurrentSceneManager(SceneManager* sm);
693
694        /** Internal method used for updating all RenderTarget objects (windows,
695            renderable textures etc) which are set to auto-update.
696        @remarks
697            You don't need to use this method if you're using Ogre's own internal
698            rendering loop (Root::startRendering). If you're running your own loop
699            you may wish to call it to update all the render targets which are
700            set to auto update (RenderTarget::setAutoUpdated). You can also update
701            individual RenderTarget instances using their own update() method.
702        */
703        void _updateAllRenderTargets(void);
704
705                /** Create a new RenderQueueInvocationSequence, useful for linking to
706                        Viewport instances to perform custom rendering.
707                @param name The name to give the new sequence
708                */
709                RenderQueueInvocationSequence* createRenderQueueInvocationSequence(
710                        const String& name);
711
712                /** Get a RenderQueueInvocationSequence.
713                @param name The name to identify the sequence
714                */
715                RenderQueueInvocationSequence* getRenderQueueInvocationSequence(
716                        const String& name);
717
718                /** Destroy a RenderQueueInvocationSequence.
719                @remarks
720                        You must ensure that no Viewports are using this sequence.
721                @param name The name to identify the sequence
722                */
723                void destroyRenderQueueInvocationSequence(
724                        const String& name);
725
726                /** Destroy all RenderQueueInvocationSequences.
727                @remarks
728                        You must ensure that no Viewports are using custom sequences.
729                @param name The name to identify the sequence
730                */
731                void destroyAllRenderQueueInvocationSequences(void);
732
733        /** Override standard Singleton retrieval.
734            @remarks
735                Why do we do this? Well, it's because the Singleton
736                implementation is in a .h file, which means it gets compiled
737                into anybody who includes it. This is needed for the
738                Singleton template to work, but we actually only want it
739                compiled into the implementation of the class based on the
740                Singleton, not all of them. If we don't change this, we get
741                link errors when trying to use the Singleton-based class from
742                an outside dll.
743            @par
744                This method just delegates to the template version anyway,
745                but the implementation stays in this single compilation unit,
746                preventing link errors.
747        */
748        static Root& getSingleton(void);
749        /** Override standard Singleton retrieval.
750            @remarks
751                Why do we do this? Well, it's because the Singleton
752                implementation is in a .h file, which means it gets compiled
753                into anybody who includes it. This is needed for the
754                Singleton template to work, but we actually only want it
755                compiled into the implementation of the class based on the
756                Singleton, not all of them. If we don't change this, we get
757                link errors when trying to use the Singleton-based class from
758                an outside dll.
759            @par
760                This method just delegates to the template version anyway,
761                but the implementation stays in this single compilation unit,
762                preventing link errors.
763        */
764        static Root* getSingletonPtr(void);
765
766                /** Clears the history of all event times.
767                @remarks
768                        OGRE stores a history of the last few event times in order to smooth
769                        out any inaccuracies and temporary fluctuations. However, if you
770                        pause or don't render for a little while this can cause a lurch, so
771                        if you're resuming rendering after a break, call this method to reset
772                        the stored times
773                */
774                void clearEventTimes(void);
775
776                /** Sets the period over which OGRE smooths out fluctuations in frame times.
777                @remarks
778                        OGRE by default gives you the raw frame time, but can optionally
779                        smooths it out over several frames, in order to reduce the
780                        noticeable effect of occasional hiccups in framerate.
781                        These smoothed values are passed back as parameters to FrameListener
782                        calls.
783                @par
784                        This method allow you to tweak the smoothing period, and is expressed
785                        in seconds. Setting it to 0 will result in completely unsmoothed
786                        frame times (the default).
787                */
788                void setFrameSmoothingPeriod(Real period) { mFrameSmoothingTime = period; }
789                /** Gets the period over which OGRE smooths out fluctuations in frame times. */
790                Real getFrameSmoothingPeriod(void) const { return mFrameSmoothingTime; }
791
792                /** Register a new MovableObjectFactory which will create new MovableObject
793                        instances of a particular type, as identified by the getType() method.
794                @remarks
795                        Plugin creators can create subclasses of MovableObjectFactory which
796                        construct custom subclasses of MovableObject for insertion in the
797                        scene. This is the primary way that plugins can make custom objects
798                        available.
799                @param fact Pointer to the factory instance
800                @param overrideExisting Set this to true to override any existing
801                        factories which are registered for the same type. You should only
802                        change this if you are very sure you know what you're doing.
803                */
804                void addMovableObjectFactory(MovableObjectFactory* fact,
805                        bool overrideExisting = false);
806                /** Removes a previously registered MovableObjectFactory.
807                @remarks
808                        All instances of objects created by this factory will be destroyed
809                        before removing the factory (by calling back the factories
810                        'destroyInstance' method). The plugin writer is responsible for actually
811                        destroying the factory.
812                */
813                void removeMovableObjectFactory(MovableObjectFactory* fact);
814                /// Checks whether a factory is registered for a given MovableObject type
815                bool hasMovableObjectFactory(const String& typeName) const;
816                /// Get a MovableObjectFactory for the given type
817                MovableObjectFactory* getMovableObjectFactory(const String& typeName);
818                /** Allocate the next MovableObject type flag.
819                @remarks
820                        This is done automatically if MovableObjectFactory::requestTypeFlags
821                        returns true; don't call this manually unless you're sure you need to.
822                */
823                uint32 _allocateNextMovableObjectTypeFlag(void);
824
825                typedef ConstMapIterator<MovableObjectFactoryMap> MovableObjectFactoryIterator;
826                /** Return an iterator over all the MovableObjectFactory instances currently
827                        registered.
828                */
829                MovableObjectFactoryIterator getMovableObjectFactoryIterator(void) const;
830    };
831} // Namespace Ogre
832#endif
Note: See TracBrowser for help on using the repository browser.