Mercurial > molko
changeset 111:f17890fe144b
image: can load a texture directly
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 08 Apr 2020 20:05:00 +0200 |
parents | d3bc14c1e243 |
children | 40f22a8188d2 |
files | src/core/font.c src/core/image.c |
diffstat | 2 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/font.c Thu Apr 02 18:22:27 2020 +0200 +++ b/src/core/font.c Wed Apr 08 20:05:00 2020 +0200 @@ -26,7 +26,6 @@ #include "error.h" #include "error_p.h" #include "font.h" -#include "texture_p.h" #include "util.h" bool
--- a/src/core/image.c Thu Apr 02 18:22:27 2020 +0200 +++ b/src/core/image.c Wed Apr 08 20:05:00 2020 +0200 @@ -22,7 +22,9 @@ #include <SDL_image.h> #include "error_p.h" -#include "texture_p.h" +#include "texture.h" +#include "window.h" +#include "window_p.h" bool image_open(struct texture *tex, const char *path) @@ -30,12 +32,10 @@ assert(tex); assert(path); - SDL_Surface *surface = IMG_Load(path); - - if (!surface) + if (!(tex->handle = IMG_LoadTexture(RENDERER(), path))) return error_sdl(); - return texture_from_surface(tex, surface); + return true; } bool @@ -44,10 +44,9 @@ assert(buffer); SDL_RWops *ops = SDL_RWFromConstMem(buffer, size); - SDL_Surface *surface; - if (!ops || !(surface = IMG_Load_RW(ops, true))) + if (!ops || !(tex->handle = IMG_LoadTexture_RW(RENDERER(), ops, true))) return error_sdl(); - return texture_from_surface(tex, surface); + return true; }