Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glTexImage2D causes GL_INVALID_OPERATION

Tags:

ios

opengl-es

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.

like image 834
Felix K. Avatar asked Nov 08 '12 18:11

Felix K.


2 Answers

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

like image 178
keaukraine Avatar answered Nov 08 '22 14:11

keaukraine


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.

like image 28
Felix K. Avatar answered Nov 08 '22 13:11

Felix K.