make refresh function public for sb::Text

This commit is contained in:
ohsqueezy 2023-12-07 19:24:04 -05:00
parent fb68938889
commit c7fb948e39
2 changed files with 9 additions and 8 deletions

View File

@ -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<SDL_Surface> blended {TTF_RenderText_Blended(_font.get(), _content.c_str(), _foreground), SDL_FreeSurface};
std::shared_ptr<SDL_Surface> blended {TTF_RenderText_Blended_Wrapped(_font.get(), _content.c_str(), _foreground, 3000), SDL_FreeSurface};
std::shared_ptr<SDL_Surface> blended {TTF_RenderUTF8_Blended_Wrapped(_font.get(), _content.c_str(), _foreground, 3000), SDL_FreeSurface};
if (!blended)
{
Log::sdl_error("Could not create text");

View File

@ -25,16 +25,12 @@ namespace sb
std::optional<glm::vec2> _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.
*/