I am trying to make the background a sky blue color with RGB of 135,206,235. When I run it, the background is not the color I expected.
public void render () {
Gdx.gl.glClearColor(.135f, .206f, .235f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
glClearColor
uses range from 0 to 1, so you need to map from range 0 - 255 by simply dividing by constant 255f:
Gdx.gl.glClearColor(135/255f, 206/255f, 235/255f, 1);
Also be cautious when dividing 2 integers, if you don't convert any of then to float (or double), integer division will be used and result will be 0 (except for 255/255 == 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With