|
Creating sub bitmap from display |
limprevisible
Member #16,590
November 2016
|
Hello guys, I try to use the al_create_sub_bitmap from the my current display but it doesnt work. I constantly have that output: Assertion failed: bitmap != dest && bitmap != dest->parent, file C:\dev\allegro_winpkg\universal\allegro\src\bitmap_draw.c, line 34 The only I found to bypass this problem is to copy the full display in an another bitmap then make my saving from this saved bitmap. Here is my trick: 1) al_set_target_bitmap(save_bitmap) Could like to bypass all this and use al_create_sub_bitmap directly from display. Any idea would be appreciated thank you |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You could use al_draw_bitmap_region. Why do you need a sub bitmap of the display? You can set a clipping rectangle as well if that's what you're worried about. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
limprevisible
Member #16,590
November 2016
|
I am creating a map with tiles. Lets say that I have one tile representing the ground. The tile next to it will be the coast (composed by half part ground and the other one water). So what I do is: 1) Save half of the ground So I will have at the end a tile composed by ground - coast - water. So that's why I need to save a region of the display. I will try the al_draw_bitmap_region and let you know => I tried with the al_draw_bitmap_region and still the same: Assertion failed: bitmap != dest && bitmap != dest->parent, file C:\dev\allegro_winpkg\universal\allegro\src\bitmap_draw.c, line 34 |
beoran
Member #12,636
March 2011
|
The way I solve this in my tile map engine is to draw the tile partially by applying a mask to the tile before drawing it. See here https://gitlab.com/beoran/eruta-bs/blob/master/src/tile.c#L508 for how I do it. This is IMO easier than messing with the screen, and also gives better performance. On contemporary architectures, reading from the screen is slow. |
SiegeLord
Member #7,827
October 2006
|
That assertion means that you can't draw a bitmap to itself, it's not specific to the display bitmap. The reason why that's forbidden is because, if I recall correctly, this operation isn't actually hardware accelerated. Basically you want to use an intermediate bitmap (there shouldn't be any speed penalty for this) and you should avoid reading from the display. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You don't need the screen to do this. Do it on a buffer or temporary bitmaps instead. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
limprevisible
Member #16,590
November 2016
|
Indeed I tried with a temp bitmap and it worked totally fine. Pity that we cant copy directly from the display. Thanks by the way guys. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You should be able to copy from the display directly. Problem is you're reading data from the GPU and the memory has to be locked. You can't draw from the screen to the screen however, if that's what you're doing. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|