Tint bitmap
Bingocat

I am trying to make a bitmap in my game be able to be tinted red, but I am having trouble with al_set_blender. I need it to not draw the red where the bitmap has no alpha. Here is my code.

#SelectExpand
1al_set_target_bitmap(temp); 2al_draw_bitmap_region(enemyImages, imageSize * frame, imageSize * type, imageSize, imageSize, 0, 0, NULL); 3al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_ONE); 4al_draw_filled_rectangle(0, 0, imageSize, imageSize, al_map_rgba(255, 0, 0, 50)); 5al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); 6al_set_target_bitmap(al_get_backbuffer(display)); 7al_draw_rotated_bitmap(temp, imageSize / 2, imageSize / 2, x, y, dir, NULL); 8al_destroy_bitmap(temp);

Polybios

Is there any reason not to use al_draw_tinted_bitmap?

Elias

There are several ways to do it, but if you can't figure out the right blending mode one simple way would be to disable alpha writes: al_set_render_state(ALLEGRO_WRITE_MASK_FLAGS, ALLEGRO_MASK_RGB)

Bingocat

I tried drawing a tinted bitmap, but the image is mostly black so I don't think it works because there isn't color to tint. Also, for some reason it seems like al_set_render_state() is nowhere to be found.

Elias

You mean your version of Allegro doesn't have al_set_render_state?

Bingocat

What do I have to include to use it? I can't really find information on it anywhere.

Elias

Nothing? It is a normal function like any other: http://liballeg.org/a5docs/trunk/graphics.html#al_set_render_state

Bingocat

Well it just isn't showing up for me. Maybe I have a weird version of Allegro, but it doesn't matter cause I decided to just do something different for the enemy anyway.

Chris Katko

You need 5.1.2 or later, according to the docs.

If you're on Linux, it's fairly easy to grab the newest version and compile it. On Windows, someone will have to provide the link to a new enough binary version.

GullRaDriel

"On Windows, someone will have to provide the link to a new enough binary version"

I never had problems compiling on windows.

Thread #616857. Printed from Allegro.cc