从示例中复制和粘贴源代码是一回事,但我正在寻找一些答案来解释为什么这些示例是这样的。
我无法回答的一个问题是为什么三角形的 ByteBuffer 每个坐标需要四个字节。
在Google 提供的示例中,一个 ByteBuffer 被实例化为每个三角形坐标四个字节。
// initialize vertex byte buffer for shape coordinates
// (number of coordinate values * 4 bytes per float)
ByteBuffer bb = ByteBuffer.allocateDirect(triangleCoords.length * 4);
// use the device hardware's native byte order
bb.order(ByteOrder.nativeOrder());
- 为什么每个坐标是四个字节而不是 2 或 8 个?
- nativeOrder() 调用的目的是什么?