source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreViewport.h @ 1092

Revision 1092, 8.3 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

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 __Viewport_H__
26#define __Viewport_H__
27
28#include "OgrePrerequisites.h"
29
30#include "OgreColourValue.h"
31
32namespace Ogre {
33    /** An abstraction of a viewport, i.e. a rendering region on a render
34        target.
35        @remarks
36            A viewport is the meeting of a camera and a rendering surface -
37            the camera renders the scene from a viewpoint, and places its
38            results into some subset of a rendering target, which may be the
39            whole surface or just a part of the surface. Each viewport has a
40            single camera as source and a single target as destination. A
41            camera only has 1 viewport, but a render target may have several.
42            A viewport also has a Z-order, i.e. if there is more than one
43            viewport on a single render target and they overlap, one must
44            obscure the other in some predetermined way.
45    */
46    class _OgreExport Viewport
47    {
48    public:
49        /** The usual constructor.
50            @param
51                cam Pointer to a camera to be the source for the image.
52            @param
53                target Pointer to the render target to be the destination
54                for the rendering.
55            @param
56                left
57            @param
58                top
59            @param
60                width
61            @param
62                height
63                Dimensions of the viewport, expressed as a value between
64                0 and 1. This allows the dimensions to apply irrespective of
65                changes in the target's size: e.g. to fill the whole area,
66                values of 0,0,1,1 are appropriate.
67            @param
68                ZOrder Relative Z-order on the target. Lower = further to
69                the front.
70        */
71        Viewport(
72            Camera* camera,
73            RenderTarget* target,
74            Real left, Real top,
75            Real width, Real height,
76            int ZOrder);
77
78        /** Default destructor.
79        */
80        ~Viewport();
81
82        /** Notifies the viewport of a possible change in dimensions.
83            @remarks
84                Used by the target to update the viewport's dimensions
85                (usually the result of a change in target size).
86            @note
87                Internal use by Ogre only.
88        */
89        void _updateDimensions(void);
90
91        /** Instructs the viewport to updates its contents.
92        */
93        void update(void);
94
95        /** Retrieves a pointer to the render target for this viewport.
96        */
97        RenderTarget* getTarget(void) const;
98
99        /** Retrieves a pointer to the camera for this viewport.
100        */
101        Camera* getCamera(void) const;
102
103        /** Sets the camera to use for rendering to this viewport. */
104        void setCamera(Camera* cam);
105
106        /** Gets the Z-Order of this viewport. */
107                int getZOrder(void) const;
108                /** Gets one of the relative dimensions of the viewport,
109            a value between 0.0 and 1.0.
110        */
111        Real getLeft(void) const;
112
113        /** Gets one of the relative dimensions of the viewport, a value
114            between 0.0 and 1.0.
115        */
116        Real getTop(void) const;
117
118        /** Gets one of the relative dimensions of the viewport, a value
119            between 0.0 and 1.0.
120        */
121
122        Real getWidth(void) const;
123        /** Gets one of the relative dimensions of the viewport, a value
124            between 0.0 and 1.0.
125        */
126
127        Real getHeight(void) const;
128        /** Gets one of the actual dimensions of the viewport, a value in
129            pixels.
130        */
131
132        int getActualLeft(void) const;
133        /** Gets one of the actual dimensions of the viewport, a value in
134            pixels.
135        */
136
137        int getActualTop(void) const;
138        /** Gets one of the actual dimensions of the viewport, a value in
139            pixels.
140        */
141        int getActualWidth(void) const;
142        /** Gets one of the actual dimensions of the viewport, a value in
143            pixels.
144        */
145
146        int getActualHeight(void) const;
147
148        /** Sets the dimensions (after creation).
149            @param
150                left
151            @param
152                top
153            @param
154                width
155            @param
156                height Dimensions relative to the size of the target,
157                represented as real values between 0 and 1. i.e. the full
158                target area is 0, 0, 1, 1.
159        */
160        void setDimensions(Real left, Real top, Real width, Real height);
161
162        /** Sets the initial background colour of the viewport (before
163            rendering).
164        */
165        void setBackgroundColour(const ColourValue& colour);
166
167        /** Gets the background colour.
168        */
169        const ColourValue& getBackgroundColour(void) const;
170
171        /** Determines whether to clear the viewport before rendering.
172            @remarks
173                If you expecting every pixel on the viewport to be redrawn
174                every frame, you can save a little time by not clearing the
175                viewport before every frame. Do so by passing 'false' to this
176                method (the default is to clear every frame).
177         */
178        void setClearEveryFrame(bool clear);
179
180        /** Determines if the viewport is cleared before every frame.
181        */
182        bool getClearEveryFrame(void) const;
183
184        /** Access to actual dimensions (based on target size).
185        */
186        void getActualDimensions(
187            int &left, int &top, int &width, int &height ) const;
188
189        bool _isUpdated(void) const;
190        void _clearUpdatedFlag(void);
191
192        /** Gets the number of rendered faces in the last update.
193        */
194        unsigned int _getNumRenderedFaces(void) const;
195
196        /** Tells this viewport whether it should display Overlay objects.
197        @remarks
198            Overlay objects are layers which appear on top of the scene. They are created via
199            SceneManager::createOverlay and every viewport displays these by default.
200            However, you probably don't want this if you're using multiple viewports,
201            because one of them is probably a picture-in-picture which is not supposed to
202            have overlays of it's own. In this case you can turn off overlays on this viewport
203            by calling this method.
204        @param enabled If true, any overlays are displayed, if false they are not.
205        */
206        void setOverlaysEnabled(bool enabled);
207
208        /** Returns whether or not Overlay objects (created in the SceneManager) are displayed in this
209            viewport. */
210        bool getOverlaysEnabled(void) const;
211
212
213    protected:
214        Camera* mCamera;
215        RenderTarget* mTarget;
216        // Relative dimensions, irrespective of target dimensions (0..1)
217        float mRelLeft, mRelTop, mRelWidth, mRelHeight;
218        // Actual dimensions, based on target dimensions
219        int mActLeft, mActTop, mActWidth, mActHeight;
220        /// ZOrder
221        int mZOrder;
222        /// Background options
223        ColourValue mBackColour;
224        bool mClearEveryFrame;
225        bool mUpdated;
226        bool mShowOverlays;
227    };
228
229}
230
231#endif
Note: See TracBrowser for help on using the repository browser.