Felix K.
Felix K.

Reputation: 6281

glTexImage2D causes GL_INVALID_OPERATION

This is my (wrapped) OpenGL call which causes a GL_INVALID_OPERATION:

GLTextures.TexImage2D(TexImage2DTarget.TEXTURE_2D, 0, TexImageInternalFormat.LUMINANCE_ALPHA, Width, Height, TexImageFormat.LUMINANCE_ALPHA, TexImagePixelType.UNSIGNED_BYTE, source.GetData());

This call works on Windows but not on iOS, in Windows everything works fine and the texture is displayed. I use the same enum-values on iOS and Windows and even the shader is the same ( with some precision hints on iOS ). Also the most textures are working on iOS.

Upvotes: 6

Views: 2207

Answers (2)

Felix K.
Felix K.

Reputation: 6281

I found the issue by thinking about the fact that it runs on desktop but not on iOS. OpenGL textures using a format and internal format and are AFAIK converted from one to another format when the formats are different but the OpenGL ES 2.0 implementation of Apple isn't supporting this.

It came in my mind that this can be the only issue for the not working textures and the GL_INVALID_OPERATION. I checked my enums and found out that the definition of LUMINANCE_ALPHA in one enum had no value assigned and just used the number of the definition before + 1. OpenGL ignores this on desktop because the number has been a valid texture format, on iOS it fails.

Upvotes: 3

keaukraine
keaukraine

Reputation: 5364

Luminance alpha textures use LATC texture compression.

And because iPhone doesn't support EXT_texture_compression_latc extension you can't use LATC textures on iPhone.

More info:

http://www.opengl.org/registry/specs/EXT/texture_compression_latc.txt

http://www.glbenchmark.com/phonedetails.jsp?benchmark=glpro25&D=Apple+iPhone+5&testgroup=gl

Upvotes: 3

Related Questions