1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Gets more explicit about potential causes of failure.

This commit is contained in:
Thomas Harte 2019-02-18 21:53:35 -05:00
parent 878b480a44
commit 3979faf43b
2 changed files with 21 additions and 7 deletions

View File

@ -10,6 +10,7 @@
#include <cstdlib>
#include <vector>
#include <stdexcept>
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() {

View File

@ -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;