Reputation: 73
I've been following this tutorial on rendering to an off-screen texture, but I'm having difficulty creating the render target.
I've registered an error callback function and I'm getting a GL_DEBUG_TYPE_OTHER
error back with a GL_DEBUG_SOURCE_API
source, which is getting spat out by glCheckNamedFramebufferStatus()
with the message:
FBO incomplete: color attachment incomplete[0].
I'm struggling to see what I'm missing here, I've double checked the parameters that I'm passing into the OpenGL functions and tried removing the glTexParameteri
calls but to no avail.
Any help would be greatly appreciated.
GLuint framebuffer = 0;
GLuint renderedTexture;
GLenum drawBuffers[1] = {GL_COLOR_ATTACHMENTS0};
bool buildOffscreenBuffer()
{
// creating frame & render texture to draw picker buffer to
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenTextures(1, &renderedTexture);
glBindTexture(GL_TEXTURE_2D, renderedTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1920, 1080,
0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// configuring framebuffer
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
renderedTexture, 0);
glDrawBuffers(1, drawBuffers);
return glCheckNamedFramebufferStatus(framebuffer, GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
}
Update: As per derhass' answer, it seems that GL_RGB isn't required as per the spec. I've tried updating this to GL_RGBA but I'm getting the same error. Since this may be implementation related, I'll list my card and driver:
Card: RX Vega 56
Driver: mesa/amdgpu
Upvotes: 1
Views: 2325
Reputation: 73
Managed to get to the bottom of this. I'd actually fixed the bug in simplifying the example for the post.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1920, 1080,
0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
Was actually getting the width and height from a helper function that from a platform layer, however that function returned a struct {int, int}
that I was storing in a struct {float, float}
. This resulted in garbage being passed as the width and height to glTexImage2D
.
Upvotes: 0
Reputation: 45332
As per the GL spec, GL_RGB
is not in the set of required renderable formats, so implementations are free to not support it. Try GL_RGBA
instead.
Upvotes: 3