Mercurial > molko
diff src/texture.c @ 26:65398df5fb5c
core: add texture_get_size function
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 12 Jan 2020 21:01:10 +0100 |
parents | c013f41a72a5 |
children | 783841af4033 |
line wrap: on
line diff
--- a/src/texture.c Fri Jan 10 20:08:26 2020 +0100 +++ b/src/texture.c Sun Jan 12 21:01:10 2020 +0100 @@ -22,6 +22,25 @@ #include "texture_p.h" #include "window_p.h" +bool +texture_get_size(struct texture *tex, uint16_t *w, uint16_t *h) +{ + assert(tex); + + int rw, rh; + + if (SDL_QueryTexture(tex->handle, NULL, NULL, &rw, &rh) < 0) { + *w = 0; + *h = 0; + return false; + } + + *w = rw; + *h = rh; + + return true; +} + void texture_draw(struct texture *tex, int x, int y) {