use of io.xol.chunkstories.renderer.opengl.vbo.VertexBufferGL in project chunkstories by Hugobros3.
the class FakeImmediateModeDebugRenderer method getCube.
public static VertexBuffer getCube() {
if (cube == null) {
cube = new VertexBufferGL();
float[] cubeData = new float[] { // Base face
0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, // Top face
1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, // Vertical segments
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
FloatBuffer dataToUpload = BufferUtils.createFloatBuffer(cubeData.length);
dataToUpload.put(cubeData);
dataToUpload.flip();
cube.uploadData(dataToUpload);
}
return cube;
}
use of io.xol.chunkstories.renderer.opengl.vbo.VertexBufferGL 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