mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-13 14:53:41 +00:00
added error throwing for texture load
makes runtime error more descriptive
This commit is contained in:
parent
7bc17eb8b9
commit
06042583f8
@ -1,5 +1,7 @@
|
|||||||
#include "TextureManager.h"
|
#include "TextureManager.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
SDL_Texture* TextureManager::loadTexture(const char* fileName)
|
SDL_Texture* TextureManager::loadTexture(const char* fileName)
|
||||||
@ -9,6 +11,7 @@ SDL_Texture* TextureManager::loadTexture(const char* fileName)
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
auto texture = IMG_LoadTexture(Game::renderer, fileName);
|
auto texture = IMG_LoadTexture(Game::renderer, fileName);
|
||||||
|
if (texture == NULL) throw std::runtime_error(std::string("Couldn't load texture '") + fileName + "'");
|
||||||
this->texture_cache.emplace(fileName, texture);
|
this->texture_cache.emplace(fileName, texture);
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user