我已经用我的Android代码FloatBuffers已有一段时间(从一些opengles教程复制),但我不明白到底是什么,这种结构是,为什么它是需要的。为什么使用FloatBuffer而不是float []?
例如代码(或类似),我看到了许多许多人的代码和android教程:
float[] vertices = ...some array...
ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
vbb.order(ByteOrder.nativeOrder()); // use the device hardware's native byte order
FloatBuffer fb = vbb.asFloatBuffer(); // create a floating point buffer from the ByteBuffer
fb.put(vertices); // add the coordinates to the FloatBuffer
fb.position(0); // set the buffer to read the first coordinate
这似乎非常繁琐,杂乱的东西,这是据我可以告诉只是看中包裹着一系列浮游物。
问题:
,这是什么类型的类(字节缓冲区,FloatBuffer)的理由,而不是任何其他类型的集合或浮标阵列简单的?
背后有什么它转换成FloatBuffer之前创建字节缓冲区的想法?