Search in sources :

Example 1 with VertexShortAttributeBinding

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

the class VertexGLAttributeTest method testShortBinding.

@Test
public void testShortBinding() {
    VertexResourceBuilder builder = new VertexResourceBuilder();
    VertexShortAttributeBinding a1 = builder.add(0, GLAttributes.SHORT_1_VERTEX_ATTRIBUTE);
    VertexResource resource = builder.build();
    a1.put((short) 10);
    a1.put((short) 150);
    a1.put((short) 100);
    a1.put((short) 100);
    assertEquals(4, a1.getPosition());
    resource.writeBuffer(buffer -> {
        assertEquals(4 * Short.BYTES, buffer.limit());
        assertEquals(10, Short.toUnsignedInt(buffer.getShort(Short.BYTES * 0)));
        assertEquals(150, Short.toUnsignedInt(buffer.getShort(Short.BYTES * 1)));
        assertEquals(100, Short.toUnsignedInt(buffer.getShort(Short.BYTES * 2)));
        assertEquals(100, Short.toUnsignedInt(buffer.getShort(Short.BYTES * 3)));
    });
}
Also used : VertexResource(org.terasology.engine.rendering.assets.mesh.resource.VertexResource) VertexResourceBuilder(org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder) VertexShortAttributeBinding(org.terasology.engine.rendering.assets.mesh.resource.VertexShortAttributeBinding) Test(org.junit.Test)

Aggregations

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