-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTextureManager.h
48 lines (36 loc) · 1.92 KB
/
TextureManager.h
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef TEXTUREMANAGER_H
#define TEXTUREMANAGER_H
#include<iostream>
#include<string>
#include<map>
#include<SDL2/SDL.h>
#include<SDL2/SDL_image.h>
using namespace std;
class TextureManager //its a SINGLETON (unitary class) it's called TextureManager::Instance->function
{
public:
//Constructors //////////////////////
static TextureManager* Instance() //////////////////////
{ //////////////////////
if(s_pInstance == 0) //////// SINGLETON ////
{ //////////////////////
s_pInstance = new TextureManager(); //////////////////////
} //////////////////////
//////////////////////
return s_pInstance; //////////////////////
}
//Methods
bool load(string fileName, string id, SDL_Renderer* pRenderer); //Load the image with the fileName, and assigns an id.
void draw (string id, int x, int y, int width, int height,
SDL_Renderer* pRenderer, SDL_RendererFlip = SDL_FLIP_NONE); //draw the static image.
void drawFrame(string id, int x, int y, int width, int height,
int currentRow, int currentFrame, SDL_Renderer* pRenderer, SDL_RendererFlip flip = SDL_FLIP_NONE); //draw image sprite
void clearFromTextureMap(string id); //delete SDL_Texture from the map
private:
map<string, SDL_Texture*> m_textureMap; //map with all the SDL_Textures
TextureManager(){}; //now is a SINGLETON
~TextureManager();
static TextureManager* s_pInstance; // Now in GOD-MODE SINGLETON
};
typedef TextureManager TheTextureManager;//Owned SINGLETON
#endif // TEXTUREMANAGER_H