Search in sources :

Example 6 with MemFreeByteBuffer

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 ^
}
Also used : VertexBufferGL(io.xol.chunkstories.renderer.opengl.vbo.VertexBufferGL) MemFreeByteBuffer(io.xol.chunkstories.client.util.MemFreeByteBuffer) ByteBuffer(java.nio.ByteBuffer) MemFreeByteBuffer(io.xol.chunkstories.client.util.MemFreeByteBuffer)

Aggregations

MemFreeByteBuffer (io.xol.chunkstories.client.util.MemFreeByteBuffer)6 ByteBuffer (java.nio.ByteBuffer)6 VertexBufferGL (io.xol.chunkstories.renderer.opengl.vbo.VertexBufferGL)3 Location (io.xol.chunkstories.api.Location)2 CollisionBox (io.xol.chunkstories.api.physics.CollisionBox)2 Player (io.xol.chunkstories.api.player.Player)2 Shader (io.xol.chunkstories.api.rendering.shader.Shader)2 Texture2D (io.xol.chunkstories.api.rendering.textures.Texture2D)2 HeightmapImplementation (io.xol.chunkstories.world.summary.HeightmapImplementation)2 Vector2d (org.joml.Vector2d)2 UnexecutableTaskException (io.xol.chunkstories.api.exceptions.tasks.UnexecutableTaskException)1 VoxelBakerCubic (io.xol.chunkstories.api.rendering.voxel.VoxelBakerCubic)1 VoxelBakerHighPoly (io.xol.chunkstories.api.rendering.voxel.VoxelBakerHighPoly)1 VoxelDynamicRenderer (io.xol.chunkstories.api.rendering.voxel.VoxelDynamicRenderer)1 VoxelRenderer (io.xol.chunkstories.api.rendering.voxel.VoxelRenderer)1 LodLevel (io.xol.chunkstories.api.rendering.world.chunk.ChunkMeshDataSubtypes.LodLevel)1 ShadingType (io.xol.chunkstories.api.rendering.world.chunk.ChunkMeshDataSubtypes.ShadingType)1 VertexLayout (io.xol.chunkstories.api.rendering.world.chunk.ChunkMeshDataSubtypes.VertexLayout)1 ChunkRenderable (io.xol.chunkstories.api.rendering.world.chunk.ChunkRenderable)1 ChunkRenderer (io.xol.chunkstories.api.rendering.world.chunk.ChunkRenderer)1