dupersuper
dupersuper

Reputation: 839

Attaching integer textures to a framebuffer

I'm trying to attach a texture with internal format GL_R32UI to a framebuffer, to be used as an ID-buffer. However, glCheckFramebufferStatus keeps coming up with GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, even when it is the only attachment.

This is very strange to me because the OpenGL 4.2 specs seems to state the GL_R32UI is one of the formats that OpenGL implementations must support when attached to framebuffers. I'm suspecting that this is a driver bug. Am I right, or can anyone show me what I am overlooking?

Upvotes: 5

Views: 1933

Answers (1)

dupersuper
dupersuper

Reputation: 839

I solved my own problem.

void glTexImage2D(GLenum target,
    GLint level,
    GLint internalFormat,
    GLsizei width,
    GLsizei height,
    GLint border,
    GLenum format,
    GLenum type,
    const GLvoid * data);

When calling glTexImage2D to create the texture, the 7th parameter 'format' needs to correspond to the 3rd 'internalFormat' parameter, even if you are passing a null pointer for the data parameter. If your internal format is an integral format, you need to supply a format like GL_RED_INTEGER, and not a format like GL_RED.

Upvotes: 8

Related Questions