diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-18 13:26:04 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-18 13:26:04 +0100 |
commit | a444da0b35123a9e51cde1f5be9aab0204eb5b66 (patch) | |
tree | cb3c02bbd94b2750c57c4579de5f7f8def05f324 /src/crepe/facade/SDLContext.cpp | |
parent | f71769f7d2e9530a49295d0c0c86c2f6add069d8 (diff) | |
parent | 81404db80bbf9463c3d535ae389e7fbb753a902c (diff) |
merge master
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); +} |