al_hold_bitmap_drawing
void al_hold_bitmap_drawing(bool hold)
Introduced in 5.0.0
Enables or disables deferred bitmap drawing. This allows for efficient drawing of many bitmaps that share a parent bitmap, such as sub-bitmaps from a tilesheet or simply identical bitmaps. Drawing bitmaps that do not share a parent is less efficient, so it is advisable to stagger bitmap drawing calls such that the parent bitmap is the same for large number of those calls. While deferred bitmap drawing is enabled, the only functions that can be used are the bitmap drawing functions and font drawing functions. Changing the state such as the blending modes will result in undefined behaviour. One exception to this rule are the transformations. It is possible to set a new transformation while the drawing is held.
No drawing is guaranteed to take place until you disable the hold. Thus, the idiom of this function's usage is to enable the deferred bitmap drawing, draw as many bitmaps as possible, taking care to stagger bitmaps that share parent bitmaps, and then disable deferred drawing. As mentioned above, this function also works with bitmap and truetype fonts, so if multiple lines of text need to be drawn, this function can speed things up.
See also: al_is_bitmap_drawing_held
Examples: ex_ttf
Most helpful discussions:
- Terrible Frame Rate With Tile Map System (3)
- Optimizing Isometric Tiles (3)
- Locking bitmap is slower than not (?) (2)
- Best performance when loading Bitmaps (2)
- performance of sub-bitmaps (1)
- Is this the right way of using al_hold_bitmap_drawing? (1)
- Resolution Independance for 2d-Tilebased (1)
- Vector size limit? (1)
- Memory saving versus performance and splitting sprites (1)
- allegro 5 c++ project works with code::blocks - stars (1)
Other recent discussions:
- 2D Isometric Game extreme lag.
- al_hold_bitmap_drawing
- Fastest way to draw many (many!) primitives
- Allegro 5.2.4 released!
- The most effective use of al_hold_bitmap_drawing
- Thinking about upgrading my GPU
- Sliding Collision
- One object - one bitmap?
- Just bored... ;)
- al_get_target_bitmap returning a destroyed bitmap