Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Tinting white

This thread is locked; no one can reply to it. rss feed Print
Tinting white
Schyfis
Member #9,752
May 2008
avatar

In Allegro 4.2, you could use draw_lit_sprite to tint a sprite white.
Being able to tint white when drawing was something I sorely missed in XNA, but I grudgingly got by. I checked around in the Allegro 5 manual tonight, and I saw al_draw_tinted_bitmap, but it seems to work the same as XNA- by multiplying by a given color.

Is there a way to draw a sprite with a white tint in Allegro 5? If so, a sample would be much appreciated!

________________________________________________________________________________________________________
[freedwill.us]
[unTied Games]

Trent Gamblin
Member #261
April 2000
avatar

It can't be done without a shader (or maybe some weird extensions I don't know about) with OGL/D3D.

tobing
Member #5,213
November 2004
avatar

I'm using al_draw_tinted_bitmap to draw a bitmap lighter than it originally is, with something like

al_draw_tinted_bitmap(bmp, al_map_rgba(60,60,255,0), x, y, 0);

but it may be that you also need to set a suitable blender mode, see
al_set_blender for details.

SiegeLord
Member #7,827
October 2006
avatar

See this thread for the shader and an approximate non-shader blender hack. I have proposed adding a new set of functions to the shader addon that would make these common effects more painless:

ALLEGRO_SHADER* al_create_default_shader();
ALLEGRO_SHADER* al_create_light_shader();
//etc

or even more simply:

ALLEGRO_EFFECT_STATE* al_create_effect_state();

al_use_default_effect(ALLEGRO_EFFECT_STATE* state);
al_use_light_effect(ALLEGRO_EFFECT_STATE* state, ALLEGRO_COLOR light);

The latter you'd use like this:

ALLEGRO_EFFECT_STATE* state = al_create_effect_state();

al_use_light_effect(state, al_map_rgba_f(1, 1, 1, 1));
al_draw_bitmap(bmp, 0, 0, 0); // The bitmap is now pure white

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Go to: