Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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);
00093         void releaseRenderBuffer(const GLSurfaceDesc &surface);
00094         
00097         bool checkFormat(PixelFormat format) { return mProps[format].valid; }
00098         
00101         GLuint getTemporaryFBO() { return mTempFBO; }
00102     private:
00105         struct FormatProperties
00106         {
00107             bool valid; // This format can be used as RTT (FBO)
00108             
00111             struct Mode
00112             {
00113                 size_t depth;     // Depth format (0=no depth)
00114                 size_t stencil;   // Stencil format (0=no stencil)
00115             };
00116             
00117             std::vector<Mode> modes;
00118         };
00121         FormatProperties mProps[PF_COUNT];
00122         
00127         struct RBFormat
00128         {
00129             RBFormat(GLenum format, size_t width, size_t height):
00130                 format(format), width(width), height(height)
00131             {}
00132             GLenum format;
00133             size_t width;
00134             size_t height;
00135             // Overloaded comparison operator for usage in map
00136             bool operator < (const RBFormat &other) const
00137             {
00138                 if(format < other.format)
00139                 {
00140                     return true;
00141                 }
00142                 else if(format == other.format)
00143                 {
00144                     if(width < other.width)
00145                     {
00146                         return true;
00147                     }
00148                     else if(width == other.width)
00149                     {
00150                         if(height < other.height)
00151                             return true;
00152                     }
00153                 }
00154                 return false;
00155             }
00156         };
00157         struct RBRef
00158         {
00159             RBRef(){}
00160             RBRef(GLRenderBuffer *buffer):
00161                 buffer(buffer), refcount(1)
00162             { }
00163             GLRenderBuffer *buffer;
00164             size_t refcount;
00165         };
00166         typedef std::map<RBFormat, RBRef> RenderBufferMap;
00167         RenderBufferMap mRenderBufferMap;
00168         // map(format, sizex, sizey) -> [GLSurface*,refcount]
00169         
00172         GLuint mTempFBO;
00173         
00175         bool mATIMode;
00176         
00178         void detectFBOFormats();
00179         GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat);
00180     };
00181     
00182 
00183 }
00184 
00185 #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 Mar 12 14:37:41 2006