Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreFrameListener.h @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

File size: 4.4 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __FrameListener_H__
30#define __FrameListener_H__
31
32
33#include "OgrePrerequisites.h"
34
35namespace Ogre {
36
37    /** Struct containing information about a frame event.
38    */
39    struct FrameEvent
40    {
41        /** Elapsed time in seconds since the last event.
42            This gives you time between frame start & frame end,
43            and between frame end and next frame start.
44            @remarks
45                This may not be the elapsed time but the average
46                elapsed time between recently fired events.
47        */
48        Real timeSinceLastEvent;
49        /** Elapsed time in seconds since the last event of the same type,
50            i.e. time for a complete frame.
51            @remarks
52                This may not be the elapsed time but the average
53                elapsed time between recently fired events of the same type.
54        */
55        Real timeSinceLastFrame;
56    };
57
58
59    /** A interface class defining a listener which can be used to receive
60        notifications of frame events.
61        @remarks
62            A 'listener' is an interface designed to be called back when
63            particular events are called. This class defines the
64            interface relating to frame events. In order to receive
65            notifications of frame events, you should create a subclass of
66            FrameListener and override the methods for which you would like
67            to customise the resulting processing. You should then call
68            Root::addFrameListener passing an instance of this class.
69            There is no limit to the number of frame listeners you can register,
70            allowing you to register multiple listeners for different purposes.
71            Frame events only occur when Ogre is in continuous rendering mode,
72            ie. after Root::startRendering is called. If the application is
73            doing ad-hoc rendering without entering a rendering loop, frame
74            events are not generated. Note that a frame event occurs once for
75            all rendering targets, not once per target.
76    */
77    class _OgreExport FrameListener
78    {
79        /*
80        Note that this could have been an abstract class, but I made
81        the explicit choice not to do this, because I wanted to give
82        people the option of only implementing the methods they wanted,
83        rather than having to create 'do nothing' implementations for
84        those they weren't interested in. As such this class follows
85        the 'Adapter' classes in Java rather than pure interfaces.
86        */
87    public:
88        /** Called when a frame is about to begin rendering.
89            @return
90                True to go ahead, false to abort rendering and drop
91                out of the rendering loop.
92        */
93        virtual bool frameStarted(const FrameEvent& evt) { return true; }
94        /** Called just after a frame has been rendered.
95            @return
96                True to continue with the next frame, false to drop
97                out of the rendering loop.
98        */
99        virtual bool frameEnded(const FrameEvent& evt) { return true; }
100
101                virtual ~FrameListener() {}
102               
103    };
104}
105
106#endif
Note: See TracBrowser for help on using the repository browser.