Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libGDX: treat first color in palette as transparent color

old game engines designate the first color of an image's palette as a transparent color. is there a way to do the same with libGDX?

i tried loading the picture and replacing the palete's first color with 0x00000000. however since the pixels are either opaque or transparent i dont need alpha values so i could save a lot of memory by using RGB888 instead of RGBA8888. i lookes through the gdx and opengl documentary for other blending options and found Gdx.gl20.glBlendColor and the SpriteBatch's setBlendFunction function. but they only change the values used in the blending equations.

thanks in advance :)

like image 612
Shinni Avatar asked Apr 09 '12 20:04

Shinni


1 Answers

to draw a textureRegion transparently use the routine like this:

    Color c = batch.getColor();
    batch.setColor(1, 1, 1, alpha);
    batch.draw(....);
    batch.setColor(c);
like image 65
Aliaaa Avatar answered Sep 20 '22 19:09

Aliaaa