Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OgreGLFBORenderTexture.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-2005 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 __OgreGLFBORTT_H__
00026 #define __OgreGLFBORTT_H__
00027 
00028 #include "OgreGLRenderTexture.h"
00029 #include "OgreGLContext.h"
00030 #include "OgreGLFrameBufferObject.h"
00031 
00033 #define GL_DEPTH24_STENCIL8_EXT                           0x88F0
00034 
00035 
00036 namespace Ogre {
00037     class GLFBOManager;
00038 
00041     class GLFBORenderTexture: public GLRenderTexture
00042     {
00043     public:
00044         GLFBORenderTexture(GLFBOManager *manager, const String &name, const GLSurfaceDesc &target);
00045 
00046         virtual void getCustomAttribute(const String& name, void* pData);
00047     protected:
00048         GLFrameBufferObject mFB;
00049     };
00050     
00053     class GLFBOManager: public GLRTTManager
00054     {
00055     public:
00056         GLFBOManager(bool atimode);
00057         ~GLFBOManager();
00058         
00062         void bind(RenderTarget *target);
00063         
00066         void unbind(RenderTarget *target) {};
00067         
00070         void getBestDepthStencil(GLenum internalFormat, GLenum *depthFormat, GLenum *stencilFormat);
00071         
00074         virtual GLFBORenderTexture *createRenderTexture(const String &name, const GLSurfaceDesc &target);
00075 
00078         virtual MultiRenderTarget* createMultiRenderTarget(const String & name);
00079         
00082         GLFrameBufferObject *createFrameBufferObject();
00083         
00086         void destroyFrameBufferObject(GLFrameBufferObject *);
00087         
00090         GLSurfaceDesc requestRenderBuffer(GLenum format, size_t width, size_t height);
00094         void requestRenderBuffer(const GLSurfaceDesc &surface);
00097         void releaseRenderBuffer(const GLSurfaceDesc &surface);
00098         
00101         bool checkFormat(PixelFormat format) { return mProps[format].valid; }
00102         
00105         GLuint getTemporaryFBO() { return mTempFBO; }
00106     private:
00109         struct FormatProperties
00110         {
00111             bool valid; // This format can be used as RTT (FBO)
00112             
00115             struct Mode
00116             {
00117                 size_t depth;     // Depth format (0=no depth)
00118                 size_t stencil;   // Stencil format (0=no stencil)
00119             };
00120             
00121             std::vector<Mode> modes;
00122         };
00125         FormatProperties mProps[PF_COUNT];
00126         
00131         struct RBFormat
00132         {
00133             RBFormat(GLenum format, size_t width, size_t height):
00134                 format(format), width(width), height(height)
00135             {}
00136             GLenum format;
00137             size_t width;
00138             size_t height;
00139             // Overloaded comparison operator for usage in map
00140             bool operator < (const RBFormat &other) const
00141             {
00142                 if(format < other.format)
00143                 {
00144                     return true;
00145                 }
00146                 else if(format == other.format)
00147                 {
00148                     if(width < other.width)
00149                     {
00150                         return true;
00151                     }
00152                     else if(width == other.width)
00153                     {
00154                         if(height < other.height)
00155                             return true;
00156                     }
00157                 }
00158                 return false;
00159             }
00160         };
00161         struct RBRef
00162         {
00163             RBRef(){}
00164             RBRef(GLRenderBuffer *buffer):
00165                 buffer(buffer), refcount(1)
00166             { }
00167             GLRenderBuffer *buffer;
00168             size_t refcount;
00169         };
00170         typedef std::map<RBFormat, RBRef> RenderBufferMap;
00171         RenderBufferMap mRenderBufferMap;
00172         // map(format, sizex, sizey) -> [GLSurface*,refcount]
00173         
00176         GLuint mTempFBO;
00177         
00179         bool mATIMode;
00180         
00182         void detectFBOFormats();
00183         GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat);
00184         bool _tryPackedFormat(GLenum packedFormat);
00185     };
00186     
00187 
00188 }
00189 
00190 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Nov 12 10:50:10 2006