Search in sources :

Example 1 with VertexFloatAttributeBinding

use of org.terasology.engine.rendering.assets.mesh.resource.VertexFloatAttributeBinding in project Terasology by MovingBlocks.

the class VertexAttributeBindingTest method testPutAllBindingFloat.

@Test
public void testPutAllBindingFloat() {
    VertexResourceBuilder builder = new VertexResourceBuilder();
    VertexFloatAttributeBinding a1 = builder.add(0, GLAttributes.FLOAT_1_VERTEX_ATTRIBUTE);
    builder.build();
    a1.put(new float[] { 10f, .5f, 12.5f, 13.5f });
    assertEquals(10f, a1.get(0), 0.001f);
    assertEquals(.5f, a1.get(1), 0.001f);
    assertEquals(12.5f, a1.get(2), 0.001f);
    assertEquals(13.5f, a1.get(3), 0.001f);
}
Also used : VertexFloatAttributeBinding(org.terasology.engine.rendering.assets.mesh.resource.VertexFloatAttributeBinding) VertexResourceBuilder(org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder) Test(org.junit.Test)

Example 2 with VertexFloatAttributeBinding

use of org.terasology.engine.rendering.assets.mesh.resource.VertexFloatAttributeBinding in project Terasology by MovingBlocks.

the class VertexGLAttributeTest method testFloatBinding.

@Test
public void testFloatBinding() {
    VertexResourceBuilder builder = new VertexResourceBuilder();
    VertexFloatAttributeBinding a1 = builder.add(0, GLAttributes.FLOAT_1_VERTEX_ATTRIBUTE);
    VertexResource resource = builder.build();
    a1.put(10.0f);
    a1.put(15.0f);
    a1.put(15.5f);
    a1.put(2.0f);
    a1.put(-100.0f);
    assertEquals(5, a1.getPosition());
    resource.writeBuffer(buffer -> {
        assertEquals(5 * Float.BYTES, buffer.limit());
        assertEquals(10.0f, buffer.getFloat(Float.BYTES * 0), 0.0001f);
        assertEquals(15.0f, buffer.getFloat(Float.BYTES * 1), 0.0001f);
        assertEquals(15.5f, buffer.getFloat(Float.BYTES * 2), 0.0001f);
        assertEquals(2.0f, buffer.getFloat(Float.BYTES * 3), 0.0001f);
        assertEquals(-100.0f, buffer.getFloat(Float.BYTES * 4), 0.0001f);
    });
}
Also used : VertexFloatAttributeBinding(org.terasology.engine.rendering.assets.mesh.resource.VertexFloatAttributeBinding) VertexResource(org.terasology.engine.rendering.assets.mesh.resource.VertexResource) VertexResourceBuilder(org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 VertexFloatAttributeBinding (org.terasology.engine.rendering.assets.mesh.resource.VertexFloatAttributeBinding)2 VertexResourceBuilder (org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder)2 VertexResource (org.terasology.engine.rendering.assets.mesh.resource.VertexResource)1