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

Revision 1591, 4.6 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 __FrameListener_H__
26#define __FrameListener_H__
27
28
29#include "OgrePrerequisites.h"
30
31namespace 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           
84#ifdef GAMETOOLS_ILLUMINATION_MODULE
85        protected:
86                int priority;
87
88        public:
89                bool compare(const FrameListener* l)const
90                {
91                        return priority < l->priority;
92                }
93                int getPriority(){return priority;}
94                void setPriority(int p){priority = p;}
95                FrameListener(){priority = 0;}
96#endif
97                public:
98
99        /** Called when a frame is about to begin rendering.
100            @return
101                True to go ahead, false to abort rendering and drop
102                out of the rendering loop.
103        */
104        virtual bool frameStarted(const FrameEvent& evt) { return true; }
105        /** Called just after a frame has been rendered.
106            @return
107                True to continue with the next frame, false to drop
108                out of the rendering loop.
109        */
110        virtual bool frameEnded(const FrameEvent& evt) { return true; }
111
112                virtual ~FrameListener() {}
113               
114    };
115}
116
117#endif
Note: See TracBrowser for help on using the repository browser.