LibGdx (OpenGl ES/Android) - Calling Texture.createGLHandle multiple times returns textureid of newly created texture overwriting it
Android 2.1 - Eclipse
What steps will reproduce the problem?
1.
Create new Texture(managed) using new Texture(FileHandle, Format, bool);
- glGenTextures is called
- glHandle is created (Logcat: 100271) "bg_plainred.png"
- uploadImageData calls glBindTexture(100271)
Create new Texture(managed) using new Texture(FileHandle, Format, bool);
- glGenTextures is called
- glHandle is created (Logcat: 315638026) "body2.png"
- uploadImageData calls glBindTexture(315638026)
At this point, all textured sprites render correctly..
2.
Call Texture.dispose(); "bg_plainred.png"
- glDeleteTextures(glHandle) (Logcat: glHandle = 100271)
3.
Create new Texture(managed) using new Texture(FileHandle, Format, bool);
- glGenTextures is called
- glHandle is created (Logcat: 100271) "bg_wallpaper.png"
- uploadImageData calls glBindTexture(100271)
Create new Texture(managed) using new Texture(FileHandle, Format, bool);
- glGenTextures is called
- glHandle is created (Logcat: 100271) "clothes.png"
- uploadImageData calls glBindTexture(100271)
So essentially,开发者_运维知识库 createGLHandle() returns 100271 twice essentially overwriting bg_wallpaper.png with clothes.png. If I try to reference the "bg_wallpaper" Texture in a Sprite, it obviously writes from "clothes.png".
If I force context loss and refocus, all textures are correct due to Textures being reloaded (managed) by Gdx.
opengl.org/glGenTextures states:
glGenTextures returns n texture names in textures. There is no guarantee that the names form a contiguous set of integers; however, it is guaranteed that none of the returned names was in use immediately before the call to glGenTextures.
My question is if there is anything I can call in GL that would force the texture to be 'in use' and not return the same glHandle id twice?
I'm not sure that this is a bug that I should submit to libgdx issues?
Texture.java code can be referenced here for further clarification:
code.google.com/gdx/src/Texture.java
Any help is greatly appreciated!
Identified the issue:
I was calling Texture.dispose() from outside the Screen.update() or Screen.render() methods which resulted in this error:
call to OpenGL ES API with no current context (logged once per thread)
Switching the code to be executed from Screen.update solved the problem.
精彩评论