Skip to content

Instantly share code, notes, and snippets.

@lheckemann
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lheckemann/f26acef9789934135641 to your computer and use it in GitHub Desktop.
Save lheckemann/f26acef9789934135641 to your computer and use it in GitHub Desktop.
#include <string>
#include <SDL.h>
#include <SDL_image.h>
SDL_Texture * load_image(SDL_Renderer* renderer, std::string path) {
SDL_Texture * result;
SDL_Surface * surf = IMG_Load(path.c_str());
if (!surf) {
return NULL;
}
result = SDL_CreateTextureFromImage(renderer, surf);
SDL_FreeSurface(surf);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment