improve framebuffer creation error messages

This commit is contained in:
MihailRis 2025-11-24 22:03:50 +03:00
parent 2af7b23b2e
commit 5aa9e68d6f
2 changed files with 29 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include <GL/glew.h>
#include "Texture.hpp"
#include "debug/Logger.hpp"
#include "gl_util.hpp"
static debug::Logger logger("gl-framebuffer");
@ -48,8 +49,12 @@ Framebuffer::Framebuffer(uint width, uint height, bool alpha)
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
logger.error() << "framebuffer is not complete!";
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
auto logLine = logger.error();
logLine << "framebuffer is not complete: ";
logLine << gl::to_string(status);
logLine << " (" << status << ")";
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);

View File

@ -45,4 +45,26 @@ namespace gl {
}
return 0;
}
/// TODO: extend
inline const char* to_string(GLenum item) {
switch (item) {
case GL_FRAMEBUFFER_UNDEFINED:
return "framebuffer undefined";
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
return "framebuffer incomplete attachment";
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
return "framebuffer incomplete missing attachment";
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
return "framebuffer incomplete draw buffer";
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
return "framebuffer incomplete read buffer";
case GL_FRAMEBUFFER_UNSUPPORTED:
return "framebuffer unsupported";
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
return "framebuffer incomplete multisample";
default:
return "unknown";
}
}
}