# HG changeset patch # User John Tsiombikas # Date 1428933112 -10800 # Node ID eea1b91dc3d45019ade41a7b5b5393aadde2c46a # Parent 65c2e37c48b2211fc56cb3c8923ac2a7bac28100 added is_complete() to framebuffer object and fixed GL_UNSUPPORTED_FRAMEBUFFER on intel diff -r 65c2e37c48b2 -r eea1b91dc3d4 src/rtarg.cc --- a/src/rtarg.cc Sun Apr 12 03:39:55 2015 +0300 +++ b/src/rtarg.cc Mon Apr 13 16:51:52 2015 +0300 @@ -1,3 +1,4 @@ +#include #include "opengl.h" #include "rtarg.h" @@ -26,7 +27,7 @@ tex_xsz = next_pow2(xsz); tex_ysz = next_pow2(ysz); - tex_fmt = check_extension("GL_ARB_texture_float") ? GL_RGB16F : GL_RGB; + tex_fmt = check_extension("GL_ARB_texture_float") ? GL_RGBA16F : GL_RGBA; glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); @@ -35,7 +36,7 @@ glBindTexture(GL_TEXTURE_2D, color); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, tex_fmt, tex_xsz, tex_ysz, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); + glTexImage2D(GL_TEXTURE_2D, 0, tex_fmt, tex_xsz, tex_ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color, 0); glGenRenderbuffers(1, &depth); @@ -43,6 +44,10 @@ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, tex_xsz, tex_ysz); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); + if(!is_complete()) { + fprintf(stderr, "framebuffer incomplete\n"); + } + return true; } @@ -66,6 +71,10 @@ tex_xsz = new_tex_xsz; tex_ysz = new_tex_ysz; + + if(!is_complete()) { + fprintf(stderr, "framebuffer incomplete\n"); + } } return true; } @@ -89,6 +98,20 @@ return fbo != 0; } +bool RenderTarget::is_complete() const +{ + if(!fbo) return false; + + unsigned int prev_fbo; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (int*)&prev_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if(prev_fbo != fbo) { + glBindFramebuffer(GL_FRAMEBUFFER, prev_fbo); + } + return status == GL_FRAMEBUFFER_COMPLETE; +} + unsigned int RenderTarget::get_texture() const { return color; diff -r 65c2e37c48b2 -r eea1b91dc3d4 src/rtarg.h --- a/src/rtarg.h Sun Apr 12 03:39:55 2015 +0300 +++ b/src/rtarg.h Mon Apr 13 16:51:52 2015 +0300 @@ -17,6 +17,7 @@ void destroy(); bool is_valid() const; + bool is_complete() const; unsigned int get_texture() const;