1

安卓 2.1 - 日食

哪些步骤将重现该问题?

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)

此时,所有带纹理的精灵都正确渲染了。

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)

所以本质上,createGLHandle() 返回 100271 两次,基本上用衣服.png 覆盖了 bg_wallpaper.png。如果我尝试在 Sprite 中引用“bg_wallpaper”纹理,它显然是从“clothes.png”写入的。

如果我强制上下文丢失和重新聚焦,由于 Gdx 重新加载(管理)纹理,所有纹理都是正确的。

opengl.org/glGenTextures状态:

glGenTextures 在纹理中返回 n 个纹理名称。不能保证名称构成一组连续的整数;但是,可以保证在调用 glGenTextures 之前没有使用任何返回的名称。

我的问题是,我是否可以在 GL 中调用任何东西来强制纹理“正在使用”并且不会两次返回相同的 glHandle id?

我不确定这是我应该提交给 libgdx 问题的错误吗?

Texture.java 代码可以参考这里进一步说明:

code.google.com/gdx/src/Texture.java

任何帮助是极大的赞赏!

4

1 回答 1

1

确定了问题:

我从 Screen.update() 或 Screen.render() 方法之外调用 Texture.dispose() 导致此错误:

在没有当前上下文的情况下调用 OpenGL ES API(每个线程记录一次)

Switching the code to be executed from Screen.update solved the problem.

于 2011-07-15T22:33:54.893 回答