[692] | 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-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #ifndef __FrameListener_H__
|
---|
| 26 | #define __FrameListener_H__
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | #include "OgrePrerequisites.h"
|
---|
| 30 |
|
---|
| 31 | namespace Ogre {
|
---|
| 32 |
|
---|
| 33 | /** Struct containing information about a frame event.
|
---|
| 34 | */
|
---|
| 35 | struct FrameEvent
|
---|
| 36 | {
|
---|
| 37 | /** Elapsed time in seconds since the last event.
|
---|
| 38 | This gives you time between frame start & frame end,
|
---|
| 39 | and between frame end and next frame start.
|
---|
| 40 | @remarks
|
---|
| 41 | This may not be the elapsed time but the average
|
---|
| 42 | elapsed time between recently fired events.
|
---|
| 43 | */
|
---|
| 44 | Real timeSinceLastEvent;
|
---|
| 45 | /** Elapsed time in seconds since the last event of the same type,
|
---|
| 46 | i.e. time for a complete frame.
|
---|
| 47 | @remarks
|
---|
| 48 | This may not be the elapsed time but the average
|
---|
| 49 | elapsed time between recently fired events of the same type.
|
---|
| 50 | */
|
---|
| 51 | Real timeSinceLastFrame;
|
---|
| 52 | };
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | /** A interface class defining a listener which can be used to receive
|
---|
| 56 | notifications of frame events.
|
---|
| 57 | @remarks
|
---|
| 58 | A 'listener' is an interface designed to be called back when
|
---|
| 59 | particular events are called. This class defines the
|
---|
| 60 | interface relating to frame events. In order to receive
|
---|
| 61 | notifications of frame events, you should create a subclass of
|
---|
| 62 | FrameListener and override the methods for which you would like
|
---|
| 63 | to customise the resulting processing. You should then call
|
---|
| 64 | Root::addFrameListener passing an instance of this class.
|
---|
| 65 | There is no limit to the number of frame listeners you can register,
|
---|
| 66 | allowing you to register multiple listeners for different purposes.
|
---|
| 67 | Frame events only occur when Ogre is in continuous rendering mode,
|
---|
| 68 | ie. after Root::startRendering is called. If the application is
|
---|
| 69 | doing ad-hoc rendering without entering a rendering loop, frame
|
---|
| 70 | events are not generated. Note that a frame event occurs once for
|
---|
| 71 | all rendering targets, not once per target.
|
---|
| 72 | */
|
---|
| 73 | class _OgreExport FrameListener
|
---|
| 74 | {
|
---|
| 75 | /*
|
---|
| 76 | Note that this could have been an abstract class, but I made
|
---|
| 77 | the explicit choice not to do this, because I wanted to give
|
---|
| 78 | people the option of only implementing the methods they wanted,
|
---|
| 79 | rather than having to create 'do nothing' implementations for
|
---|
| 80 | those they weren't interested in. As such this class follows
|
---|
| 81 | the 'Adapter' classes in Java rather than pure interfaces.
|
---|
| 82 | */
|
---|
| 83 | public:
|
---|
| 84 | /** Called when a frame is about to begin rendering.
|
---|
| 85 | @return
|
---|
| 86 | True to go ahead, false to abort rendering and drop
|
---|
| 87 | out of the rendering loop.
|
---|
| 88 | */
|
---|
| 89 | virtual bool frameStarted(const FrameEvent& evt) { return true; }
|
---|
| 90 | /** Called just after a frame has been rendered.
|
---|
| 91 | @return
|
---|
| 92 | True to continue with the next frame, false to drop
|
---|
| 93 | out of the rendering loop.
|
---|
| 94 | */
|
---|
| 95 | virtual bool frameEnded(const FrameEvent& evt) { return true; }
|
---|
| 96 |
|
---|
| 97 | virtual ~FrameListener() {}
|
---|
| 98 |
|
---|
| 99 | };
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | #endif
|
---|