OgreRenderTarget.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __RenderTarget_H__
#define __RenderTarget_H__
#include "OgrePrerequisites.h"
#include "OgreString.h"
#include "OgreTextureManager.h"
#include "OgreViewport.h"
#include "OgreTimer.h"
#include "OgreHeaderPrefix.h"
/* Define the number of priority groups for the render system's render targets. */
#ifndef OGRE_NUM_RENDERTARGET_GROUPS
#define OGRE_NUM_RENDERTARGET_GROUPS 10
#define OGRE_DEFAULT_RT_GROUP 4
#define OGRE_REND_TO_TEX_RT_GROUP 2
#endif
namespace Ogre {
class _OgreExport RenderTarget : public RenderSysAlloc
{
public:
enum StatFlags
{
SF_NONE = 0,
SF_FPS = 1,
SF_AVG_FPS = 2,
SF_BEST_FPS = 4,
SF_WORST_FPS = 8,
SF_TRIANGLE_COUNT = 16,
SF_ALL = 0xFFFF
};
struct FrameStats
{
float lastFPS;
float avgFPS;
float bestFPS;
float worstFPS;
unsigned long bestFrameTime;
unsigned long worstFrameTime;
size_t triangleCount;
size_t batchCount;
};
enum FrameBuffer
{
FB_FRONT,
FB_BACK,
FB_AUTO
};
RenderTarget();
virtual ~RenderTarget();
virtual const String& getName(void) const;
virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth);
virtual uint32 getWidth(void) const;
virtual uint32 getHeight(void) const;
virtual uint32 getColourDepth(void) const;
void setDepthBufferPool( uint16 poolId );
//Returns the pool ID this RenderTarget should query from. @see DepthBuffer
uint16 getDepthBufferPool() const;
DepthBuffer* getDepthBuffer() const;
//Returns false if couldn't attach
virtual bool attachDepthBuffer( DepthBuffer *depthBuffer );
virtual void detachDepthBuffer();
virtual void _detachDepthBuffer();
virtual void update(bool swapBuffers = true);
virtual void swapBuffers() {}
virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f ,
float width = 1.0f, float height = 1.0f);
virtual unsigned short getNumViewports(void) const;
virtual Viewport* getViewport(unsigned short index);
virtual Viewport* getViewportByZOrder(int ZOrder);
virtual bool hasViewportWithZOrder(int ZOrder);
virtual void removeViewport(int ZOrder);
virtual void removeAllViewports(void);
virtual void getStatistics(float& lastFPS, float& avgFPS,
float& bestFPS, float& worstFPS) const; // Access to stats
virtual const FrameStats& getStatistics(void) const;
virtual float getLastFPS() const;
virtual float getAverageFPS() const;
virtual float getBestFPS() const;
virtual float getWorstFPS() const;
virtual float getBestFrameTime() const;
virtual float getWorstFrameTime() const;
virtual void resetStatistics(void);
virtual void getCustomAttribute(const String& name, void* pData);
virtual void addListener(RenderTargetListener* listener);
virtual void removeListener(RenderTargetListener* listener);
virtual void removeAllListeners(void);
virtual void setPriority( uchar priority ) { mPriority = priority; }
virtual uchar getPriority() const { return mPriority; }
virtual bool isActive() const;
virtual void setActive( bool state );
virtual void setAutoUpdated(bool autoupdate);
virtual bool isAutoUpdated(void) const;
virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer = FB_AUTO) = 0;
virtual PixelFormat suggestPixelFormat() const { return PF_BYTE_RGBA; }
void writeContentsToFile(const String& filename);
virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix);
virtual bool requiresTextureFlipping() const = 0;
virtual size_t getTriangleCount(void) const;
virtual size_t getBatchCount(void) const;
virtual void _notifyCameraRemoved(const Camera* cam);
virtual bool isPrimary(void) const;
virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
virtual uint getFSAA() const { return mFSAA; }
virtual const String& getFSAAHint() const { return mFSAAHint; }
class Impl
{
protected:
~Impl() { }
};
virtual Impl *_getImpl();
virtual void _beginUpdate();
virtual void _updateViewport(int zorder, bool updateStatistics = true);
virtual void _updateViewport(Viewport* viewport, bool updateStatistics = true);
virtual void _updateAutoUpdatedViewports(bool updateStatistics = true);
virtual void _endUpdate();
protected:
String mName;
uchar mPriority;
uint32 mWidth;
uint32 mHeight;
uint32 mColourDepth;
uint16 mDepthBufferPoolId;
DepthBuffer *mDepthBuffer;
// Stats
FrameStats mStats;
Timer* mTimer ;
unsigned long mLastSecond;
unsigned long mLastTime;
size_t mFrameCount;
bool mActive;
bool mAutoUpdate;
// Hardware sRGB gamma conversion done on write?
bool mHwGamma;
// FSAA performed?
uint mFSAA;
String mFSAAHint;
void updateStats(void);
typedef map<int, Viewport*>::type ViewportList;
ViewportList mViewportList;
typedef vector<RenderTargetListener*>::type RenderTargetListenerList;
RenderTargetListenerList mListeners;
virtual void firePreUpdate(void);
virtual void firePostUpdate(void);
virtual void fireViewportPreUpdate(Viewport* vp);
virtual void fireViewportPostUpdate(Viewport* vp);
virtual void fireViewportAdded(Viewport* vp);
virtual void fireViewportRemoved(Viewport* vp);
virtual void updateImpl();
};
} // Namespace
#include "OgreHeaderSuffix.h"
#endif
Ogre::RenderTarget
A &#39;canvas&#39; which can receive the results of a rendering operation.
Definition: OgreRenderTarget.h:65
Ogre::RenderTarget::FrameStats::bestFrameTime
unsigned long bestFrameTime
Definition: OgreRenderTarget.h:85
Ogre::RenderTarget::FrameStats::worstFPS
float worstFPS
Definition: OgreRenderTarget.h:84
Ogre::PF_BYTE_RGBA
4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha ...
Definition: OgrePixelFormat.h:105
Ogre::RenderTarget::RenderTargetListenerList
vector< RenderTargetListener * >::type RenderTargetListenerList
Definition: OgreRenderTarget.h:497
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::RenderTarget::mLastTime
unsigned long mLastTime
Definition: OgreRenderTarget.h:480
Ogre::RenderTarget::mLastSecond
unsigned long mLastSecond
Definition: OgreRenderTarget.h:479
Ogre::RenderTarget::mTimer
Timer * mTimer
Definition: OgreRenderTarget.h:478
Ogre::RenderTarget::setPriority
virtual void setPriority(uchar priority)
Sets the priority of this render target in relation to the others.
Definition: OgreRenderTarget.h:300
Ogre::RenderTarget::mListeners
RenderTargetListenerList mListeners
Definition: OgreRenderTarget.h:498
OgreString.h
Ogre::uchar
unsigned char uchar
In order to avoid finger-aches :)
Definition: OgrePrerequisites.h:112
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::RenderTarget::isHardwareGammaEnabled
virtual bool isHardwareGammaEnabled() const
Indicates whether on rendering, linear colour space is converted to sRGB gamma colour space...
Definition: OgreRenderTarget.h:374
Ogre::RenderTarget::FrameStats::triangleCount
size_t triangleCount
Definition: OgreRenderTarget.h:87
Ogre::Viewport
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
Ogre::Timer
Timer class.
Definition: Android/OgreTimerImp.h:37
Ogre::RenderTarget::mHwGamma
bool mHwGamma
Definition: OgreRenderTarget.h:486
Ogre::RenderTarget::FB_FRONT
Definition: OgreRenderTarget.h:93
Ogre::RenderTarget::FrameStats::avgFPS
float avgFPS
Definition: OgreRenderTarget.h:82
Ogre::RenderTarget::FrameStats::lastFPS
float lastFPS
Definition: OgreRenderTarget.h:81
OgrePrerequisites.h
OgreViewport.h
Ogre::RenderTarget::mFSAAHint
String mFSAAHint
Definition: OgreRenderTarget.h:489
Ogre::RenderTarget::mStats
FrameStats mStats
Definition: OgreRenderTarget.h:476
Ogre::RenderTarget::Impl::~Impl
~Impl()
Definition: OgreRenderTarget.h:390
OgreTextureManager.h
Ogre::RenderTarget::mDepthBuffer
DepthBuffer * mDepthBuffer
Definition: OgreRenderTarget.h:473
Ogre::RenderTarget::FrameBuffer
FrameBuffer
Definition: OgreRenderTarget.h:91
Ogre::RenderTarget::FrameStats::bestFPS
float bestFPS
Definition: OgreRenderTarget.h:83
OgreTimer.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::RenderTarget::suggestPixelFormat
virtual PixelFormat suggestPixelFormat() const
Suggests a pixel format to use for extracting the data in this target, when calling copyContentsToMem...
Definition: OgreRenderTarget.h:339
Ogre::DepthBuffer
An abstract class that contains a depth/stencil buffer.
Definition: OgreDepthBuffer.h:82
Ogre::RenderTarget::FrameStats::batchCount
size_t batchCount
Definition: OgreRenderTarget.h:88
Ogre::RenderTarget::Impl
RenderSystem specific interface for a RenderTarget; this should be subclassed by RenderSystems.
Definition: OgreRenderTarget.h:387
Ogre::RenderTarget::ViewportList
map< int, Viewport * >::type ViewportList
Definition: OgreRenderTarget.h:493
Ogre::RenderTarget::mWidth
uint32 mWidth
Definition: OgreRenderTarget.h:469
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::RenderTarget::swapBuffers
virtual void swapBuffers()
Swaps the frame buffers to display the next frame.
Definition: OgreRenderTarget.h:167
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::RenderTarget::StatFlags
StatFlags
Definition: OgreRenderTarget.h:68
Ogre::RenderTarget::mPriority
uchar mPriority
The priority of the render target.
Definition: OgreRenderTarget.h:467
Ogre::RenderTarget::mViewportList
ViewportList mViewportList
List of viewports, map on Z-order.
Definition: OgreRenderTarget.h:495
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RenderTarget::FB_BACK
Definition: OgreRenderTarget.h:94
Ogre::RenderTarget::getFSAAHint
virtual const String & getFSAAHint() const
Gets the FSAA hint (.
Definition: OgreRenderTarget.h:382
Ogre::RenderTargetListener
A interface class defining a listener which can be used to receive notifications of RenderTarget even...
Definition: OgreRenderTargetListener.h:77
Ogre::RenderTarget::FrameStats
Definition: OgreRenderTarget.h:79
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::PixelBox
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
Definition: OgrePixelFormat.h:304
Ogre::RenderTarget::mFSAA
uint mFSAA
Definition: OgreRenderTarget.h:488
Ogre::RenderTarget::mColourDepth
uint32 mColourDepth
Definition: OgreRenderTarget.h:471
Ogre::RenderTarget::FrameStats::worstFrameTime
unsigned long worstFrameTime
Definition: OgreRenderTarget.h:86
Ogre::RenderTarget::getPriority
virtual uchar getPriority() const
Gets the priority of a render target.
Definition: OgreRenderTarget.h:302
Ogre::RenderTarget::mActive
bool mActive
Definition: OgreRenderTarget.h:483
Ogre::RenderTarget::mAutoUpdate
bool mAutoUpdate
Definition: OgreRenderTarget.h:484
Ogre::uint16
unsigned short uint16
Definition: OgrePlatform.h:360
Ogre::RenderTarget::mDepthBufferPoolId
uint16 mDepthBufferPoolId
Definition: OgreRenderTarget.h:472
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::RenderTarget::mHeight
uint32 mHeight
Definition: OgreRenderTarget.h:470
Ogre::RenderTarget::getFSAA
virtual uint getFSAA() const
Indicates whether multisampling is performed on rendering and at what level.
Definition: OgreRenderTarget.h:378
Ogre::RenderTarget::mName
String mName
The name of this target.
Definition: OgreRenderTarget.h:465
Ogre::RenderTarget::mFrameCount
size_t mFrameCount
Definition: OgreRenderTarget.h:481

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.