I’m trying to create a basic framebuffer with two color attachments and a depth + stencil attachment, all are plain textures.
This is the OpenGL code that is eventually executed behind my C++ abstraction:
GLuint framebuffer;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
GLuint color_attachment;
glGenTextures(1, &color_attachment);
glBindTexture(GL_TEXTURE_2D, color_attachment);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1024, 576, 0, GL_RGB,
GL_UNSIGNED_BYTE, nullptr); // Here is the error
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
color_attachment, 0);
// More OpenGL code here, but unimportant since the error is already thrown
// glCheckFramebufferStatus succeeds...
if (!(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)) {
SPDLOG_CRITICAL("Framebuffer {} is incomplete", framebuffer);
std::exit(1);
}
Now, the strange problem is this:
When the code oddly reaches the glTexImage2D function, OpenGL will print this message to the console (I have set the error callback, because I’m using OpenGL >= 4.3) with severity GL_DEBUG_SEVERITY_MEDIUM
:
FBO incomplete: no attachments and default width or height is 0 [-1]
But the code continues with no problems and glCheckFramebufferStatus
returns GL_FRAMEBUFFER_COMPLETE
, which means that the framebuffer is complete.
I don’t understand what is the problem. I saw this error message on the internet only once, but with no context and no help. Can somebody help me, please?
I’m on Linux
, OpenGL version 4.5 (Core Profile) Mesa 20.0.8
and driver Intel Open Source Technology Center
.
Thank you!