OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreRenderTarget.h
Go to the documentation of this file.
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-2011 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __RenderTarget_H__
29 #define __RenderTarget_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreString.h"
34 #include "OgreTextureManager.h"
35 #include "OgreViewport.h"
36 #include "OgreTimer.h"
37 
38 /* Define the number of priority groups for the render system's render targets. */
39 #ifndef OGRE_NUM_RENDERTARGET_GROUPS
40  #define OGRE_NUM_RENDERTARGET_GROUPS 10
41  #define OGRE_DEFAULT_RT_GROUP 4
42  #define OGRE_REND_TO_TEX_RT_GROUP 2
43 #endif
44 
45 namespace Ogre {
46 
65  {
66  public:
67  enum StatFlags
68  {
69  SF_NONE = 0,
70  SF_FPS = 1,
71  SF_AVG_FPS = 2,
72  SF_BEST_FPS = 4,
73  SF_WORST_FPS = 8,
74  SF_TRIANGLE_COUNT = 16,
75  SF_ALL = 0xFFFF
76  };
77 
78  struct FrameStats
79  {
80  float lastFPS;
81  float avgFPS;
82  float bestFPS;
83  float worstFPS;
84  unsigned long bestFrameTime;
85  unsigned long worstFrameTime;
86  size_t triangleCount;
87  size_t batchCount;
88  };
89 
91  {
94  FB_AUTO
95  };
96 
97  RenderTarget();
98  virtual ~RenderTarget();
99 
101  virtual const String& getName(void) const;
102 
104  virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth);
105 
106  virtual unsigned int getWidth(void) const;
107  virtual unsigned int getHeight(void) const;
108  virtual unsigned int getColourDepth(void) const;
109 
132  virtual void update(bool swapBuffers = true);
153  virtual void swapBuffers(bool waitForVSync = true)
154  { (void)waitForVSync; }
155 
179  virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f ,
180  float width = 1.0f, float height = 1.0f);
181 
183  virtual unsigned short getNumViewports(void) const;
184 
186  virtual Viewport* getViewport(unsigned short index);
187 
190  virtual void removeViewport(int ZOrder);
191 
194  virtual void removeAllViewports(void);
195 
214  virtual void getStatistics(float& lastFPS, float& avgFPS,
215  float& bestFPS, float& worstFPS) const; // Access to stats
216 
217  virtual const FrameStats& getStatistics(void) const;
218 
221  virtual float getLastFPS() const;
222 
225  virtual float getAverageFPS() const;
226 
229  virtual float getBestFPS() const;
230 
233  virtual float getWorstFPS() const;
234 
237  virtual float getBestFrameTime() const;
238 
241  virtual float getWorstFrameTime() const;
242 
245  virtual void resetStatistics(void);
246 
256  virtual void getCustomAttribute(const String& name, void* pData);
257 
266  virtual void addListener(RenderTargetListener* listener);
268  virtual void removeListener(RenderTargetListener* listener);
270  virtual void removeAllListeners(void);
271 
279  virtual void setPriority( uchar priority ) { mPriority = priority; }
281  virtual uchar getPriority() const { return mPriority; }
282 
285  virtual bool isActive() const;
286 
289  virtual void setActive( bool state );
290 
302  virtual void setAutoUpdated(bool autoupdate);
306  virtual bool isAutoUpdated(void) const;
307 
313  virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer = FB_AUTO) = 0;
314 
318  virtual PixelFormat suggestPixelFormat() const { return PF_BYTE_RGBA; }
319 
321  void writeContentsToFile(const String& filename);
322 
325  virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix);
326 
327  virtual bool requiresTextureFlipping() const = 0;
328 
330  virtual size_t getTriangleCount(void) const;
332  virtual size_t getBatchCount(void) const;
336  virtual void _notifyCameraRemoved(const Camera* cam);
337 
344  virtual bool isPrimary(void) const;
345 
353  virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
354 
357  virtual uint getFSAA() const { return mFSAA; }
358 
361  virtual const String& getFSAAHint() const { return mFSAAHint; }
362 
366  class Impl
367  {
368  protected:
369  ~Impl() { }
370  };
376  virtual Impl *_getImpl();
377 
401  virtual void _beginUpdate();
402 
412  virtual void _updateViewport(int zorder, bool updateStatistics = true);
413 
422  virtual void _updateViewport(Viewport* viewport, bool updateStatistics = true);
423 
432  virtual void _updateAutoUpdatedViewports(bool updateStatistics = true);
433 
440  virtual void _endUpdate();
441 
442  protected:
447 
448  unsigned int mWidth;
449  unsigned int mHeight;
450  unsigned int mColourDepth;
452 
453  // Stats
455 
457  unsigned long mLastSecond;
458  unsigned long mLastTime;
459  size_t mFrameCount;
460 
461  bool mActive;
463  // Hardware sRGB gamma conversion done on write?
464  bool mHwGamma;
465  // FSAA performed?
468 
469  void updateStats(void);
470 
474 
477 
478 
480  virtual void firePreUpdate(void);
482  virtual void firePostUpdate(void);
484  virtual void fireViewportPreUpdate(Viewport* vp);
486  virtual void fireViewportPostUpdate(Viewport* vp);
488  virtual void fireViewportAdded(Viewport* vp);
490  virtual void fireViewportRemoved(Viewport* vp);
491 
493  virtual void updateImpl();
494  };
498 } // Namespace
499 
500 #endif
A 'canvas' which can receive the results of a rendering operation.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:85
unsigned long mLastTime
#define _OgreExport
Definition: OgrePlatform.h:203
vector< RenderTargetListener * >::type RenderTargetListenerList
virtual uint getFSAA() const
Indicates whether multisampling is performed on rendering and at what level.
map< int, Viewport * >::type ViewportList
virtual PixelFormat suggestPixelFormat() const
Suggests a pixel format to use for extracting the data in this target, when calling copyContentsToMem...
virtual uchar getPriority() const
Gets the priority of a render target.
4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha ...
virtual bool isHardwareGammaEnabled() const
Indicates whether on rendering, linear colour space is converted to sRGB gamma colour space...
Timer class.
String mName
The name of this target.
RenderSystem specific interface for a RenderTarget; this should be subclassed by RenderSystems.
uchar mPriority
The priority of the render target.
unsigned int mColourDepth
virtual void swapBuffers(bool waitForVSync=true)
Swaps the frame buffers to display the next frame.
PixelFormat
The pixel format used for images, textures, and render surfaces.
unsigned char uchar
In order to avoid finger-aches :)
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
RenderTargetListenerList mListeners
A interface class defining a listener which can be used to receive notifications of RenderTarget even...
ViewportList mViewportList
List of viewports, map on Z-order.
virtual void setPriority(uchar priority)
Sets the priority of this render target in relation to the others.
virtual const String & getFSAAHint() const
Gets the FSAA hint (.
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:56
_StringBase String
unsigned long mLastSecond
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
unsigned int uint