Hello,
I using two bitmaps, image (subbitmap) and grid (main bitmap)
Until here it is all going well, but If I draw directly to image(subbitmap) then I not found how to send the changes to display.
Any idea how can I update the main bitmap after edit the subbitmap?
]]>I cannot test this at the moment but it could help you:
al_create_sub_bitmap(...) actually returns a pointer value of ALLEGRO_BITMAP type which you (in your actual source) never store or use.
Once you obtain that pointer you need to use it with al_set_target_bitmap command.
So something like this (instead of line 12):
ALLEGRO_BITMAP *sub = al_create_sub_bitmap(grid, 0, 0, columns, rows); al_set_target_bitmap(sub); //draw to sub //draw grid on screen
Also, you post parts of your source code (as opposed to full code of the example where you are reproducing the issue) so it is difficult to know what you are trying to do but for one, lines 5&6 are kind of canceling eachother out:
al_set_target_bitmap(grid); al_set_target_bitmap(al_get_backbuffer(display));
]]>
Thanks for your response!
I deleted the following lines:
al_set_target_bitmap(grid); al_set_target_bitmap(al_get_backbuffer(display));
I try your recomendation for line 12:
subImage = al_create_sub_bitmap(grid, 0, 0, columns, rows); al_set_target_bitmap(subImage); al_draw_bitmap(image, 0, 0, 0);
only obtain a black screen
But, when I try to draw the grid al_draw_bitmap(grid, 0, 0, 0), it produces an error:
_bitmap_drawer: Assertion `bitmap != dest && bitmap != dest->parent' failed.
Sorry for not post the entire code. The last part of the post sample code will run inside a while-loop.
]]>Don't worry about not posting entire code. It is just that it would be easier to make it work for you if you did post a minimalistic example that reproduces the issue you have - you could get a better answer here if you did.
What is the issue at the moment, I believe, is that you are never drawing anything to 'display'. Once your grid, sub, ... bitmaps have been drawn to, you will need to:
al_set_target_bitmap(al_get_backbuffer(display));
and then draw those bitmaps on the screen (namely, I believe you need to draw the 'grid' bitmap to 'display') and then do the al_flip_display();.
You can't draw a bitmap onto itself.
Also, I answered your question on Stack Overflow.
Note : The 'Allegro Development' forum is for development of the Allegro library, not 'Programming Questions' which is for questions about use of Allegro.
]]>