本文整理汇总了Java中javax.microedition.khronos.opengles.GL10.GL_TRIANGLES属性的典型用法代码示例。如果您正苦于以下问题:Java GL10.GL_TRIANGLES属性的具体用法?Java GL10.GL_TRIANGLES怎么用?Java GL10.GL_TRIANGLES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.microedition.khronos.opengles.GL10
的用法示例。
在下文中一共展示了GL10.GL_TRIANGLES属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModelIndices
private static int[] getModelIndices(InputStream modelStream)
throws IOException, IndexTypeNotSupportedException, PrimitiveTypeNotSupportedException {
byte[] indexBufferSize32Bits = new byte[4];
byte[] dataTypeBytes = new byte[4];
byte[] primTypeBytes = new byte[4];
byte[] sizePerElementBytes = new byte[4];
byte[] numIndices32Bits = new byte[4];
modelStream.read(indexBufferSize32Bits, 0, 4);
modelStream.read(dataTypeBytes, 0, 4);
modelStream.read(primTypeBytes, 0, 4);
modelStream.read(sizePerElementBytes, 0, 4);
modelStream.read(numIndices32Bits, 0, 4);
int indexBufferSize = ByteBuffer.wrap(indexBufferSize32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();
int primType = ByteBuffer.wrap(primTypeBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
int numIndices = ByteBuffer.wrap(numIndices32Bits).order(ByteOrder.LITTLE_ENDIAN).getInt();
if (primType != GL10.GL_TRIANGLES) {
// We only support the triangle primitives right now
throw new PrimitiveTypeNotSupportedException("Only triangle primitives are supported");
}
int indexTypeSize = indexBufferSize / numIndices;
int[] indices = new int[numIndices];
byte[] currentIndexBytes = new byte[indexTypeSize];
// Read the indices into a buffer
for (int i = 0; i < numIndices; i++) {
modelStream.read(currentIndexBytes, 0, indexTypeSize);
int currentIndex = -1;
switch (indexTypeSize) {
case 4:
currentIndex = ByteBuffer.wrap(currentIndexBytes).order(ByteOrder.LITTLE_ENDIAN).getInt();
break;
case 2:
currentIndex = ByteBuffer.wrap(currentIndexBytes).order(ByteOrder.LITTLE_ENDIAN).getShort();
break;
case 1:
currentIndex = currentIndexBytes[0];
break;
default:
// We don't support other types
throw new IndexTypeNotSupportedException("Only integer, short and byte indices are supported");
}
indices[i] = currentIndex;
}
return indices;
}