Program with al_set_target_bitmap does not run.
A. van Patmos

Hi all,

I've been trying to use the al_set_target_bitmap functionality in the following ways (they all compile but do not run):

#SelectExpand
1ALLEGRO_BITMAP *bgimage, *vul = NULL; 2 3al_init_primitives_addon(); 4al_install_keyboard(); 5 6vul = al_load_bitmap("bg.bmp"); 7 8bgimage = al_create_bitmap(width, height); 9 10al_set_target_bitmap(bgimage); 11al_draw_bitmap(vul, 0, 0, 0); 12al_draw_filled_triangle(440, 460, 530, 280, 620, 460, al_map_rgb(255, 0, 0)); 13al_set_target_bitmap(al_get_backbuffer(display));

Here I thought I needed two pointers, one for creating the bitmap and one for filling it.

#SelectExpand
2ALLEGRO_BITMAP *bgimage = NULL; 3 4al_init_primitives_addon(); 5al_install_keyboard(); 6 7bgimage = al_load_bitmap("bg.bmp"); 8 9//bgimage = al_create_bitmap(width, height); 10 11al_set_target_bitmap(bgimage); 12//al_draw_bitmap(vul, 0, 0, 0); 13al_draw_filled_triangle(440, 460, 530, 280, 620, 460, al_map_rgb(255, 0, 0)); 14al_set_target_bitmap(al_get_backbuffer(display));

Here I load the bg.bmp directly in bgimage which will also be the target_bitmap.

#SelectExpand
3ALLEGRO_BITMAP *bgimage = NULL; 4 5al_init_primitives_addon(); 6al_install_keyboard(); 7 8//bgimage = al_load_bitmap("bg.bmp"); 9 10//bgimage = al_create_bitmap(width, height); 11 12al_set_target_bitmap(bgimage); 13bgimage = al_load_bitmap("bg.bmp"); 14//al_draw_bitmap(vul, 0, 0, 0); 15al_draw_filled_triangle(440, 460, 530, 280, 620, 460, al_map_rgb(255, 0, 0)); 16al_set_target_bitmap(al_get_backbuffer(display));

And here I execute al_load_bitmap after al_set_target_bitmap.

All of these give "test.exe has encountered a problem and needs to close etc..."
If I leave out the .bmp it will run and draw the triangle I put in to check. And that I expected to appear on top of the image, is that correct?
I'm running XP-SP3 and Allegro 4.7.1-tdm BTW.

Is it my code or is something else wrong, please?

Paragon

You code doesn't show you calling al_init()
Also, double check that you loaded the bitmap correctly
At the end, after you set the target bitmap to the back buffer, you still need to draw the bitmap you created.

If you are having trouble loading the bitmap try: http://wiki.allegro.cc/index.php?title=Loading_Resources_(Troubleshooting)

A. van Patmos

Yes I lost my al_init_image_addon() at some point. al_init() and al_draw_bitmap() were there, Thanks.

Thread #613390. Printed from Allegro.cc