Attaching integer textures to a framebuffer
Asked Answered
B

1

5

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?

Buenrostro answered 5/11, 2012 at 11:0 Comment(4)
What are you using as format?Cetane
I think you're inching towards the solution I just worked out :)Buenrostro
Glad its working :). I found it in the spec at page 163 if you are interested.Cetane
Ah, I see. Now I know where to look.Buenrostro
B
8

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.

Buenrostro answered 5/11, 2012 at 11:24 Comment(1)
Note that a tool like glIntercept would allow you to detect this error by giving you an error message. So would employing a debug context and the ARB_debug_output extension.Isaacisaacs

© 2022 - 2024 — McMap. All rights reserved.