Back to index

nux  3.0.0
GLDeviceFrameBufferObject.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef GLDEVICEFRAMEBUFFEROBJECT_H
00024 #define GLDEVICEFRAMEBUFFEROBJECT_H
00025 
00082 namespace nux
00083 {
00084 
00085   class GLFramebufferObject
00086   {
00087   public:
00089     GLFramebufferObject();
00090     virtual ~GLFramebufferObject();
00091 
00093     void Bind();
00094 
00096     virtual void AttachTexture( GLenum attachment, GLenum texType, GLuint texId,
00097                                  int mipLevel = 0, int zSlice = 0);
00098 
00102     virtual void AttachTextures( int numTextures,
00103                                   GLenum texTarget[],
00104                                   GLuint texId[],
00105                                   GLenum attachment[] = NULL,
00106                                   int mipLevel[]      = NULL,
00107                                   int zSlice[]        = NULL );
00108 
00110     virtual void AttachRenderBuffer( GLenum attachment, GLuint buffId );
00111 
00113     void Unattach( GLenum attachment );
00114 
00122     bool IsValid();
00123 
00124 
00127     GLenum GetAttachedType( GLenum attachment );
00128 
00131     GLuint GetAttachedId( GLenum attachment );
00132 
00134     GLint  GetAttachedMipLevel( GLenum attachment );
00135 
00137     GLint  GetAttachedCubeFace( GLenum attachment );
00138 
00140     GLint  GetAttachedZSlice( GLenum attachment );
00142 
00143 
00146     static int GetMaxColorAttachments();
00147 
00156     static void Disable();
00158 
00159   private:
00160     GLint m_fboId;
00161     GLint  m_savedFboId;
00162 
00163     void  _GuardedBind();
00164     void  _GuardedUnbind();
00165     void  _FramebufferTextureND( GLenum attachment, GLenum texType,
00166                                   GLuint texId, int mipLevel, int zSlice );
00167     static GLuint _GenerateFboId();
00168   };
00169 
00200   class GLRenderbuffer
00201   {
00202   public:
00204     GLRenderbuffer();
00205     GLRenderbuffer(GLenum internalFormat, int width, int height);
00206     ~GLRenderbuffer();
00207 
00208     void   Bind();
00209     void   Unbind();
00210     void   Set(GLenum internalFormat, int width, int height);
00211     GLuint GetId() const;
00212 
00213     static GLint GetMaxSize();
00214 
00215   private:
00216     GLuint m_bufId;
00217 
00218     static GLuint _CreateBufferId();
00219   };
00220 
00221 }
00222 
00223 #endif // GLDEVICEFRAMEBUFFEROBJECT_H
00224 
00225