ATI: "invalid operation" on glTexImage2D with depth-textures

Hi there

This line


gives me an “invalid operation” error. Although the texture i get seems to work just fine.

However, in the docs it’s said, that “invalid operation” happens, if it is done between glBegin / glEnd, which is definitely not the case here.

Therefore i really don’t know, why i get this error.

It seems to depend on the GL_DEPTH_COMPONENT stuff. If i call the same routine with GL_RGBA8 i get no errors.

This is on an ATI Radeon 9700 with Catalyst 5.6.

Any ideas?


Ok, if i set the format parameter to GL_DEPTH_COMPONENT it works. With all other formats i tried it gives me an error.


  1. it should generate a “invalid enum” error, instead of “invalid operation”
  2. if i specify a NULL pointer it should accept any format. I don’t want to put lots of “if internalformat = DEPTH16/24/32 then format = …” into my code, if i specify a NULL pointer anyway.


GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV on a depth texture?

Edit: You figured it out yourself …


  1. Nope, all enums are valid in this call, but you can’t use them together.
  2. The pixels parameter doesn’t matter. The internalformat, format and type combination must still be valid.

You have to use a valid combination of internal format and format, even if you pass a null pointer. Read the spec:

“Textures with a base internal format of DEPTH_COMPONENT require depth
component data; textures with other base internal formats require RGBA
component data. The error INVALID_OPERATION is generated if the base
internal format is DEPTH_COMPONENT and format is not DEPTH_COMPONENT,
or if the base internal format is not DEPTH_COMPONENT and format is