new option-based api for sprite issue

This commit is contained in:
2024-07-30 15:30:35 +03:00
parent 06ce0eb13a
commit 4a924cb2a9
6 changed files with 44 additions and 74 deletions

View File

@ -61,33 +61,14 @@ struct sprite_primitive_payload_without_color {
*/
/* TODO: it might make sense to infer alpha channel presence / meaningfulness for textures in atlas */
/* so that they are rendered with no blend / batched in a way to reduce overdraw automatically */
void push_sprite(char *path, t_frect rect) {
void push_sprite(const t_push_sprite_args args) {
struct sprite_primitive sprite = {
.rect = rect,
.color = (t_color) { 255, 255, 255, 255 },
.rotation = 0.0,
.texture_key = textures_get_key(&ctx.texture_cache, path),
.flip_x = false,
.flip_y = false,
};
struct primitive_2d primitive = {
.type = PRIMITIVE_2D_SPRITE,
.sprite = sprite,
};
arrput(ctx.render_queue_2d, primitive);
}
void push_sprite_ex(t_frect rect, t_push_sprite_args args) {
struct sprite_primitive sprite = {
.rect = rect,
.color = args.color,
.rotation = args.rotation,
.rect = args.rect,
.color = m_or(args, color, ((t_color) { 255, 255, 255, 255 })),
.rotation = m_or(args, rotation, 0.0f),
.texture_key = textures_get_key(&ctx.texture_cache, args.path),
.flip_x = args.flip_x,
.flip_y = args.flip_y,
.flip_x = m_or(args, flip_x, false),
.flip_y = m_or(args, flip_y, false),
};
struct primitive_2d primitive = {