-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextureManager.cpp
More file actions
28 lines (22 loc) · 843 Bytes
/
textureManager.cpp
File metadata and controls
28 lines (22 loc) · 843 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
#include "textureManager.hpp"
#include <iostream>
SDL_Texture* TextureManager::LoadTexture(const char * filename, SDL_Renderer* ren){
SDL_Surface *tmpSurface = IMG_Load(filename);
SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, tmpSurface);
SDL_FreeSurface(tmpSurface);
return tex;
}
SDL_Texture* TextureManager::LoadTextureFromFont(const char * fontFileName,int fontSize,const char* caption, SDL_Renderer *ren){
SDL_Color clr;
clr.r = 0x00;
clr.b = 0x00;
clr.g = 0x00;
clr.a = 0x00;
TTF_Font *font = TTF_OpenFont(fontFileName, fontSize);
if (font == NULL) std::cout <<fontFileName <<"noFont\n";
SDL_Surface *tmpSurface = TTF_RenderText_Solid(font, caption, clr);
SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, tmpSurface);
SDL_FreeSurface(tmpSurface);
TTF_CloseFont(font);
return tex;
}