use of org.terasology.nui.Color in project Terasology by MovingBlocks.
the class VertexGLAttributeTest method testColorPackedBinding.
@Test
public void testColorPackedBinding() {
VertexResourceBuilder builder = new VertexResourceBuilder();
VertexAttributeBinding<Colorc, Color> a1 = builder.add(0, GLAttributes.COLOR_4_PACKED_VERTEX_ATTRIBUTE);
VertexResource resource = builder.build();
a1.put(Color.white);
a1.put(Color.red);
a1.put(Color.green);
a1.put(Color.blue);
assertEquals(4, a1.getPosition());
int stride = Byte.BYTES * 4;
resource.writeBuffer(buffer -> {
assertEquals(4 * 4 * Byte.BYTES, buffer.limit());
assertEquals(255, Byte.toUnsignedInt(buffer.get(Byte.BYTES * 0)));
assertEquals(255, Byte.toUnsignedInt(buffer.get(Byte.BYTES * 1)));
assertEquals(255, Byte.toUnsignedInt(buffer.get(Byte.BYTES * 2)));
assertEquals(255, Byte.toUnsignedInt(buffer.get(Byte.BYTES * 3)));
assertEquals(255, Byte.toUnsignedInt(buffer.get(stride + Byte.BYTES * 0)));
assertEquals(0, Byte.toUnsignedInt(buffer.get(stride + Byte.BYTES * 1)));
assertEquals(0, Byte.toUnsignedInt(buffer.get(stride + Byte.BYTES * 2)));
assertEquals(255, Byte.toUnsignedInt(buffer.get(stride + Byte.BYTES * 3)));
assertEquals(0, Byte.toUnsignedInt(buffer.get((2 * stride) + Byte.BYTES * 0)));
assertEquals(255, Byte.toUnsignedInt(buffer.get((2 * stride) + Byte.BYTES * 1)));
assertEquals(0, Byte.toUnsignedInt(buffer.get((2 * stride) + Byte.BYTES * 2)));
assertEquals(255, Byte.toUnsignedInt(buffer.get((2 * stride) + Byte.BYTES * 3)));
assertEquals(0, Byte.toUnsignedInt(buffer.get((3 * stride) + Byte.BYTES * 0)));
assertEquals(0, Byte.toUnsignedInt(buffer.get((3 * stride) + Byte.BYTES * 1)));
assertEquals(255, Byte.toUnsignedInt(buffer.get((3 * stride) + Byte.BYTES * 2)));
assertEquals(255, Byte.toUnsignedInt(buffer.get((3 * stride) + Byte.BYTES * 3)));
});
}
use of org.terasology.nui.Color in project Terasology by MovingBlocks.
the class TextureDataFactoryTest method testColorTransformedToTextureUri.
@Test
public void testColorTransformedToTextureUri() throws Exception {
int red = 0x12;
int green = 0x3;
int blue = 0xc4;
int alpha = 0xe;
Color expectedColor = new Color(red, green, blue, alpha);
int expectedRed = 18;
int expectedGreen = 3;
int expectedBlue = -60;
int expectedAlpha = 14;
testRepeatedColorInDataTexture(expectedColor, expectedRed, expectedGreen, expectedBlue, expectedAlpha);
}
use of org.terasology.nui.Color in project Terasology by MovingBlocks.
the class TextureDataFactoryTest method testRedColorNoAlphaTransformedToTextureUri.
@Test
public void testRedColorNoAlphaTransformedToTextureUri() throws Exception {
Color expectedColor = Color.RED;
int expectedRed = -1;
int expectedGreen = 0;
int expectedBlue = 0;
int expectedAlpha = -1;
testRepeatedColorInDataTexture(expectedColor, expectedRed, expectedGreen, expectedBlue, expectedAlpha);
}
use of org.terasology.nui.Color in project Terasology by MovingBlocks.
the class TextureUtilTest method testColorTransformedToAssetUriTransformedToColor.
@Test
public void testColorTransformedToAssetUriTransformedToColor() throws Exception {
Color expectedColor = Color.RED;
ResourceUrn assetUri = TextureUtil.getTextureUriForColor(expectedColor);
Color actualColor = TextureUtil.getColorForColorName(assetUri.getFragmentName().toLowerCase());
assertEquals(expectedColor, actualColor);
int red = 0x12;
int green = 0x3;
int blue = 0xc4;
int alpha = 0xe;
expectedColor = new Color(red, green, blue, alpha);
assetUri = TextureUtil.getTextureUriForColor(expectedColor);
actualColor = TextureUtil.getColorForColorName(assetUri.getFragmentName().toLowerCase());
assertEquals(expectedColor, actualColor);
}
use of org.terasology.nui.Color in project Terasology by MovingBlocks.
the class TextureUtilTest method testColorTransformedToTextureUri.
@Test
public void testColorTransformedToTextureUri() throws Exception {
ResourceUrn assetUri = TextureUtil.getTextureUriForColor(Color.RED);
assertEquals(TerasologyConstants.ENGINE_MODULE, assetUri.getModuleName());
assertEquals(new Name("color"), assetUri.getResourceName());
assertEquals(new Name("ff0000ff"), assetUri.getFragmentName());
int red = 0x12;
int green = 0x3;
int blue = 0xc4;
int alpha = 0xe;
assetUri = TextureUtil.getTextureUriForColor(new Color(red, green, blue, alpha));
assertEquals(TerasologyConstants.ENGINE_MODULE, assetUri.getModuleName());
assertEquals(new Name("color"), assetUri.getResourceName());
assertEquals(new Name("1203c40e"), assetUri.getFragmentName());
}
Aggregations