diff --git a/Outputs/OpenGL/Primitives/TextureTarget.cpp b/Outputs/OpenGL/Primitives/TextureTarget.cpp index 4c492170c..21d0f093a 100644 --- a/Outputs/OpenGL/Primitives/TextureTarget.cpp +++ b/Outputs/OpenGL/Primitives/TextureTarget.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace Outputs::Display::OpenGL; @@ -48,8 +49,23 @@ TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit, } // Check for successful construction. - if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) - throw ErrorFramebufferIncomplete; + const auto framebuffer_status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if(framebuffer_status != GL_FRAMEBUFFER_COMPLETE) { + switch(framebuffer_status) { + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + throw std::runtime_error("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"); + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: + throw std::runtime_error("GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"); + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: + throw std::runtime_error("GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"); + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + throw std::runtime_error("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"); + case GL_FRAMEBUFFER_UNSUPPORTED: + throw std::runtime_error("GL_FRAMEBUFFER_UNSUPPORTED"); + default: + throw std::runtime_error("Framebuffer status incomplete; " + std::to_string(framebuffer_status)); + } + } } TextureTarget::~TextureTarget() { diff --git a/Outputs/OpenGL/Primitives/TextureTarget.hpp b/Outputs/OpenGL/Primitives/TextureTarget.hpp index 2a3a9a930..59fd42d51 100644 --- a/Outputs/OpenGL/Primitives/TextureTarget.hpp +++ b/Outputs/OpenGL/Primitives/TextureTarget.hpp @@ -26,7 +26,9 @@ class TextureTarget { /*! Creates a new texture target. Contents are initially undefined. - Throws ErrorFramebufferIncomplete if creation fails. Leaves both the generated texture and framebuffer bound. + Leaves both the generated texture and framebuffer bound. + + @throws std::runtime_error if creation fails. @param width The width of target to create. @param height The height of target to create. @@ -73,10 +75,6 @@ class TextureTarget { */ void draw(float aspect_ratio, float colour_threshold = 0.0f) const; - enum { - ErrorFramebufferIncomplete - }; - private: GLuint framebuffer_ = 0, texture_ = 0, renderbuffer_ = 0; GLsizei width_ = 0, height_ = 0;