Search in sources :

Example 1 with VertexIntegerAttributeBinding

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

the class VertexAttributeBindingTest method testPutAllBindingInt.

@Test
public void testPutAllBindingInt() {
    VertexResourceBuilder builder = new VertexResourceBuilder();
    VertexIntegerAttributeBinding a1 = builder.add(0, GLAttributes.INT_1_VERTEX_ATTRIBUTE);
    builder.build();
    a1.put(new int[] { 10, 2, 1, 1 });
    assertEquals(10, a1.get(0));
    assertEquals(2, a1.get(1));
    assertEquals(1, a1.get(2));
    assertEquals(1, a1.get(3));
}
Also used : VertexResourceBuilder(org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder) VertexIntegerAttributeBinding(org.terasology.engine.rendering.assets.mesh.resource.VertexIntegerAttributeBinding) Test(org.junit.Test)

Example 2 with VertexIntegerAttributeBinding

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

the class VertexResourceTest method testRewind.

@Test
public void testRewind() {
    VertexResourceBuilder builder = new VertexResourceBuilder();
    VertexIntegerAttributeBinding a1 = builder.add(0, GLAttributes.INT_1_VERTEX_ATTRIBUTE);
    VertexResource resource = builder.build();
    a1.put(10);
    a1.put(20);
    assertEquals(2, a1.getPosition());
    resource.writeBuffer(buffer -> {
        assertEquals(2 * Integer.BYTES, buffer.limit());
        assertEquals(10, buffer.getInt(Integer.BYTES * 0));
        assertEquals(20, buffer.getInt(Integer.BYTES * 1));
    });
    // rewind buffer
    a1.rewind();
    // position is at 0
    assertEquals(0, a1.getPosition());
    // set 15 for position 0
    a1.put(15);
    resource.writeBuffer(buffer -> {
        assertEquals(2 * Integer.BYTES, buffer.limit());
        assertEquals(15, buffer.getInt(Integer.BYTES * 0));
        assertEquals(20, buffer.getInt(Integer.BYTES * 1));
    });
    // set 5 for position 1
    a1.put(5);
    resource.writeBuffer(buffer -> {
        assertEquals(2 * Integer.BYTES, buffer.limit());
        assertEquals(15, buffer.getInt(Integer.BYTES * 0));
        assertEquals(5, buffer.getInt(Integer.BYTES * 1));
    });
}
Also used : VertexResource(org.terasology.engine.rendering.assets.mesh.resource.VertexResource) VertexResourceBuilder(org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder) VertexIntegerAttributeBinding(org.terasology.engine.rendering.assets.mesh.resource.VertexIntegerAttributeBinding) Test(org.junit.Test)

Example 3 with VertexIntegerAttributeBinding

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

the class VertexGLAttributeTest method testIntBinding.

@Test
public void testIntBinding() {
    VertexResourceBuilder builder = new VertexResourceBuilder();
    VertexIntegerAttributeBinding a1 = builder.add(0, GLAttributes.INT_1_VERTEX_ATTRIBUTE);
    VertexResource resource = builder.build();
    a1.put(10);
    a1.put(20);
    a1.put(150);
    a1.put(100);
    a1.put(-100);
    assertEquals(5, a1.getPosition());
    resource.writeBuffer(buffer -> {
        assertEquals(5 * Integer.BYTES, buffer.limit());
        assertEquals(10, buffer.getInt(Integer.BYTES * 0));
        assertEquals(20, buffer.getInt(Integer.BYTES * 1));
        assertEquals(150, buffer.getInt(Integer.BYTES * 2));
        assertEquals(100, buffer.getInt(Integer.BYTES * 3));
        assertEquals(-100, buffer.getInt(Integer.BYTES * 4));
    });
}
Also used : VertexResource(org.terasology.engine.rendering.assets.mesh.resource.VertexResource) VertexResourceBuilder(org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder) VertexIntegerAttributeBinding(org.terasology.engine.rendering.assets.mesh.resource.VertexIntegerAttributeBinding) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 VertexIntegerAttributeBinding (org.terasology.engine.rendering.assets.mesh.resource.VertexIntegerAttributeBinding)3 VertexResourceBuilder (org.terasology.engine.rendering.assets.mesh.resource.VertexResourceBuilder)3 VertexResource (org.terasology.engine.rendering.assets.mesh.resource.VertexResource)2