6 if(file.substr(file.length() - 3) ==
"bmp")
loadBMP(file, ren);
7 if(file.substr(file.length() - 3) ==
"png")
loadPNG(file, ren);
14 SDL_Surface* surface = SDL_LoadBMP(file.c_str());
15 SDL_CHECK(surface,
"SDL_LoadBMP(\"file.c_str()\")");
16 tex = SDL_CreateTextureFromSurface(ren, surface);
17 SDL_CHECK(tex,
"SDL_CreateTextureFromSurface");
18 SDL_FreeSurface(surface);
22 SDL_Surface* loadedSurface = IMG_Load(filename.c_str());
23 if(loadedSurface == NULL) {
24 printf(
"Unable to load image %s! SDL_image Error: %s\n", filename.c_str(), IMG_GetError());
26 tex = SDL_CreateTextureFromSurface(ren, loadedSurface);
28 printf(
"Unable to create texture from %s! SDL Error: %s\n", filename.c_str(), SDL_GetError());
30 SDL_FreeSurface(loadedSurface);
void loadBMP(string file, SDL_Renderer *ren)
Load in a BMP image with the path to the BMP file and the renderer.
void loadImage(string file, SDL_Renderer *ren)
Load in either a BMP or PNG file with the path and renderer.
SDL_Texture * getTexture()
Get SDL_Texture.
void loadPNG(string file, SDL_Renderer *ren)
Load in a PNG image with the path to the PNG file and the renderer.