gl_framebuffer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Kutumov Alexey                                  *
00003  *   ru.pixel@gmail.com                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00033 #ifndef __gl_framebuffer__header__
00034 #define __gl_framebuffer__header__
00035 
00036 #include "gpucalc/framebuffer.h"
00037 #include <GL/glew.h>
00038 
00039 #include "gpucalc/log_manager.h"
00040 
00041 namespace gpucalc
00042 {
00105  class GLTexture;
00106  class GLGraphicCore;
00107  
00108  
00109  const char _GLFrameBufferClassName [] = "GLFrameBuffer";
00110  
00111  
00112  class _GpuCalcPrivate GLFrameBuffer: public FrameBuffer
00113  {
00114 
00115   OBJ_DISABLE_COPY(GLFrameBuffer)
00116 
00117 
00118   friend class GLGraphicCore;
00119 
00120 
00121   public:
00122    ~GLFrameBuffer()
00123    {
00124     glDeleteFramebuffersEXT(1, &mGLFrameBufferID);
00125     LogManager::getSingleton().logMessage(this, "FrameBuffer ID deleted for OpenGL memory.", LML_Normal);
00126    }
00127  
00128 
00129    void initialize();
00130 
00131 
00135    void attach(const Texture * texture);
00136 
00137 
00141    void detach(const Texture * texture);
00142 
00143 
00147    void drawBuffer(const Texture * RenderTarget);
00148 
00149 
00153    void getData(Data & data, const Texture * from);
00154 
00155 
00156    void checkErrors(const std::string & where);
00157 
00158 
00159   private:
00160    GLuint mGLFrameBufferID;
00161 
00162 
00163    GLint mGLFrameBufferWidth;
00164 
00165 
00166    GLint mGLFrameBufferHeight;
00167 
00168 
00169    GLenum mGLFrameBufferFormat;
00170 
00171 
00172    GLenum mGLFrameBufferType;
00173 
00174 
00175    GLint mMaxNumberOfAttachment;
00176 
00177 
00178    typedef std::vector<const Texture *> AttachmentList;
00179 
00180 
00181    AttachmentList mAttachmentList;
00182 
00183 
00184    GLFrameBuffer(const std::string & FrameBufferName, GLint MaxNumberOfAttachments, GraphicCore * DefaultGLGraphicCore):
00185     Object(_GLFrameBufferClassName, FrameBufferName), FrameBuffer(_GLFrameBufferClassName, FrameBufferName, DefaultGLGraphicCore),
00186     mGLFrameBufferID(0), mGLFrameBufferWidth(0), mGLFrameBufferHeight(0), mGLFrameBufferFormat(0), mGLFrameBufferType(0),
00187     mMaxNumberOfAttachment(MaxNumberOfAttachments), mAttachmentList(MaxNumberOfAttachments)
00188    {
00189    }
00190 
00191 
00192    GLint getFirstFreeAttachment() const;
00193 
00194 
00195    GLint getIndexByTexture(const Texture * texture) const;
00196 
00197 
00198    GLint getIndexByTextureName(const std::string & TextureName) const;
00199  };
00200 }
00201 
00202 #endif

Generated on Thu Mar 5 22:36:42 2009 for gpucalc by  doxygen 1.5.6