|
al_hold_bitmap_drawing |
Josh Taylor
Member #17,070
April 2019
|
Well, I'm kind of new around here. First of all, I have to say Allegro 5 is great. I've only messed around a little with 4 in the past until I bit the bullet and tried out 5. Here's my question: Here's the code I used it with: 1 al_hold_bitmap_drawing(true);
2 for (int y = sy; y < sy + y_tiles_in_view; y++)
3 {
4 for (int x = sx; x < sx + x_tiles_in_view; x++)
5 {
6 if ((x < MAP_WIDTH) && (x > -1) && (y < MAP_HEIGHT) && (y > -1))
7 {
8 if (m->position[x + y * MAP_WIDTH].empty_tile == false)
9 {
10 //Draw the tile, subtracting the camera position
11 al_draw_bitmap_region(tile_sheet,
12 convert_index_to_pixel_xy(m->position[x + y * MAP_WIDTH].tile, 16, TILE_SIZE, RETURN_X),
13 convert_index_to_pixel_xy(m->position[x + y * MAP_WIDTH].tile, 16, TILE_SIZE, RETURN_Y),
14 TILE_SIZE,
15 TILE_SIZE,
16 (x * TILE_SIZE) - c->x,
17 (y * TILE_SIZE) - c->y,
18 0);
19 }
20 }
21 }
22 }
23 al_hold_bitmap_drawing(false);
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
al_hold_bitmap_drawing works on any bitmap as long as the src texture is the same. 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 |
Josh Taylor
Member #17,070
April 2019
|
Thanks, Edgar! That's what I hoped to hear.
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
So yes, your example is using al_hold_bitmap_drawing correctly. It's designed to work with atlas's and tile maps. Things that would make it work less effectively include changing the source texture. So if you tried to draw many small independent bitmaps each with their own texture, the performance gain would be practically nil. Because each time the source texture changes, it has to rebind it with the gpu in order to draw from it. Also to note, al_hold_bitmap_drawing does not work with primitive drawing. It's for bitmap drawing only. 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 |
|