4

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?

dupersuper
  • 839
  • 1
  • 7
  • 14

1 Answers1

7

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.

dupersuper
  • 839
  • 1
  • 7
  • 14
  • 2
    Note that a tool like [glIntercept](http://code.google.com/p/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. – Nicol Bolas Nov 05 '12 at 15:56