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