-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextureManager.cpp
More file actions
34 lines (27 loc) · 788 Bytes
/
Copy pathTextureManager.cpp
File metadata and controls
34 lines (27 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// Created by Blas Antunez on 8/9/24.
//
#include "TextureManager.h"
// "redeclare" the variable, so this file knows that is exists
unordered_map<string, sf::Texture> TextureManager::textures;
void TextureManager::LoadTexture(string filename)
{
string path = "../images/";
path += filename + ".png";
// EXAMPLE
// filename == space
// path == images/space.png
textures[filename].loadFromFile(path);
}
sf::Texture& TextureManager::GetTexture(string textureName)
{
// if the texture does not exist...
if (textures.find(textureName) == textures.end()) // we did not find it
// load it first? Then return it?
LoadTexture(textureName);
return textures[textureName];
}
void TextureManager::Clear()
{
textures.clear(); // get rid of all stored objects in unordered map
}