-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextureManager.cpp
More file actions
executable file
·39 lines (34 loc) · 1.12 KB
/
Copy pathTextureManager.cpp
File metadata and controls
executable file
·39 lines (34 loc) · 1.12 KB
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
#include "TextureManager.hpp"
SDL_Texture *TextureManager::loadTexture(const char *texture)
{
SDL_Surface *tempSurface = IMG_Load(texture);
SDL_Texture *tex = SDL_CreateTextureFromSurface(Game::renderer, tempSurface);
SDL_FreeSurface(tempSurface);
return tex;
}
void TextureManager::Draw(SDL_Texture *tex, SDL_Rect src, SDL_Rect dest)
{
SDL_RenderCopy(Game::renderer, tex, &src, &dest);
}
void TextureManager::DrawGari(SDL_Texture *tex, SDL_Rect src, SDL_Rect dest, float angle)
{
// SDL_RenderCopy(Game::renderer, tex, &src, &dest);
SDL_RenderCopyEx(Game::renderer, tex, &src, &dest, angle, NULL, SDL_FLIP_NONE);
}
SDL_Texture *TextureManager::CreateTextTexture(TTF_Font *font, string text, Uint8 r, Uint8 g, Uint8 b)
{
SDL_Surface *tmpSurface = TTF_RenderText_Solid(font, text.c_str(), {r, g, b});
if (tmpSurface == NULL)
{
cout << "surface error";
exit(0);
}
SDL_Texture *tmpTex = SDL_CreateTextureFromSurface(Game::renderer, tmpSurface);
if (tmpTex == NULL)
{
cout << "surface error";
exit(0);
}
SDL_FreeSurface(tmpSurface);
return tmpTex;
}