diff options
Diffstat (limited to 'src/crepe/facade/SDLContext.cpp')
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 8cbec72..9486ccd 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -6,6 +6,8 @@ #include <SDL2/SDL_rect.h> #include <SDL2/SDL_render.h> #include <SDL2/SDL_surface.h> +#include <SDL2/SDL_ttf.h> +#include <SDL2/SDL_video.h> #include <array> #include <cmath> #include <cstddef> @@ -30,6 +32,9 @@ using namespace std; SDLContext::SDLContext(Mediator & mediator) { dbg_trace(); + if (TTF_Init() == -1) { + throw runtime_error(format("SDL_ttf initialization failed: {}", TTF_GetError())); + } if (SDL_Init(SDL_INIT_VIDEO) != 0) { throw runtime_error(format("SDLContext: SDL_Init error: {}", SDL_GetError())); } @@ -71,6 +76,7 @@ SDLContext::~SDLContext() { // thread that SDL_Init() was called on? This has caused problems for me // before. IMG_Quit(); + TTF_Quit(); SDL_Quit(); } @@ -407,3 +413,7 @@ void SDLContext::set_color_texture(const Texture & texture, const Color & color) SDL_SetTextureColorMod(texture.get_img(), color.r, color.g, color.b); SDL_SetTextureAlphaMod(texture.get_img(), color.a); } + +Asset SDLContext::get_font_from_name(const std::string & font_family) { + return this->font_facade.get_font_asset(font_family); +} |