Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.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
Android Opengl顶点大于1_Android_Opengl - Fatal编程技术网

Android Opengl顶点大于1

Android Opengl顶点大于1,android,opengl,Android,Opengl,我在安卓中做一个多边形,我有一个顶点,问题是,有一些大于1的顶点,它们是浮点数 我见过一段代码,其中1的值是这样处理的: int one = 0x10000; 我有如下浮动值: float verticesflotantes[]={//Arreglo de Vertices Flotantes 1.0000f, 1.0000f, 4.2361f, 1.0000f, 1.0000f, -4.2361f,

我在安卓中做一个多边形,我有一个顶点,问题是,有一些大于1的顶点,它们是浮点数

我见过一段代码,其中1的值是这样处理的:

int one = 0x10000;
我有如下浮动值:

float verticesflotantes[]={//Arreglo de Vertices Flotantes
                  1.0000f,    1.0000f,    4.2361f,
                  1.0000f,    1.0000f,   -4.2361f,
                  1.0000f,   -1.0000f,    4.2361f,
                  1.0000f,   -1.0000f,   -4.2361f,
                 -1.0000f,    1.0000f,    4.2361f,
                 -1.0000f,    1.0000f,   -4.2361f,
                 -1.0000f,   -1.0000f,    4.2361f,
                 -1.0000f,   -1.0000f,   -4.2361f,
                  4.2361f,    1.0000f,    1.0000f,.... continue...
但是我需要的顶点数组是一个int,我试着这样做:

int vertices[] = new int[verticesflotantes.length];

        for(int i = 0;i<verticesflotantes.length;i++){
            // 1 = 65536
            // 5 = 1 = 65536
            // 5 = 65536
            // x = x*65536/5

            float regla3 = verticesflotantes[i]*65536/5;

            String hexadecimal = Float.toHexString(regla3);

            vertices[i]= Integer.parseInt(hexadecimal,16);
}
int顶点[]=新的int[verticesflotantes.length];

对于(int i=0;i您得到了NumberFormatException,因为您在
Integer.parseInt(…)
函数中解析了一个“浮点字符串”。
也许你可以这样做:

int regla3 = (int) verticesflotantes[i]*65536/5; // get the integer part
// well... now you have integer part, I think there is nothing we need to do.

vertices[i] = regla3;