aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/sprite.c16
1 files changed, 16 insertions, 0 deletions
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)