Mercurial > molko
diff src/core/sprite.c @ 94:ed72843a7194
core: simplify font/texture interfaces
Expose the structure to avoid calling functions and heap allocations. While
here remove some useless functions.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 30 Mar 2020 13:34:42 +0200 |
parents | 52792b863ff7 |
children |
line wrap: on
line diff
--- a/src/core/sprite.c Thu Mar 26 10:28:11 2020 +0100 +++ b/src/core/sprite.c Mon Mar 30 13:34:42 2020 +0200 @@ -19,7 +19,6 @@ #include <assert.h> #include "sprite.h" -#include "texture_p.h" #include "texture.h" void @@ -28,20 +27,14 @@ unsigned int cellw, unsigned int cellh) { - int w = 0; - int h = 0; - assert(sprite); - assert(tex); - - /* TODO: use texture_get_size */ - SDL_QueryTexture(tex->handle, NULL, NULL, &w, &h); + assert(tex && texture_ok(tex)); sprite->texture = tex; sprite->cellw = cellw; sprite->cellh = cellh; - sprite->nrows = h / cellh; - sprite->ncols = w / cellw; + sprite->nrows = tex->h / cellh; + sprite->ncols = tex->w / cellw; } void @@ -49,7 +42,7 @@ { assert(sprite); - texture_draw_ex( + texture_scale( sprite->texture, c * sprite->cellw, /* src y */ r * sprite->cellh, /* src x */