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-2013 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 #include "OgreHeaderPrefix.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 00065 class _OgreExport RenderTarget : public RenderSysAlloc 00066 { 00067 public: 00068 enum StatFlags 00069 { 00070 SF_NONE = 0, 00071 SF_FPS = 1, 00072 SF_AVG_FPS = 2, 00073 SF_BEST_FPS = 4, 00074 SF_WORST_FPS = 8, 00075 SF_TRIANGLE_COUNT = 16, 00076 SF_ALL = 0xFFFF 00077 }; 00078 00079 struct FrameStats 00080 { 00081 float lastFPS; 00082 float avgFPS; 00083 float bestFPS; 00084 float worstFPS; 00085 unsigned long bestFrameTime; 00086 unsigned long worstFrameTime; 00087 size_t triangleCount; 00088 size_t batchCount; 00089 }; 00090 00091 enum FrameBuffer 00092 { 00093 FB_FRONT, 00094 FB_BACK, 00095 FB_AUTO 00096 }; 00097 00098 RenderTarget(); 00099 virtual ~RenderTarget(); 00100 00102 virtual const String& getName(void) const; 00103 00105 virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth); 00106 00107 virtual uint32 getWidth(void) const; 00108 virtual uint32 getHeight(void) const; 00109 virtual uint32 getColourDepth(void) const; 00110 00118 void setDepthBufferPool( uint16 poolId ); 00119 00120 //Returns the pool ID this RenderTarget should query from. @see DepthBuffer 00121 uint16 getDepthBufferPool() const; 00122 00123 DepthBuffer* getDepthBuffer() const; 00124 00125 //Returns false if couldn't attach 00126 virtual bool attachDepthBuffer( DepthBuffer *depthBuffer ); 00127 00128 virtual void detachDepthBuffer(); 00129 00134 virtual void _detachDepthBuffer(); 00135 00158 virtual void update(bool swapBuffers = true); 00167 virtual void swapBuffers() {} 00168 00192 virtual Viewport* addViewport(Camera* cam, int ZOrder = 0, float left = 0.0f, float top = 0.0f , 00193 float width = 1.0f, float height = 1.0f); 00194 00196 virtual unsigned short getNumViewports(void) const; 00197 00199 virtual Viewport* getViewport(unsigned short index); 00200 00204 virtual Viewport* getViewportByZOrder(int ZOrder); 00205 00207 virtual bool hasViewportWithZOrder(int ZOrder); 00208 00211 virtual void removeViewport(int ZOrder); 00212 00215 virtual void removeAllViewports(void); 00216 00235 virtual void getStatistics(float& lastFPS, float& avgFPS, 00236 float& bestFPS, float& worstFPS) const; // Access to stats 00237 00238 virtual const FrameStats& getStatistics(void) const; 00239 00242 virtual float getLastFPS() const; 00243 00246 virtual float getAverageFPS() const; 00247 00250 virtual float getBestFPS() const; 00251 00254 virtual float getWorstFPS() const; 00255 00258 virtual float getBestFrameTime() const; 00259 00262 virtual float getWorstFrameTime() const; 00263 00266 virtual void resetStatistics(void); 00267 00277 virtual void getCustomAttribute(const String& name, void* pData); 00278 00287 virtual void addListener(RenderTargetListener* listener); 00289 virtual void removeListener(RenderTargetListener* listener); 00291 virtual void removeAllListeners(void); 00292 00300 virtual void setPriority( uchar priority ) { mPriority = priority; } 00302 virtual uchar getPriority() const { return mPriority; } 00303 00306 virtual bool isActive() const; 00307 00310 virtual void setActive( bool state ); 00311 00323 virtual void setAutoUpdated(bool autoupdate); 00327 virtual bool isAutoUpdated(void) const; 00328 00334 virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer = FB_AUTO) = 0; 00335 00339 virtual PixelFormat suggestPixelFormat() const { return PF_BYTE_RGBA; } 00340 00342 void writeContentsToFile(const String& filename); 00343 00346 virtual String writeContentsToTimestampedFile(const String& filenamePrefix, const String& filenameSuffix); 00347 00348 virtual bool requiresTextureFlipping() const = 0; 00349 00351 virtual size_t getTriangleCount(void) const; 00353 virtual size_t getBatchCount(void) const; 00357 virtual void _notifyCameraRemoved(const Camera* cam); 00358 00365 virtual bool isPrimary(void) const; 00366 00374 virtual bool isHardwareGammaEnabled() const { return mHwGamma; } 00375 00378 virtual uint getFSAA() const { return mFSAA; } 00379 00382 virtual const String& getFSAAHint() const { return mFSAAHint; } 00383 00387 class Impl 00388 { 00389 protected: 00390 ~Impl() { } 00391 }; 00397 virtual Impl *_getImpl(); 00398 00422 virtual void _beginUpdate(); 00423 00433 virtual void _updateViewport(int zorder, bool updateStatistics = true); 00434 00443 virtual void _updateViewport(Viewport* viewport, bool updateStatistics = true); 00444 00453 virtual void _updateAutoUpdatedViewports(bool updateStatistics = true); 00454 00461 virtual void _endUpdate(); 00462 00463 protected: 00465 String mName; 00467 uchar mPriority; 00468 00469 uint32 mWidth; 00470 uint32 mHeight; 00471 uint32 mColourDepth; 00472 uint16 mDepthBufferPoolId; 00473 DepthBuffer *mDepthBuffer; 00474 00475 // Stats 00476 FrameStats mStats; 00477 00478 Timer* mTimer ; 00479 unsigned long mLastSecond; 00480 unsigned long mLastTime; 00481 size_t mFrameCount; 00482 00483 bool mActive; 00484 bool mAutoUpdate; 00485 // Hardware sRGB gamma conversion done on write? 00486 bool mHwGamma; 00487 // FSAA performed? 00488 uint mFSAA; 00489 String mFSAAHint; 00490 00491 void updateStats(void); 00492 00493 typedef map<int, Viewport*>::type ViewportList; 00495 ViewportList mViewportList; 00496 00497 typedef vector<RenderTargetListener*>::type RenderTargetListenerList; 00498 RenderTargetListenerList mListeners; 00499 00500 00502 virtual void firePreUpdate(void); 00504 virtual void firePostUpdate(void); 00506 virtual void fireViewportPreUpdate(Viewport* vp); 00508 virtual void fireViewportPostUpdate(Viewport* vp); 00510 virtual void fireViewportAdded(Viewport* vp); 00512 virtual void fireViewportRemoved(Viewport* vp); 00513 00515 virtual void updateImpl(); 00516 }; 00520 } // Namespace 00521 00522 #include "OgreHeaderSuffix.h" 00523 00524 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:45