0
votes

Using libgdx, is there something we have to do to enable transparency drawing a Pixmap to a Texture? I've tried doing this before the texture's draw() call where I pass the Pixmap:

Gdx.gl.glClearColor(0.5f, 0.0f, 0.0f, 1.0f);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
Gdx.gl.glEnable(GL10.GL_BLEND);

But it's painting an opaque dark red (glClearColor) color instead of a transparent pixel.

1
The alpha value of your clear is 1.0, which is completely opaque in OpenGL's eyes. Setting that less than 1.0 will add some translucency, but only if your texture (or pixmap) stores the alpha value as well (i.e., it was allocated to have an alpha channel).radical7

1 Answers

2
votes

I don't know the reason for the lack of transparency drawing to a Texture, but it appears that using Pixmaps exclusively (drawing a pixmap onto another larger pixmap) and only rendering to the Texture as a very last step was the solution.

Can't find information on it so I can only assume that drawing a transparent Pixmap to a Texture to blend with the Texture's background color isn't supported.