Android OpenGL 错误:"remaining() <需要"和安卓 4.4 [英] Android OpenGL error: "remaining() < needed" and Android 4.4

查看:17
本文介绍了Android OpenGL 错误:"remaining() <需要"和安卓 4.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在运行 Android 4.4 的手机上启动我的应用程序时遇到一个我不明白的错误(如果这有帮助,那就是 Moto G):

I am getting an error I do not understand when I try and launch my app on a phone running Android 4.4 (It's a Moto G if this helps):

java.lang.IllegalArgumentException: remaining() < needed

Exception thrown in Thread[GLThread 85832,5,main] java.lang.IllegalArgumentException: remaining < needed
at android.opengl.GLES20.glGetInteger v(Native Method)
at com.jme3.renderer.android.OGLESShaderRenderer.intialize(OGLESShaderRenderer.java:311)
at com.jme3.system.android.OGLESContext.initInThread(OGLESContext.java:215)
at com.jme3.system.android.OGLESContext.onSurfaceCreated(OGLESContext.java:187)
at android.opengl.GLSurfaceView$GLTread.guardedRun(GLSurfaceView.java:1501)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

当我在运行 Android 4.0 的 Xperia U 上运行完全相同的代码时,它运行良好.这里发生了什么,我可以采取哪些步骤来确保我的代码在各种设备上运行?

When I run the exact same code on an Xperia U running Android 4.0 it runs fine. What is going on here, and what steps can I take to make sure my code runs on a variety of devices?

推荐答案

glGetIntegerv() Java 绑定的一个变体采用 IntBuffer 参数来保存多个返回值.如果您的请求需要的空间多于缓冲区所容纳的空间,您将收到此错误.

One variant of the glGetIntegerv() Java bindings takes an IntBuffer argument to hold multiple return values. If your request requires more space than the buffer holds, you will get this error.

较旧版本的 jMonkeyEngine 请求具有固定大小缓冲区的 GL_COMPRESSED_TEXTURE_FORMATS.在支持太多格式的设备上调用失败.(您应该查询 GL_NUM_COMPRESSED_TEXTURE_FORMATS,并使用该值来调整缓冲区大小.)在旧版本的 Android 上,这实际上导致了堆损坏,因为 Java 语言绑定进行了错误的比较并允许要写入 IntBuffer 末尾的数据(固定).

Older versions of jMonkeyEngine did a request for GL_COMPRESSED_TEXTURE_FORMATS with a fixed-size buffer. The call failed on devices that supported too many formats. (You're supposed to query GL_NUM_COMPRESSED_TEXTURE_FORMATS, and use that value to size your buffer.) On older versions of Android this actually caused heap corruption, because the Java-language bindings did the comparison wrong and allowed the data to write past the end of the IntBuffer (fixed).

您可以在在此处应用查看对 jMonkeyEngine 的修复.从异常中的行号判断,您使用的 jMonkeyEngine 版本早于修复.

You can see the fix to jMonkeyEngine applied here. Judging by the line number in the exception, you're using a version of jMonkeyEngine that pre-dates the fix.

这篇关于Android OpenGL 错误:&quot;remaining() &lt;需要"和安卓 4.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆