# glTexImage2D has incorrect max level check inside

**URL:** <https://forums.imgtec.com/t/glteximage2d-has-incorrect-max-level-check-inside/828>\
**Category:** PowerVR Insider\
**Created:** [September 9, 2010, 12:37pm UTC](https://forums.imgtec.com/t/glteximage2d-has-incorrect-max-level-check-inside/828 "2010-09-09T12:37:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![todi1856](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@todi1856](https://forums.imgtec.com/u/todi1856)\
**Post date:** [September 9, 2010, 12:37pm UTC](https://forums.imgtec.com/t/glteximage2d-has-incorrect-max-level-check-inside/828/1 "2010-09-09T12:37:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [September 9, 2010, 12:42pm UTC](https://forums.imgtec.com/t/glteximage2d-has-incorrect-max-level-check-inside/828/2 "2010-09-09T12:42:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![todi1856](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@todi1856](https://forums.imgtec.com/u/todi1856)\
**Post date:** [September 9, 2010, 12:53pm UTC](https://forums.imgtec.com/t/glteximage2d-has-incorrect-max-level-check-inside/828/3 "2010-09-09T12:53:36Z")

</div>

Whoops, log(maxTextureSizel)/log(2.0f) produced 12.99999 and when converting to int, it gave me 12… ☹  
  
  
  
  
  
Sorry, you’re right
