mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
add ClearToColor util for clearing whole target bitmap, not just the clipping rectangle
Clearing the clipping rectangle can be very costly, while clearing a whole texture is often free.
This commit is contained in:
parent
d20eb28814
commit
9611be3267
2 changed files with 16 additions and 0 deletions
13
src/utils.c
13
src/utils.c
|
@ -128,6 +128,19 @@ SYMBOL_EXPORT void DrawCenteredTintedScaled(ALLEGRO_BITMAP* bitmap, ALLEGRO_COLO
|
|||
x, y, sx, sy, 0, flags);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void ClearToColor(struct Game* game, ALLEGRO_COLOR color) {
|
||||
ALLEGRO_BITMAP* target = al_get_target_bitmap();
|
||||
if (GetFramebuffer(game) == target && al_get_parent_bitmap(target) == al_get_backbuffer(game->display)) {
|
||||
al_set_target_backbuffer(game->display);
|
||||
}
|
||||
int x, y, w, h;
|
||||
al_get_clipping_rectangle(&x, &y, &w, &h);
|
||||
al_reset_clipping_rectangle();
|
||||
al_clear_to_color(color);
|
||||
al_set_clipping_rectangle(x, y, w, h);
|
||||
al_set_target_bitmap(target);
|
||||
}
|
||||
|
||||
/* linear filtering code written by SiegeLord */
|
||||
SYMBOL_EXPORT ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) {
|
||||
return al_map_rgba_f(c1.r + frac * (c2.r - c1.r),
|
||||
|
|
|
@ -56,6 +56,9 @@ void DrawCentered(ALLEGRO_BITMAP* bitmap, int x, int y, int flags);
|
|||
void DrawCenteredScaled(ALLEGRO_BITMAP* bitmap, int x, int y, double sx, double sy, int flags);
|
||||
void DrawCenteredTintedScaled(ALLEGRO_BITMAP* bitmap, ALLEGRO_COLOR tint, int x, int y, double sx, double sy, int flags);
|
||||
|
||||
/*! \brief Clears the current target completely, without taking current clipping rectangle into account. */
|
||||
void ClearToColor(struct Game* game, ALLEGRO_COLOR color);
|
||||
|
||||
ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac);
|
||||
void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height);
|
||||
|
||||
|
|
Loading…
Reference in a new issue