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 __OgreGLFBORTT_H__ 00029 #define __OgreGLFBORTT_H__ 00030 00031 #include "OgreGLRenderTexture.h" 00032 #include "OgreGLContext.h" 00033 #include "OgreGLFrameBufferObject.h" 00034 00036 #define GL_DEPTH24_STENCIL8_EXT 0x88F0 00037 00038 00039 namespace Ogre { 00040 class GLFBOManager; 00041 00044 class _OgreGLExport GLFBORenderTexture: public GLRenderTexture 00045 { 00046 public: 00047 GLFBORenderTexture(GLFBOManager *manager, const String &name, const GLSurfaceDesc &target, bool writeGamma, uint fsaa); 00048 00049 virtual void getCustomAttribute(const String& name, void* pData); 00050 00052 virtual void swapBuffers(); 00053 00055 virtual bool attachDepthBuffer( DepthBuffer *depthBuffer ); 00056 virtual void detachDepthBuffer(); 00057 virtual void _detachDepthBuffer(); 00058 protected: 00059 GLFrameBufferObject mFB; 00060 }; 00061 00064 class _OgreGLExport GLFBOManager: public GLRTTManager 00065 { 00066 public: 00067 GLFBOManager(bool atimode); 00068 ~GLFBOManager(); 00069 00073 void bind(RenderTarget *target); 00074 00077 void unbind(RenderTarget *target) {}; 00078 00081 void getBestDepthStencil(GLenum internalFormat, GLenum *depthFormat, GLenum *stencilFormat); 00082 00085 virtual GLFBORenderTexture *createRenderTexture(const String &name, 00086 const GLSurfaceDesc &target, bool writeGamma, uint fsaa); 00087 00090 virtual MultiRenderTarget* createMultiRenderTarget(const String & name); 00091 00094 GLSurfaceDesc requestRenderBuffer(GLenum format, uint32 width, uint32 height, uint fsaa); 00098 void requestRenderBuffer(const GLSurfaceDesc &surface); 00101 void releaseRenderBuffer(const GLSurfaceDesc &surface); 00102 00105 bool checkFormat(PixelFormat format) { return mProps[format].valid; } 00106 00109 GLuint getTemporaryFBO() { return mTempFBO; } 00110 private: 00113 struct FormatProperties 00114 { 00115 bool valid; // This format can be used as RTT (FBO) 00116 00119 struct Mode 00120 { 00121 size_t depth; // Depth format (0=no depth) 00122 size_t stencil; // Stencil format (0=no stencil) 00123 }; 00124 00125 vector<Mode>::type modes; 00126 }; 00129 FormatProperties mProps[PF_COUNT]; 00130 00135 struct RBFormat 00136 { 00137 RBFormat(GLenum inFormat, size_t inWidth, size_t inHeight, uint fsaa): 00138 format(inFormat), width(inWidth), height(inHeight), samples(fsaa) 00139 {} 00140 RBFormat() {} 00141 GLenum format; 00142 size_t width; 00143 size_t height; 00144 uint samples; 00145 // Overloaded comparison operator for usage in map 00146 bool operator < (const RBFormat &other) const 00147 { 00148 if(format < other.format) 00149 { 00150 return true; 00151 } 00152 else if(format == other.format) 00153 { 00154 if(width < other.width) 00155 { 00156 return true; 00157 } 00158 else if(width == other.width) 00159 { 00160 if(height < other.height) 00161 return true; 00162 else if (height == other.height) 00163 { 00164 if (samples < other.samples) 00165 return true; 00166 } 00167 } 00168 } 00169 return false; 00170 } 00171 }; 00172 struct RBRef 00173 { 00174 RBRef(){} 00175 RBRef(GLRenderBuffer *inBuffer): 00176 buffer(inBuffer), refcount(1) 00177 { } 00178 GLRenderBuffer *buffer; 00179 size_t refcount; 00180 }; 00181 typedef map<RBFormat, RBRef>::type RenderBufferMap; 00182 RenderBufferMap mRenderBufferMap; 00183 // map(format, sizex, sizey) -> [GLSurface*,refcount] 00184 00187 GLuint mTempFBO; 00188 00190 bool mATIMode; 00191 00193 void detectFBOFormats(); 00194 GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat); 00195 bool _tryPackedFormat(GLenum packedFormat); 00196 void _createTempFramebuffer(GLuint fmt, GLuint &fb, GLuint &tid); 00197 }; 00198 00199 00200 } 00201 00202 #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:42