use of io.xol.chunkstories.client.util.MemFreeByteBuffer in project chunkstories by Hugobros3.
the class BonedRenderer method uploadFloatBuffers.
private void uploadFloatBuffers(FloatBuffer vertices, FloatBuffer textureCoordinates, FloatBuffer normals, ByteBuffer boneIds, ByteBuffer boneWeights) {
meshDataOnGPU = new VertexBufferGL();
int buffer_size = verticesCount * TOTAL_STRUCT_SIZE;
ByteBuffer buffer = MemoryUtil.memAlloc(buffer_size);
for (int i = 0; i < verticesCount; i++) {
buffer.putFloat(vertices.get(i * 3 + 0));
buffer.putFloat(vertices.get(i * 3 + 1));
buffer.putFloat(vertices.get(i * 3 + 2));
buffer.putFloat(normals.get(i * 3 + 0));
buffer.putFloat(normals.get(i * 3 + 1));
buffer.putFloat(normals.get(i * 3 + 2));
buffer.putFloat(textureCoordinates.get(i * 2 + 0));
buffer.putFloat(textureCoordinates.get(i * 2 + 1));
buffer.put(boneIds.get(i * 4 + 0));
buffer.put(boneIds.get(i * 4 + 1));
buffer.put(boneIds.get(i * 4 + 2));
buffer.put(boneIds.get(i * 4 + 3));
buffer.put(boneWeights.get(i * 4 + 0));
buffer.put(boneWeights.get(i * 4 + 1));
buffer.put(boneWeights.get(i * 4 + 2));
buffer.put(boneWeights.get(i * 4 + 3));
}
buffer.flip();
meshDataOnGPU.uploadData(new MemFreeByteBuffer(buffer));
// memfree(meshDataOnGPU) uneeded ^
}
Aggregations