Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.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 Android OpenGL ES纹理显示混乱_Java_Android_Opengl Es_Textures - Fatal编程技术网

Java Android OpenGL ES纹理显示混乱

Java Android OpenGL ES纹理显示混乱,java,android,opengl-es,textures,Java,Android,Opengl Es,Textures,我制作了一个小函数,它迭代字符串,并根据256x256字体纹理中每个字符的坐标将新的纹理坐标放入缓冲区,这样我就可以使用OpenGL顶点数组渲染文本 private void updateTexCoords() { float unit = 0.0625f; byte[] arr = string.getBytes(); for(int i = 0; i < string.length()*8; i += 8) {

我制作了一个小函数,它迭代字符串,并根据256x256字体纹理中每个字符的坐标将新的纹理坐标放入缓冲区,这样我就可以使用OpenGL顶点数组渲染文本

private void updateTexCoords()
    {
        float unit = 0.0625f;
        byte[] arr = string.getBytes();
        for(int i = 0; i < string.length()*8; i += 8)
        {
            float x = (float)(((int)arr[i/8] & 0xff)%16)*unit;
            float y = (float)(((int)arr[i/8] & 0xff)/16)*unit;
            //axis center is at (0,1) pointing right, down
            texture[0+i] = x; texture[1+i] = y+unit; //bottom left
            texture[2+i] = x; texture[3+i] = y; //top left
            texture[4+i] = x+unit; texture[5+i] = y+unit; //bottom right
            texture[6+i] = x+unit; texture[7+i] = y; //top right
        }
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(texture.length * 4);
        byteBuffer.order(ByteOrder.nativeOrder());
        textureBuffer = byteBuffer.asFloatBuffer();
        textureBuffer.put(texture);
        textureBuffer.position(0);
    }
private void updateExcoords()
{
浮动单位=0.0625f;
字节[]arr=string.getBytes();
对于(int i=0;i
它适用于除一款旧手机HTC nexus one之外的所有测试设备, 它显示了混乱的符号,尽管有一个图案,你可以看到基本上给它的纹理坐标是错误的。
在一台特定的设备上,什么会导致这样的问题,特别是在使用Java并且不干扰与本机硬件相关的东西时?

一些Android设备只是有错误的OpenGL ES驱动程序。HTC可能已经更新了可用的驱动程序。它是哪种GPU类型?如果它在AVD仿真上正常工作,那么您的代码可能就可以了


如果您使用背面消隐,我也会尝试反转消隐的卷绕方向。

除文本外,所有图像都正确显示。甚至那些具有自定义纹理坐标(不是标准的0f和1f)的纹理。