From c7fb948e3970eeaccb143225ab10bc84689bd09f Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 7 Dec 2023 19:24:04 -0500 Subject: [PATCH] make refresh function public for sb::Text --- src/Text.cpp | 2 +- src/Text.hpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Text.cpp b/src/Text.cpp index 1288dd1..373c149 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -68,7 +68,7 @@ void Text::refresh() { /* Render the text with transparent background as RGBA pixel data using the SDL image library. */ // std::shared_ptr blended {TTF_RenderText_Blended(_font.get(), _content.c_str(), _foreground), SDL_FreeSurface}; - std::shared_ptr blended {TTF_RenderText_Blended_Wrapped(_font.get(), _content.c_str(), _foreground, 3000), SDL_FreeSurface}; + std::shared_ptr blended {TTF_RenderUTF8_Blended_Wrapped(_font.get(), _content.c_str(), _foreground, 3000), SDL_FreeSurface}; if (!blended) { Log::sdl_error("Could not create text"); diff --git a/src/Text.hpp b/src/Text.hpp index 3a8789c..5531597 100644 --- a/src/Text.hpp +++ b/src/Text.hpp @@ -25,16 +25,12 @@ namespace sb std::optional _dimensions; GLint _scaling_quality = GL_LINEAR; - /*! - * Load the texture with the appropriate SDL_Surface pixels created by the SDL TTF library. - */ - void refresh(); - public: /*! - * Construct a sb::Text object from a font, string, and background and foreground colors. A texture with the text rendered in the - * given colors will be created and attached to this object. + * Construct a sb::Text object from a font, string, and background and foreground colors. A texture will be created and attached. The + * texture is not generated or rendered. Text::refresh() must be called afterward with the GL context loaded. The content, dimensions, + * foreground, background, font, and scaling quality functions call Text::refresh() automatically. * * The font must be wrapped in a shared pointer. A default loaded font is available from Game::font(). * @@ -103,6 +99,11 @@ namespace sb */ void scaling_quality(GLint quality); + /*! + * Load the texture with the appropriate SDL_Surface pixels created by the SDL TTF library. + */ + void refresh(); + /*! * Convert the text object to a string with some debugging information. */