aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-18 13:36:52 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-18 13:36:52 +0100
commit0e800c6857122436e7a766c6934991aa1d8d31ff (patch)
treece5eb98a3b93b40b9535613b84eff3a7a4b1854a /src/crepe/facade/SDLContext.cpp
parent3c7373eba71ccf5f16069d540c9f66e297895b1a (diff)
parent81404db80bbf9463c3d535ae389e7fbb753a902c (diff)
Merge branch 'master' into loek/savemgrloek/savemgr
Diffstat (limited to 'src/crepe/facade/SDLContext.cpp')
-rw-r--r--src/crepe/facade/SDLContext.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index f331517..fffbe34 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);
+}