/* QGLView Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef GLFRAMEBUFFER_H #define GLFRAMEBUFFER_H #include "gltypes.h" class GLFramebuffer { public: GLFramebuffer(int colorAttachments = 1, bool withDepth = true, GLenum colorFormat = GL_RGBA8, GLenum target = GL_TEXTURE_2D); virtual ~GLFramebuffer(); GLuint id() const {return fbo;} GLuint colorTexture(int index = 0) const {return colors[index];} GLenum colorFormat() const {return color_format;} GLuint depthTexture() const {return tex_d;} GLenum target() const {return target_;} int width() const {return wid;} int height() const {return hei;} QSize size() const {return QSize(wid, hei);} void resize(int width, int height); void bind(); void release(); void setReadBuffer(int index) {glReadBuffer(GL_COLOR_ATTACHMENT0 + index);} void setWriteBuffer(int index) {glDrawBuffer(GL_COLOR_ATTACHMENT0 + index);} void setWriteBuffers(int indeces[]); void setWriteBuffers(int * indeces, int count); void setColorFormat(GLenum format) {color_format = format; is_changed = true;} void copyDepthFrom(GLuint tex) {;} void bindColorTextures(); void bindDepthTexture(int channel); private: bool is_depth, is_changed; QVector colors; GLenum color_format, target_; GLuint fbo, drbo, tex_d; GLint prev_view[4], wid, hei; }; #endif // GLFRAMEBUFFER_H