1

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

1
  • Please provide an example which actually produces the issue. Btw, you might check my dirty FBO example (compile via 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. Commented Nov 27, 2020 at 18:45

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Same error with GL_RGBA I'm afraid. I didn't realise that GL_RGB wasn't required by the spec. I'll update the question with some driver information
You still haven't updated the source code for the texture format.
My bad, looked at this first thing in the morning and I missed that in the update
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.