aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-16 03:54:26 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-16 03:54:26 +0100
commit61c7efc6dd2a036b5d14aa223d06a18cb7d1388e (patch)
tree602a5553bc780ea438a5e0780806a35d2d98ba44 /include
parentb82049c7ad77603537d419bdd0ebebfd3f007916 (diff)
Sprite: add rotation and origin
Diffstat (limited to 'include')
-rw-r--r--include/mgl/gl.h1
-rw-r--r--include/mgl/graphics/sprite.h6
2 files changed, 6 insertions, 1 deletions
diff --git a/include/mgl/gl.h b/include/mgl/gl.h
index 75bc764..7dc1dd7 100644
--- a/include/mgl/gl.h
+++ b/include/mgl/gl.h
@@ -43,6 +43,7 @@ typedef struct {
void (*glLoadIdentity)(void);
void (*glLoadMatrixf)(const float *m);
void (*glTranslatef)(float x, float y, float z);
+ void (*glRotatef)(float angle, float x, float y, float z);
void (*glGenBuffers)(int n, unsigned int *buffers);
void (*glBindBuffer)(unsigned int target, unsigned int buffer);
void (*glDeleteBuffers)(int n, const unsigned int *buffers);
diff --git a/include/mgl/graphics/sprite.h b/include/mgl/graphics/sprite.h
index 03f81ab..64d9c03 100644
--- a/include/mgl/graphics/sprite.h
+++ b/include/mgl/graphics/sprite.h
@@ -12,15 +12,19 @@ typedef struct {
mgl_color color;
mgl_vec2f position;
mgl_vec2f scale;
+ mgl_vec2f origin; /* top left by default (0, 0) */
+ float rotation; /* in degrees */
} mgl_sprite;
/* |texture| may be NULL */
-void mgl_sprite_init(mgl_sprite *self, mgl_texture *texture, float x, float y);
+void mgl_sprite_init(mgl_sprite *self, mgl_texture *texture);
/* |texture| may be NULL */
void mgl_sprite_set_texture(mgl_sprite *self, mgl_texture *texture);
void mgl_sprite_set_position(mgl_sprite *self, mgl_vec2f position);
void mgl_sprite_set_color(mgl_sprite *self, mgl_color color);
+void mgl_sprite_set_rotation(mgl_sprite *self, float degrees);
+void mgl_sprite_set_origin(mgl_sprite *self, mgl_vec2f origin);
void mgl_sprite_draw(mgl_context *context, mgl_sprite *sprite);
#endif /* MGL_SPRITE_H */