1 #ifndef __FRAMEBUFFEROBJECT_H__
2 #define __FRAMEBUFFEROBJECT_H__
5 * Copyright (C) 2005-2013 Team XBMC
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, see
20 * <http://www.gnu.org/licenses/>.
24 #include "system.h" // for HAS_GL
26 #if defined(HAS_GL) || HAS_GLES == 2
27 #include "system_gl.h"
31 // A class that abstracts FBOs to facilitate Render To Texture
33 // Requires OpenGL 1.5+ or the GL_EXT_framebuffer_object extension.
37 // CFrameBufferObject *fbo = new CFrameBufferObject();
39 // fbo->CreateAndBindToTexture(GL_TEXTURE_2D, 256, 256, GL_RGBA);
40 // OR fbo->BindToTexture(GL_TEXTURE_2D, <existing texture ID>);
41 // fbo->BeginRender();
42 // <normal GL rendering calls>
44 // bind and use texture anywhere
45 // glBindTexture(GL_TEXTURE_2D, fbo->Texture());
48 class CFrameBufferObject
54 // returns true if FBO support is detected
57 // returns true if FBO has been initialized
58 bool IsValid() const { return m_valid; }
60 // returns true if FBO has a texture bound to it
61 bool IsBound() const { return m_bound; }
69 // Bind to an exiting texture
70 bool BindToTexture(GLenum target, GLuint texid);
72 // Set texture filtering
73 void SetFiltering(GLenum target, GLenum mode);
75 // Create a new texture and bind to it
76 bool CreateAndBindToTexture(GLenum target, int width, int height, GLenum format,
77 GLenum filter=GL_LINEAR, GLenum clampmode=GL_CLAMP_TO_EDGE);
79 // Return the internally created texture ID
80 GLuint Texture() const { return m_texid; }
82 // Begin rendering to FBO
84 // Finish rendering to FBO
85 void EndRender() const;