From b4799373f7fb9c8faec813e78a955438301cb9d1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 25 Jul 2024 14:56:49 +0200 Subject: Add sprite set size/height functions, option to hide window decorations in create window --- src/graphics/sprite.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/graphics') diff --git a/src/graphics/sprite.c b/src/graphics/sprite.c index df3e902..95f733b 100644 --- a/src/graphics/sprite.c +++ b/src/graphics/sprite.c @@ -31,6 +31,22 @@ void mgl_sprite_set_origin(mgl_sprite *self, mgl_vec2f origin) { self->origin = origin; } +void mgl_sprite_set_size(mgl_sprite *self, mgl_vec2f size) { + if(!self->texture) + return; + + self->scale.x = size.x / (float)self->texture->width; + self->scale.y = size.y / (float)self->texture->height; +} + +void mgl_sprite_set_height(mgl_sprite *self, float height) { + if(!self->texture) + return; + + self->scale.x = height / (float)self->texture->width; + self->scale.y = self->scale.x; +} + /* TODO: Cache texture bind to not bind texture if its already bound and do not bind texture 0 */ void mgl_sprite_draw(mgl_context *context, mgl_sprite *sprite) { if(!sprite->texture) -- cgit v1.2.3