I am creating a framebuffer in LWJGL using:

        framebuffer = glGenFramebuffers();
        texture = glGenTextures();
        glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
        glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0);

But glCheckFramebufferStatus tells me that the attachment is incomplete. What am I doing wrong? I checked several websites and I don't seem to be missing anything...?


1 Answer 1


I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) and chapter 9 of the specification (https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf) on how framebuffers and their attachments (renderbuffers) are being set up for drawing.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

Use the glNamedFramebufferParameteri and glNamedRenderbufferParameteri functions for specific adjustments.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .