# 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-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __RenderTarget_H__
    00030 #define __RenderTarget_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033
    00034 #include "OgreString.h"
    00035 #include "OgreTextureManager.h"
    00036 #include "OgreViewport.h"
    00037 #include "OgreTimer.h"
    00038
    00039 /* Define the number of priority groups for the render system's render targets. */
    00040 #ifndef OGRE_NUM_RENDERTARGET_GROUPS
    00041     #define OGRE_NUM_RENDERTARGET_GROUPS 10
    00042     #define OGRE_DEFAULT_RT_GROUP 4
    00043     #define OGRE_REND_TO_TEX_RT_GROUP 2
    00044 #endif
    00045
    00046 namespace Ogre {
    00047
    00059     class _OgreExport RenderTarget : public RenderSysAlloc
    00060     {
    00061     public:
    00062         enum StatFlags
    00063         {
    00064             SF_NONE           = 0,
    00065             SF_FPS            = 1,
    00066             SF_AVG_FPS        = 2,
    00067             SF_BEST_FPS       = 4,
    00068             SF_WORST_FPS      = 8,
    00069             SF_TRIANGLE_COUNT = 16,
    00070             SF_ALL            = 0xFFFF
    00071         };
    00072
    00073         struct FrameStats
    00074         {
    00075             float lastFPS;
    00076             float avgFPS;
    00077             float bestFPS;
    00078             float worstFPS;
    00079             unsigned long bestFrameTime;
    00080             unsigned long worstFrameTime;
    00081             size_t triangleCount;
    00082             size_t batchCount;
    00083         };
    00084
    00085         enum FrameBuffer
    00086         {
    00087             FB_FRONT,
    00088             FB_BACK,
    00089             FB_AUTO
    00090         };
    00091
    00092         RenderTarget();
    00093         virtual ~RenderTarget();
    00094
    00096         virtual const String& getName(void) const;
    00097
    00099         virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth);
    00100
    00101         virtual unsigned int getWidth(void) const;
    00102         virtual unsigned int getHeight(void) const;
    00103         virtual unsigned int getColourDepth(void) const;
    00104
    00127         virtual void update(bool swapBuffers = true);
    00148         virtual void swapBuffers(bool waitForVSync = true) {}
    00149
    00173         virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f ,
    00174             float width = 1.0f, float height = 1.0f);
    00175
    00177         virtual unsigned short getNumViewports(void) const;
    00178
    00180         virtual Viewport* getViewport(unsigned short index);
    00181
    00184         virtual void removeViewport(int ZOrder);
    00185
    00188         virtual void removeAllViewports(void);
    00189
    00208         virtual void getStatistics(float& lastFPS, float& avgFPS,
    00209             float& bestFPS, float& worstFPS) const;  // Access to stats
    00210
    00211         virtual const FrameStats& getStatistics(void) const;
    00212
    00215         virtual float getLastFPS() const;
    00216
    00219         virtual float getAverageFPS() const;
    00220
    00223         virtual float getBestFPS() const;
    00224
    00227         virtual float getWorstFPS() const;
    00228
    00231         virtual float getBestFrameTime() const;
    00232
    00235         virtual float getWorstFrameTime() const;
    00236
    00239         virtual void resetStatistics(void);
    00240
    00250         virtual void getCustomAttribute(const String& name, void* pData);
    00251
    00260         virtual void addListener(RenderTargetListener* listener);
    00262         virtual void removeListener(RenderTargetListener* listener);
    00264         virtual void removeAllListeners(void);
    00265
    00273         virtual void setPriority( uchar priority ) { mPriority = priority; }
    00275         virtual uchar getPriority() const { return mPriority; }
    00276
    00279         virtual bool isActive() const;
    00280
    00283         virtual void setActive( bool state );
    00284
    00296         virtual void setAutoUpdated(bool autoupdate);
    00300         virtual bool isAutoUpdated(void) const;
    00301
    00307         virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer = FB_AUTO) = 0;
    00308
    00312         virtual PixelFormat suggestPixelFormat() const { return PF_BYTE_RGBA; }
    00313
    00315         void writeContentsToFile(const String& filename);
    00316
    00319         virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix);
    00320
    00321         virtual bool requiresTextureFlipping() const = 0;
    00322
    00324         virtual size_t getTriangleCount(void) const;
    00326         virtual size_t getBatchCount(void) const;
    00330         virtual void _notifyCameraRemoved(const Camera* cam);
    00331
    00338         virtual bool isPrimary(void) const;
    00339
    00347         virtual bool isHardwareGammaEnabled() const { return mHwGamma; }
    00348
    00351         virtual uint getFSAA() const { return mFSAA; }
    00352
    00353
    00357         class Impl
    00358         {
    00359         protected:
    00365             ~Impl() { };
    00366         };
    00372         virtual Impl *_getImpl();
    00373     protected:
    00375         String mName;
    00377         uchar mPriority;
    00378
    00379         unsigned int mWidth;
    00380         unsigned int mHeight;
    00381         unsigned int mColourDepth;
    00382         bool mIsDepthBuffered;
    00383
    00384         // Stats
    00385         FrameStats mStats;
    00386
    00387         Timer* mTimer ;
    00388         unsigned long mLastSecond;
    00389         unsigned long mLastTime;
    00390         size_t mFrameCount;
    00391
    00392         bool mActive;
    00393         bool mAutoUpdate;
    00394         // Hardware sRGB gamma conversion done on write?
    00395         bool mHwGamma;
    00396         // FSAA performed?
    00397         uint mFSAA;
    00398
    00399         void updateStats(void);
    00400
    00401         typedef std::map<int, Viewport*, std::less<int> > ViewportList;
    00403         ViewportList mViewportList;
    00404
    00405         typedef std::vector<RenderTargetListener*> RenderTargetListenerList;
    00406         RenderTargetListenerList mListeners;
    00407
    00408
    00410         virtual void firePreUpdate(void);
    00412         virtual void firePostUpdate(void);
    00414         virtual void fireViewportPreUpdate(Viewport* vp);
    00416         virtual void fireViewportPostUpdate(Viewport* vp);
    00418         virtual void fireViewportAdded(Viewport* vp);
    00420         virtual void fireViewportRemoved(Viewport* vp);
    00421
    00423         virtual void updateImpl();
    00424     };
    00425
    00426 } // Namespace
    00427
    00428 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 26 11:32:19 2009