Search code examples
androidopengl-esandroid-ndkopengl-es-1.1

glGenTextures not generating names


I am using OpenGL ES 1.1 with the NDK and occasionally when I call glGenTextures it does not change the value of name holder that I pass in (doesn't even set it to 0).

  • glGetError returns 0, no error.
  • All GL code is in a JNI method called from onDrawFrame of the surface renderer so the context shouldn't be a problem. (edit: this was a wrong assumption and was the cause of the problem)
  • The code works in some cases and not others. If I repeat the call each frame it works after about 5 tries. (I am generating glyphs on request).
  • The first lot of textures get created up to at least #32 but after that it is hit and miss.

Does anyone know of a reason why glGenTextures would appear to do nothing?


Solution

  • Is glGenTextures called with a valid OpenGL(-ES) context being active? If you're using multiple threads: A OpenGL(-ES) context can be active in only one thread at a time. But each thread may have a different context active.