A
A
Andrey Andryushchenko2015-04-17 14:26:35
Java
Andrey Andryushchenko, 2015-04-17 14:26:35

How to fill with semi-alpha in libGDX?

I need to fill the screen with a translucent color, for example, in order to darken the previous frame.
I tried to do it like this:

Gdx.gl.glClearColor(1, 0, 0, 0.5f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

But this code just fills the screen with red instead of dimming it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Petrov, 2015-04-17
@sperson

I could be wrong, but it seems that using glClear for such purposes is not exactly 'pretty' and does not always work with default settings.
In your case, it would be more correct to draw a rectangle on the entire screen and already control its color.

D
Don Kaban, 2015-04-18
@donkaban

1. glClearColor will fill the color buffer with the value that you pass there, why do you think that there will be something left from the previous one?
2. Make a billboard (well, a quad, perpendicular to the camera) in full screen, put it in z before your picture, fill it with alpha, turn on blend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question