【发布时间】:2011-10-14 15:48:04
【问题描述】:
我最近在 Badlogicgames.com 上阅读了一篇关于加快将信息添加到顶点缓冲区(或任何其他 intbuffer)的过程的文章,它确实提高了我的项目的速度,但我不太了解
“注意到 IntBuffer.put(int[] src) 没有受到问题的影响”
statement.... 如果您不需要浮点数,是否可以将 int[] 数组输入 IntBuffer 以提高速度?每次我尝试将 int[] 放入缓冲区时;什么都没有渲染...
这是我目前使用的一个例子:
dMesh[i].putVertexBuffer(coords); //function being called
public void putVertexBuffer(int[] input) //actual function
{
ByteBuffer tC = ByteBuffer.allocateDirect(input.length *4);
tC.order(ByteOrder.nativeOrder());
_vertexBuffer = tC.asIntBuffer();
_vertexBuffer.put(input);
_vertexBuffer.position(0);
}
现在,如果 int 数组 "coords" 填充了变量,这些变量是使用 "Float.floatToIntBits(float value)" 转换为整数的浮点数;这很好......但是标准整数数组没有显示任何内容...... 但是如果我只有一个 float[] 数组并将“asIntBuffer()”更改为“asFloatBuffer()”,这行得通吗?我糊涂了。是否需要转换? 提前感谢任何提供任何见解的人。
快速编辑: 我差点忘了……这是我引用的文章: http://www.badlogicgames.com/wiki/index.php/Direct_Bulk_FloatBuffer.put_is_slow
【问题讨论】:
-
欢迎来到 StackOverflow,希望您阅读FAQ。
标签: android opengl-es android-2.2-froyo