3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
9 #include "ext_framebuffer_object.h"
10 #include "framebuffer.h"
11 #include "renderbuffer.h"
12 #include "texture2d.h"
17 Framebuffer::Framebuffer()
19 static RequireExtension _ext("GL_EXT_framebuffer_object");
21 glGenFramebuffersEXT(1, &id);
25 Framebuffer::~Framebuffer()
27 glDeleteFramebuffersEXT(1, &id);
30 void Framebuffer::bind() const
32 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id);
36 void Framebuffer::attach(FramebufferAttachment attch, Renderbuffer &rbuf)
39 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attch, GL_RENDERBUFFER_EXT, rbuf.get_id());
42 void Framebuffer::attach(FramebufferAttachment attch, Texture2D &tex, int level)
45 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch, tex.get_target(), tex.get_id(), level);
48 FramebufferStatus Framebuffer::check_status() const
51 return static_cast<FramebufferStatus>(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
54 const Framebuffer *Framebuffer::current()
59 void Framebuffer::unbind()
63 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
68 void Framebuffer::maybe_bind() const
74 const Framebuffer *Framebuffer::cur_fbo=0;