# HG changeset patch # User David Demelier # Date 1586369100 -7200 # Node ID f17890fe144b2411d17046ed6075d8491bb13af1 # Parent d3bc14c1e24387ea7563bc85d488d40355f13cf7 image: can load a texture directly diff -r d3bc14c1e243 -r f17890fe144b src/core/font.c --- 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 diff -r d3bc14c1e243 -r f17890fe144b src/core/image.c --- 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 #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; }