Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Tint bitmap

This thread is locked; no one can reply to it. rss feed Print
Tint bitmap
Bingocat
Member #15,424
December 2013

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
Member #12,293
October 2010

Is there any reason not to use al_draw_tinted_bitmap?

Elias
Member #358
May 2000

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)

--
"Either help out or stop whining" - Evert

Bingocat
Member #15,424
December 2013

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
Member #358
May 2000

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

--
"Either help out or stop whining" - Evert

Bingocat
Member #15,424
December 2013

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

Elias
Member #358
May 2000

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

--
"Either help out or stop whining" - Evert

Bingocat
Member #15,424
December 2013

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
Member #1,881
January 2002
avatar

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.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs

GullRaDriel
Member #3,861
September 2003
avatar

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

I never had problems compiling on windows.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Go to: