mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
Gets more explicit about potential causes of failure.
This commit is contained in:
parent
878b480a44
commit
3979faf43b
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace Outputs::Display::OpenGL;
|
using namespace Outputs::Display::OpenGL;
|
||||||
|
|
||||||
@ -48,8 +49,23 @@ TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for successful construction.
|
// Check for successful construction.
|
||||||
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
const auto framebuffer_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
throw ErrorFramebufferIncomplete;
|
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() {
|
TextureTarget::~TextureTarget() {
|
||||||
|
@ -26,7 +26,9 @@ class TextureTarget {
|
|||||||
/*!
|
/*!
|
||||||
Creates a new texture target. Contents are initially undefined.
|
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 width The width of target to create.
|
||||||
@param height The height 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;
|
void draw(float aspect_ratio, float colour_threshold = 0.0f) const;
|
||||||
|
|
||||||
enum {
|
|
||||||
ErrorFramebufferIncomplete
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint framebuffer_ = 0, texture_ = 0, renderbuffer_ = 0;
|
GLuint framebuffer_ = 0, texture_ = 0, renderbuffer_ = 0;
|
||||||
GLsizei width_ = 0, height_ = 0;
|
GLsizei width_ = 0, height_ = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user