Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java LibGdx(opengles/Android)-多次调用Texture.createGLHandle将返回覆盖它的新创建纹理的textureid_Java_Android_Opengl Es_Libgdx - Fatal编程技术网

Java LibGdx(opengles/Android)-多次调用Texture.createGLHandle将返回覆盖它的新创建纹理的textureid

Java LibGdx(opengles/Android)-多次调用Texture.createGLHandle将返回覆盖它的新创建纹理的textureid,java,android,opengl-es,libgdx,Java,Android,Opengl Es,Libgdx,Android 2.1-Eclipse 什么步骤会重现问题? 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

Android 2.1-Eclipse

什么步骤会重现问题?

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)
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)
此时,所有带纹理的精灵都会正确渲染

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_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)
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两次,基本上是用cloth.png覆盖bg_wallper.png。如果我尝试在精灵中引用“bg_墙纸”纹理,它显然是从“costs.png”中写入的

如果我强制上下文丢失并重新聚焦,所有纹理都是正确的,因为Gdx正在重新加载(管理)纹理

国家:

glGenTextures在纹理中返回n个纹理名称。没有 保证名称形成一组连续的整数;然而, 可以保证没有返回的名称被使用 在调用glGenTextures之前

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

我不确定这是否是我应该提交给libgdx发行版的bug

此处可参考Texture.java代码以进一步澄清:

非常感谢您的帮助

确定了问题:

我从Screen.update()或Screen.render()方法外部调用了Texture.dispose(),这导致了以下错误:

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

从Screen.update切换要执行的代码解决了问题。

确定了问题:

我从Screen.update()或Screen.render()方法外部调用了Texture.dispose(),这导致了以下错误:

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


从Screen.update切换要执行的代码解决了问题。

您在这里询问过吗?完成!谢谢,我不知道那里有。你问过这里吗?完成!谢谢,我不知道那里有。