OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-2014 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 "OgrePixelFormat.h"
34 #include "OgreHeaderPrefix.h"
35 
36 /* Define the number of priority groups for the render system's render targets. */
37 #ifndef OGRE_NUM_RENDERTARGET_GROUPS
38  #define OGRE_NUM_RENDERTARGET_GROUPS 10
39  #define OGRE_DEFAULT_RT_GROUP 4
40  #define OGRE_REND_TO_TEX_RT_GROUP 2
41 #endif
42 
43 namespace Ogre {
44 
63  {
64  public:
65  enum StatFlags
66  {
67  SF_NONE = 0,
68  SF_FPS = 1,
69  SF_AVG_FPS = 2,
70  SF_BEST_FPS = 4,
71  SF_WORST_FPS = 8,
72  SF_TRIANGLE_COUNT = 16,
73  SF_ALL = 0xFFFF
74  };
75 
76  struct FrameStats
77  {
78  size_t triangleCount;
79  size_t batchCount;
80  int vBlankMissCount; // -1 means that the value is not applicable
81  };
82 
84  {
87  FB_AUTO
88  };
89 
90  RenderTarget();
91  virtual ~RenderTarget();
92 
94  virtual const String& getName(void) const;
95 
97  virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth);
98 
99  virtual uint32 getWidth(void) const;
100  virtual uint32 getHeight(void) const;
101  virtual uint32 getColourDepth(void) const;
102 
110  void setDepthBufferPool( uint16 poolId );
111 
112  //Returns the pool ID this RenderTarget should query from. @see DepthBuffer
113  uint16 getDepthBufferPool() const;
114 
115  DepthBuffer* getDepthBuffer() const;
116 
117  //Returns false if couldn't attach
118  virtual bool attachDepthBuffer( DepthBuffer *depthBuffer );
119 
120  virtual void detachDepthBuffer();
121 
126  virtual void _detachDepthBuffer();
127 
136  virtual void swapBuffers(void) { mFsaaResolveDirty = false; }
137 
138  virtual void setFsaaResolveDirty(void) { mFsaaResolveDirty = true; }
139 
163  virtual Viewport* addViewport( float left = 0.0f, float top = 0.0f,
164  float width = 1.0f, float height = 1.0f );
165 
167  virtual unsigned short getNumViewports(void) const;
168 
170  virtual Viewport* getViewport(unsigned short index);
171 
174  virtual void removeViewport( Viewport *vp );
175 
178  virtual void removeAllViewports(void);
179 
180  virtual const FrameStats& getStatistics(void) const;
181 
184  virtual void resetStatistics(void);
185 
195  virtual void getCustomAttribute(const String& name, void* pData);
196 
205  virtual void addListener(RenderTargetListener* listener);
207  virtual void removeListener(RenderTargetListener* listener);
209  virtual void removeAllListeners(void);
210 
218  virtual void setPriority( uchar priority ) { mPriority = priority; }
220  virtual uchar getPriority() const { return mPriority; }
221 
224  virtual bool isActive() const;
225 
228  virtual void setActive( bool state );
229 
235  virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer = FB_AUTO) = 0;
236 
240  virtual PixelFormat suggestPixelFormat() const { return PF_BYTE_RGBA; }
241 
243  void writeContentsToFile(const String& filename);
244 
247  virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix);
248 
249  virtual bool requiresTextureFlipping() const = 0;
250 
252  virtual size_t getTriangleCount(void) const;
254  virtual size_t getBatchCount(void) const;
255 
262  virtual bool isPrimary(void) const;
263 
271  virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
272 
275  virtual uint getFSAA() const { return mFSAA; }
276 
279  virtual const String& getFSAAHint() const { return mFSAAHint; }
280 
281  bool isFsaaResolveDirty(void) const { return mFsaaResolveDirty; }
282 
286  class Impl
287  {
288  protected:
289  ~Impl() { }
290  };
296  virtual Impl *_getImpl();
297 
321  virtual void _beginUpdate();
322 
323  void _updateViewportCullPhase01(Viewport* viewport, Camera *camera, const Camera *lodCamera,
324  uint8 firstRq, uint8 lastRq );
325 
336  virtual void _updateViewportRenderPhase02( Viewport* viewport, Camera *camera,
337  const Camera *lodCamera,uint8 firstRq, uint8 lastRq,
338  bool updateStatistics );
339 
341  virtual bool isRenderWindow(void) const { return false; }
342 
349  virtual void _endUpdate();
350 
351  protected:
356 
362 
363  // Stats
365 
366  bool mActive;
367  // Hardware sRGB gamma conversion done on write?
368  bool mHwGamma;
369  // FSAA performed?
373 
377 
380 
381 
383  virtual void firePreUpdate(void);
385  virtual void firePostUpdate(void);
387  virtual void fireViewportPreUpdate(Viewport* vp);
389  virtual void fireViewportPostUpdate(Viewport* vp);
391  virtual void fireViewportAdded(Viewport* vp);
393  virtual void fireViewportRemoved(Viewport* vp);
394  };
398 } // Namespace
399 
400 #include "OgreHeaderSuffix.h"
401 
402 #endif
unsigned char uint8
Definition: OgrePlatform.h:422
A 'canvas' which can receive the results of a rendering operation.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
vector< RenderTargetListener * >::type RenderTargetListenerList
virtual uint getFSAA() const
Indicates whether multisampling is performed on rendering and at what level.
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.
bool isFsaaResolveDirty(void) const
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...
An abstract class that contains a depth/stencil buffer.
All return values are either in milliseconds or frames per second; but they're internally stored in m...
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.
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...
DepthBuffer * mDepthBuffer
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
virtual void setFsaaResolveDirty(void)
_StringBase String
Definition: OgreCommon.h:53
unsigned short uint16
Definition: OgrePlatform.h:421
virtual void swapBuffers(void)
Swaps the frame buffers to display the next frame.
virtual bool isRenderWindow(void) const
Whether our derived class is RenderWindow.
vector< Viewport * >::type ViewportList
unsigned int uint