From e84717feb5a9435b96b6d10e77e699cea5d8bff9 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Mon, 16 Dec 2024 20:46:00 +0100 Subject: retrieving font with resource manager added --- src/example/loadfont.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/example/loadfont.cpp b/src/example/loadfont.cpp index 508197a..35afdf7 100644 --- a/src/example/loadfont.cpp +++ b/src/example/loadfont.cpp @@ -1,7 +1,9 @@ #include +#include #include #include #include +#include #include #include #include @@ -11,6 +13,7 @@ int main() { // SDLFontContext font_facade; Mediator mediator; SDLContext sdl_context{mediator}; + ResourceManager resource_manager{mediator}; try { // Correct way to create a unique pointer for Text std::unique_ptr label = std::make_unique( @@ -21,6 +24,14 @@ int main() { = std::make_unique(1, vec2(100, 100), vec2(0, 0), "test test", "fsaafdafsdafsdafsdasfdds", Text::Data{}); std::cout << "Path: " << label2->font.get_path() << std::endl; + ResourceManager & resource_mgr = mediator.resource_manager; + const Font & res = resource_manager.get(label->font); + TTF_Font * test_font = res.get_font(); + if(test_font == NULL){ + std::cout << "error with font" << std::endl; + }else{ + std::cout << "correct font retrieved" << std::endl; + } } catch (const std::exception & e) { std::cout << "Standard exception thrown: " << e.what() << std::endl; } -- cgit v1.2.3