From ebc2a4269e195aa073078addff727a15f6b3f12d Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 2 Aug 2013 10:34:23 +0200 Subject: [PATCH] Modified way of handling OpenGL framebuffer errors. Now it is more verbose and the status is checked at the right moment (previously it was fine with Linux, but on Windows it showed errors). --- common/gal/opengl/opengl_compositor.cpp | 59 +++++++++++++++++++++---- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/common/gal/opengl/opengl_compositor.cpp b/common/gal/opengl/opengl_compositor.cpp index 91b757cb98..9357d8dbbe 100644 --- a/common/gal/opengl/opengl_compositor.cpp +++ b/common/gal/opengl/opengl_compositor.cpp @@ -73,14 +73,6 @@ void OPENGL_COMPOSITOR::Initialize() glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer ); - // Check the status, exit if the framebuffer can't be created - GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER ); - - if( status != GL_FRAMEBUFFER_COMPLETE ) - { - wxLogFatalError( wxT( "Cannot create the framebuffer." ) ); - } - // Unbind the framebuffer, so by default all the rendering goes directly to the display glBindFramebuffer( GL_FRAMEBUFFER, 0 ); m_currentFbo = 0; @@ -125,6 +117,57 @@ unsigned int OPENGL_COMPOSITOR::GetBuffer() glBindFramebuffer( GL_FRAMEBUFFER, m_framebuffer ); m_currentFbo = m_framebuffer; glFramebufferTexture2D( GL_FRAMEBUFFER, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 ); + + // Check the status, exit if the framebuffer can't be created + GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER ); + + if( status != GL_FRAMEBUFFER_COMPLETE ) + { + switch( status ) + { + case GL_FRAMEBUFFER_UNDEFINED: + wxLogFatalError( wxT( "Target is the default framebuffer, " + "but the default framebuffer does not exist." ) ); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + wxLogFatalError( wxT( "Cannot create the framebuffer." ) ); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + wxLogFatalError( wxT( "The framebuffer attachment points are incomplete." ) ); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: + wxLogFatalError( wxT( "The framebuffer does not have at least " + "one image attached to it." ) ); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: + wxLogFatalError( wxT( "The framebuffer read buffer is incomplete." ) ); + break; + + case GL_FRAMEBUFFER_UNSUPPORTED: + wxLogFatalError( wxT( "The combination of internal formats of the attached images " + "violates an implementation-dependent set of restrictions." ) ); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + wxLogFatalError( wxT( "GL_RENDERBUFFER_SAMPLES is not the same " + "for all attached renderbuffers" ) ); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: + wxLogFatalError( wxT( "Framebuffer incomplete layer targets errors." ) ); + break; + + default: + wxLogFatalError( wxT( "Cannot create the framebuffer." ) ); + break; + } + } + + ClearBuffer(); glBindFramebuffer( GL_FRAMEBUFFER, 0 ); m_currentFbo = 0;