X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fframebuffer.cpp;h=43b0f94b82e4c882327ef686491453a1bc7cf263;hp=c4f714c64b7768e74989602ac023ce3e14655159;hb=6afbace895a7bbcf216ab8e48280ea0303ab5892;hpb=485315ca65cb40f33253008a79b0933997bd74f5 diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index c4f714c6..43b0f94b 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -1,5 +1,4 @@ #include "error.h" -#include "extension.h" #include "ext_framebuffer_blit.h" #include "ext_framebuffer_object.h" #include "framebuffer.h" @@ -30,15 +29,15 @@ Framebuffer::Framebuffer(): height(0), dirty(0) { - static RequireExtension _ext("GL_EXT_framebuffer_object"); + static Require _req(EXT_framebuffer_object); - glGenFramebuffersEXT(1, &id); + glGenFramebuffers(1, &id); } Framebuffer::~Framebuffer() { if(id) - glDeleteFramebuffersEXT(1, &id); + glDeleteFramebuffers(1, &id); if(current()==this) unbind(); } @@ -53,20 +52,20 @@ void Framebuffer::update_attachment(unsigned mask) const const Attachment &attch = attachments[i]; if(mask&(1<get_id()); + if(attch.type==GL_RENDERBUFFER) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, attch.attachment, GL_RENDERBUFFER, attch.rbuf->get_id()); else if(attch.type==GL_TEXTURE_2D) { static_cast(attch.tex)->allocate(attch.level); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch.attachment, attch.type, attch.tex->get_id(), attch.level); + glFramebufferTexture2D(GL_FRAMEBUFFER, attch.attachment, attch.type, attch.tex->get_id(), attch.level); } else if(attch.type==GL_TEXTURE_CUBE_MAP) { static_cast(attch.tex)->allocate(attch.level); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attch.attachment, attch.cube_face, attch.tex->get_id(), attch.level); + glFramebufferTexture2D(GL_FRAMEBUFFER, attch.attachment, attch.cube_face, attch.tex->get_id(), attch.level); } else - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attch.attachment, 0, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, attch.attachment, 0, 0); } if(attch.attachment>=COLOR_ATTACHMENT0 && attch.attachment<=COLOR_ATTACHMENT3) @@ -84,7 +83,7 @@ void Framebuffer::check_size() for(vector::iterator i=attachments.begin(); i!=attachments.end(); ++i) if(i->type) { - if(i->type==GL_RENDERBUFFER_EXT) + if(i->type==GL_RENDERBUFFER) { width = i->rbuf->get_width(); height = i->rbuf->get_height(); @@ -162,7 +161,7 @@ void Framebuffer::detach(FramebufferAttachment attch) FramebufferStatus Framebuffer::check_status() const { Bind _bind(this, true); - return static_cast(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); + return static_cast(glCheckFramebufferStatus(GL_FRAMEBUFFER)); } void Framebuffer::clear(BufferBits bits) @@ -173,12 +172,12 @@ void Framebuffer::clear(BufferBits bits) void Framebuffer::blit_from(const Framebuffer &other, int sx0, int sy0, int sx1, int sy1, int dx0, int dy0, int dx1, int dy1, BufferBits bits, bool filter) { - static RequireExtension _ext("GL_EXT_framebuffer_blit"); + static Require _req(EXT_framebuffer_blit); const Framebuffer *old = current(); if(set_current(this)) { - glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, id); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, id); if(dirty) { update_attachment(dirty); @@ -186,12 +185,12 @@ void Framebuffer::blit_from(const Framebuffer &other, int sx0, int sy0, int sx1, } } if(old!=&other) - glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, other.id); + glBindFramebuffer(GL_READ_FRAMEBUFFER, other.id); - glBlitFramebufferEXT(sx0, sy0, sx1, sy1, dx0, dy0, dx1, dy1, bits, (filter ? GL_LINEAR : GL_NEAREST)); + glBlitFramebuffer(sx0, sy0, sx1, sy1, dx0, dy0, dx1, dy1, bits, (filter ? GL_LINEAR : GL_NEAREST)); set_current(old); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, (old ? old->id : 0)); + glBindFramebuffer(GL_FRAMEBUFFER, (old ? old->id : 0)); } void Framebuffer::blit_from(const Framebuffer &other, int sx, int sy, unsigned wd, unsigned ht, int dx, int dy, BufferBits bits) @@ -208,7 +207,7 @@ void Framebuffer::bind() const { if(set_current(this)) { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id); + glBindFramebuffer(GL_FRAMEBUFFER, id); if(dirty) { update_attachment(dirty); @@ -246,7 +245,7 @@ Framebuffer::Attachment::Attachment(FramebufferAttachment a): void Framebuffer::Attachment::set(Renderbuffer &r) { - type = GL_RENDERBUFFER_EXT; + type = GL_RENDERBUFFER; rbuf = &r; level = 0; }