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
gcc HelloFBO.c -lglfw -lGLEW -lGL), I'd be surprised if that wouldn't run on mesa/amdgpu. Just add the framebuffer completness checks, and change the FBO dimensions if you like.