glTexImage2D has incorrect max level check inside

void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)





According to OpenGL 2.0 documentation:


"GL_INVALID_VALUE may be generated if level is greater than log 2 ⁡ max , where max is the returned value of GL_MAX_TEXTURE_SIZE when target is GL_TEXTURE_2D or GL_MAX_CUBE_MAP_TEXTURE_SIZE when target is not GL_TEXTURE_2D."





on OpenGL ES 2.0 Emu, max texture size is 8192, thus max level is 12, so values from 0…12 are legal





But if you pass for ex., 13 to glTexImage2D, the GL_INVALID_VALUE won’t popup… I think this is a bug.





The value 14 and above will produce GL_INVALID_VALUE.

With mipmap sizes ranging from 1 (2^0) to 8192 (2^13) you get 14 levels. The behaviour you observed is correct.

Whoops, log(maxTextureSizel)/log(2.0f) produced 12.99999 and when converting to int, it gave me 12… :frowning:





Sorry, you’re right