OgreRenderTarget.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2009 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef __RenderTarget_H__
00029 #define __RenderTarget_H__
00030 
00031 #include "OgrePrerequisites.h"
00032 
00033 #include "OgreString.h"
00034 #include "OgreTextureManager.h"
00035 #include "OgreViewport.h"
00036 #include "OgreTimer.h"
00037 
00038 /* Define the number of priority groups for the render system's render targets. */
00039 #ifndef OGRE_NUM_RENDERTARGET_GROUPS
00040     #define OGRE_NUM_RENDERTARGET_GROUPS 10
00041     #define OGRE_DEFAULT_RT_GROUP 4
00042     #define OGRE_REND_TO_TEX_RT_GROUP 2
00043 #endif
00044 
00045 namespace Ogre {
00046 
00064     class _OgreExport RenderTarget : public RenderSysAlloc
00065     {
00066     public:
00067         enum StatFlags
00068         {
00069             SF_NONE           = 0,
00070             SF_FPS            = 1,
00071             SF_AVG_FPS        = 2,
00072             SF_BEST_FPS       = 4,
00073             SF_WORST_FPS      = 8,
00074             SF_TRIANGLE_COUNT = 16,
00075             SF_ALL            = 0xFFFF
00076         };
00077 
00078         struct FrameStats
00079         {
00080             float lastFPS;
00081             float avgFPS;
00082             float bestFPS;
00083             float worstFPS;
00084             unsigned long bestFrameTime;
00085             unsigned long worstFrameTime;
00086             size_t triangleCount;
00087             size_t batchCount;
00088         };
00089 
00090         enum FrameBuffer
00091         {
00092             FB_FRONT,
00093             FB_BACK,
00094             FB_AUTO
00095         };
00096 
00097         RenderTarget();
00098         virtual ~RenderTarget();
00099 
00101         virtual const String& getName(void) const;
00102 
00104         virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth);
00105 
00106         virtual unsigned int getWidth(void) const;
00107         virtual unsigned int getHeight(void) const;
00108         virtual unsigned int getColourDepth(void) const;
00109 
00132         virtual void update(bool swapBuffers = true);
00153         virtual void swapBuffers(bool waitForVSync = true)
00154         { (void)waitForVSync; }
00155 
00179         virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f ,
00180             float width = 1.0f, float height = 1.0f);
00181 
00183         virtual unsigned short getNumViewports(void) const;
00184 
00186         virtual Viewport* getViewport(unsigned short index);
00187 
00190         virtual void removeViewport(int ZOrder);
00191 
00194         virtual void removeAllViewports(void);
00195 
00214         virtual void getStatistics(float& lastFPS, float& avgFPS,
00215             float& bestFPS, float& worstFPS) const;  // Access to stats
00216 
00217         virtual const FrameStats& getStatistics(void) const;
00218 
00221         virtual float getLastFPS() const;
00222 
00225         virtual float getAverageFPS() const;
00226 
00229         virtual float getBestFPS() const;
00230 
00233         virtual float getWorstFPS() const;
00234 
00237         virtual float getBestFrameTime() const;
00238 
00241         virtual float getWorstFrameTime() const;
00242 
00245         virtual void resetStatistics(void);
00246 
00256         virtual void getCustomAttribute(const String& name, void* pData);
00257 
00266         virtual void addListener(RenderTargetListener* listener);
00268         virtual void removeListener(RenderTargetListener* listener);
00270         virtual void removeAllListeners(void);
00271 
00279         virtual void setPriority( uchar priority ) { mPriority = priority; }
00281         virtual uchar getPriority() const { return mPriority; }
00282 
00285         virtual bool isActive() const;
00286 
00289         virtual void setActive( bool state );
00290 
00302         virtual void setAutoUpdated(bool autoupdate);
00306         virtual bool isAutoUpdated(void) const;
00307 
00313         virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer = FB_AUTO) = 0;
00314 
00318         virtual PixelFormat suggestPixelFormat() const { return PF_BYTE_RGBA; }
00319         
00321         void writeContentsToFile(const String& filename);
00322 
00325         virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix);
00326 
00327         virtual bool requiresTextureFlipping() const = 0;
00328 
00330         virtual size_t getTriangleCount(void) const;
00332         virtual size_t getBatchCount(void) const;
00336         virtual void _notifyCameraRemoved(const Camera* cam);
00337 
00344         virtual bool isPrimary(void) const;
00345 
00353         virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
00354 
00357         virtual uint getFSAA() const { return mFSAA; }
00358 
00361         virtual const String& getFSAAHint() const { return mFSAAHint; }
00362 
00366         class Impl
00367         {
00368         protected:
00369             ~Impl() { }
00370         };
00376         virtual Impl *_getImpl();
00377 
00401         virtual void _beginUpdate();
00402 
00412         virtual void _updateViewport(int zorder, bool updateStatistics = true);
00413 
00422         virtual void _updateViewport(Viewport* viewport, bool updateStatistics = true);
00423 
00432         virtual void _updateAutoUpdatedViewports(bool updateStatistics = true);
00433         
00440         virtual void _endUpdate();
00441 
00442     protected:
00444         String mName;
00446         uchar mPriority;
00447 
00448         unsigned int mWidth;
00449         unsigned int mHeight;
00450         unsigned int mColourDepth;
00451         bool mIsDepthBuffered;
00452 
00453         // Stats
00454         FrameStats mStats;
00455         
00456         Timer* mTimer ;
00457         unsigned long mLastSecond;
00458         unsigned long mLastTime;
00459         size_t mFrameCount;
00460 
00461         bool mActive;
00462         bool mAutoUpdate;
00463         // Hardware sRGB gamma conversion done on write?
00464         bool mHwGamma;
00465         // FSAA performed?
00466         uint mFSAA;
00467         String mFSAAHint;
00468 
00469         void updateStats(void);
00470 
00471         typedef map<int, Viewport*>::type ViewportList;
00473         ViewportList mViewportList;
00474 
00475         typedef vector<RenderTargetListener*>::type RenderTargetListenerList;
00476         RenderTargetListenerList mListeners;
00477     
00478 
00480         virtual void firePreUpdate(void);
00482         virtual void firePostUpdate(void);
00484         virtual void fireViewportPreUpdate(Viewport* vp);
00486         virtual void fireViewportPostUpdate(Viewport* vp);
00488         virtual void fireViewportAdded(Viewport* vp);
00490         virtual void fireViewportRemoved(Viewport* vp);
00491         
00493         virtual void updateImpl();
00494     };
00498 } // Namespace
00499 
00500 #endif

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52