Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » About shaders and ALLEGRO_BITMAPS

This thread is locked; no one can reply to it. rss feed Print
About shaders and ALLEGRO_BITMAPS
paulwayne
Member #16,605
December 2016

I want to use shaders to create a 2d shadowing effect like this

I have a simple shader that i can apply to the current display, and that works fine. Like this:

#SelectExpand
1al_set_target_backbuffer(display); 2al_use_shader(shader); 3.. draw 4al_use_shader(NULL); 5al_flip_display();

But when i try to use the shaders with a bitmap i cant make this to work.
Basically i want to apply the shader to a bitmap like this:

#SelectExpand
1//draw things to bitmap 2al_set_target_bitmap(bmp); 3al_use_shader(shader); 4.. draw 5al_use_shader(NULL); 6 7//now display it 8al_set_target_backbuffer(display); 9al_clear_to_color(al_map_rgb(0, 0, 0)); 10al_draw_bitmap(bmp, 0, 0, 0);

Maybe is something im missing since im new to allegro, any idea?
Im using the last source version of allegro.

SiegeLord
Member #7,827
October 2006
avatar

It should work, I just tried it on Linux and it seemed fine. What platform are you on?

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

paulwayne
Member #16,605
December 2016

Im on Windows 7 32 bits, Visual Studio 2013, and last Allegro version.

SiegeLord
Member #7,827
October 2006
avatar

Interesting. I tried it on Windows myself, and it seemed to work ok.

Try adding this line before al_init() to enable logging (it'll generate an allegro.log file in your working directory when you run the program):

al_set_config_value(al_get_system_config(), "trace", "level", "debug");

It'll be useful to look at that log.

Additionally, try doing this before you create the display to force OpenGL mode (by default, Allegro uses Direct3D on Windows):

al_set_new_display_flags(ALLEGRO_PROGRAMMABLE_PIPELINE | ALLEGRO_OPENGL);

Lastly, it'll be helpful if you produced a tiny program that reproduced your issue, so we can verify it's not something wrong in your code.

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

paulwayne
Member #16,605
December 2016

I finally got this to work. There was a problem with the shaders i was using. /facepalm

Go to: