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 © 2000-2002 The OGRE Team 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 */ 00025 #ifndef __RenderTarget_H__ 00026 #define __RenderTarget_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 00030 #include "OgreString.h" 00031 #include "OgreTextureManager.h" 00032 #include "OgreViewport.h" 00033 #include "OgreTimer.h" 00034 00035 /* Define the number of priority groups for the render system's render targets. */ 00036 #ifndef OGRE_NUM_RENDERTARGET_GROUPS 00037 #define OGRE_NUM_RENDERTARGET_GROUPS 10 00038 #define OGRE_DEFAULT_RT_GROUP 4 00039 #define OGRE_REND_TO_TEX_RT_GROUP 2 00040 #endif 00041 00042 namespace Ogre { 00043 00055 class _OgreExport RenderTarget 00056 { 00057 public: 00058 enum StatFlags 00059 { 00060 SF_NONE = 0, 00061 SF_FPS = 1, 00062 SF_AVG_FPS = 2, 00063 SF_BEST_FPS = 4, 00064 SF_WORST_FPS = 8, 00065 SF_TRIANGLE_COUNT = 16, 00066 SF_ALL = 0xFFFF 00067 }; 00068 00069 struct FrameStats 00070 { 00071 float lastFPS; 00072 float avgFPS; 00073 float bestFPS; 00074 float worstFPS; 00075 unsigned long bestFrameTime; 00076 unsigned long worstFrameTime; 00077 size_t triangleCount; 00078 }; 00079 00080 RenderTarget(); 00081 virtual ~RenderTarget(); 00082 00084 virtual const String& getName(void) const; 00085 00087 virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth); 00088 00089 virtual unsigned int getWidth(void) const; 00090 virtual unsigned int getHeight(void) const; 00091 virtual unsigned int getColourDepth(void) const; 00092 00106 virtual void update(void); 00107 00131 virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f , 00132 float width = 1.0f, float height = 1.0f); 00133 00135 virtual unsigned short getNumViewports(void) const; 00136 00138 virtual Viewport* getViewport(unsigned short index); 00139 00142 virtual void removeViewport(int ZOrder); 00143 00146 virtual void removeAllViewports(void); 00147 00159 virtual void setStatsDisplay(StatFlags sf); 00160 00179 virtual void getStatistics(float& lastFPS, float& avgFPS, 00180 float& bestFPS, float& worstFPS) const; // Access to stats 00181 00182 virtual const FrameStats& getStatistics(void) const; 00183 00186 virtual float getLastFPS() const; 00187 00190 virtual float getAverageFPS() const; 00191 00194 virtual float getBestFPS() const; 00195 00198 virtual float getWorstFPS() const; 00199 00202 virtual float getBestFrameTime() const; 00203 00206 virtual float getWorstFrameTime() const; 00207 00210 virtual void resetStatistics(void); 00211 00214 virtual void outputText(int x, int y, const String& text) = 0; 00215 00225 virtual void getCustomAttribute(const String& name, void* pData); 00226 00228 virtual void setDebugText(const String& text); 00229 00231 const String& getDebugText() const; 00232 00241 virtual void addListener(RenderTargetListener* listener); 00243 virtual void removeListener(RenderTargetListener* listener); 00245 virtual void removeAllListeners(void); 00246 00254 virtual void setPriority( uchar priority ) { mPriority = priority; } 00256 virtual uchar getPriority() const { return mPriority; } 00257 00260 virtual bool isActive() const; 00261 00264 virtual void setActive( bool state ); 00265 00267 virtual void writeContentsToFile(const String& filename) = 0; 00268 00271 virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix); 00272 00273 virtual bool requiresTextureFlipping() const = 0; 00274 00276 virtual size_t getTriangleCount(void) const; 00277 00278 protected: 00280 String mName; 00282 uchar mPriority; 00283 00284 unsigned int mWidth; 00285 unsigned int mHeight; 00286 unsigned int mColourDepth; 00287 bool mIsDepthBuffered; 00288 00289 // Stats 00290 StatFlags mStatFlags; 00291 FrameStats mStats; 00292 00293 Timer* mTimer ; 00294 String mDebugText; 00295 unsigned long mLastSecond; 00296 unsigned long mLastTime; 00297 size_t mFrameCount; 00298 00299 bool mActive; 00300 00301 void updateStats(void); 00302 00303 typedef std::map<int, Viewport*, std::less<int> > ViewportList; 00305 ViewportList mViewportList; 00306 00307 typedef std::vector<RenderTargetListener*> RenderTargetListenerList; 00308 RenderTargetListenerList mListeners; 00309 00311 virtual void firePreUpdate(void); 00313 virtual void firePostUpdate(void); 00315 virtual void fireViewportPreUpdate(Viewport* vp); 00317 virtual void fireViewportPostUpdate(Viewport* vp); 00318 }; 00319 00320 } // Namespace 00321 00322 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:25 2004