From 687e42ddfdc8c0dac2664a22af69073853a0182c Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Sat, 27 Jul 2024 15:44:34 +0300 Subject: [PATCH] rendering.c: sprite texture flipping --- src/rendering/sprites.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/rendering/sprites.h b/src/rendering/sprites.h index 0cfef9a..3995fb1 100644 --- a/src/rendering/sprites.h +++ b/src/rendering/sprites.h @@ -99,7 +99,6 @@ static struct sprite_batch { } -/* TODO: texture flipping */ /* assumes that orthogonal matrix setup is done already */ static void render_sprites(const struct primitive_2d primitives[], const size_t len, @@ -142,32 +141,32 @@ static void render_sprites(const struct primitive_2d primitives[], sprite.rect.x, sprite.rect.y }, .uv0 = { - xr, - yr, }, + xr + wr * sprite.flip_x, + yr + hr * sprite.flip_y, }, /* bottom-left */ .v1 = { (sprite.rect.x), (sprite.rect.y + sprite.rect.h) }, .uv1 = { - xr, - yr + hr, }, + xr + wr * sprite.flip_x, + yr + hr * !sprite.flip_y, }, /* bottom-right */ .v2 = { (sprite.rect.x + sprite.rect.w), (sprite.rect.y + sprite.rect.h) }, .uv2 = { - xr + wr, - yr + hr, }, + xr + wr * !sprite.flip_x, + yr + hr * !sprite.flip_y, }, /* upper-right */ .v3 = { (sprite.rect.x + sprite.rect.w), (sprite.rect.y) }, .uv3 = { - xr + wr, - yr, }, + xr + wr * !sprite.flip_x, + yr + hr * sprite.flip_y, }, /* equal for all (flat shaded) */ .c0 = sprite.color,