Invalid operation when I try to load a GL_R8UI texture.

loading the same texture with GL_R8 works just fine, but loading with GL_R8UI throws an GL_INVALID_OPERATION. I am on an OpenGL 3.3 core context profile, but I loaded the extention ARB_direct_state_access. These are the function calls that are tracked from apitrace:


glCreateTextures(GL_TEXTURE_2D, 1, [2])  // [2] means that two is the value that got stored in the parameter array
glTextureStorage2D(2, 1, GL_R8UI, 1024, 1024)
glTextureParameteri(2, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTextureParameteri(2, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glGetTextureLevelParameteriv(2, 0, GL_TEXTURE_WIDTH, [1024])
glGetTextureLevelParameteriv(2, 0, GL_TEXTURE_HEIGHT, [1024])
glTextureSubImage2D(texture=2, level=0, xoffset=0, yoffset=0, width=1024, height=1024, format = GL_RED, type = GL_UNSIGNED_BYTE, pixels = [binary data, size = 1024kb])

and this is the error message:


message: GL_INVALID_OPERATION error generated. Texture type and format combination is not valid.

I just do not understand the problem.

The format parameter should be GL_RED_INTEGER for an integer texture (the online reference page is incorrect on this point; the list of acceptable values for format doesn’t appear to have been updated since integer textures were added).

Thanks a lot, I really thought there was a bug in my driver or something like that, because it just refused to work.

No wonder that I could not find it. How should I be able to do it properly when the official reference is incomplete? And where do other people know it from?

Anyway you really could help, thank you very much.

If in doubt, refer to the current specification.

Unfortunately, information is often fairly scattered. E.g. the description of glTexSubImage2D() just refers to glTexImage2D() which refers to glTexImage3D() which refers to the “Transfer of Pixel Rectangles” section.