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));
}
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));
});
}
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));
});
}
Aggregations