libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
mx::Text Class Reference

Helper for rendering text strings with SDL_Renderer. More...

#include <font.hpp>

Public Member Functions

 Text ()=default
 Default constructor.
void setRenderer (SDL_Renderer *renderer)
 Set the SDL renderer used for all draw calls.
void setColor (SDL_Color color)
 Set the colour used when rendering text.
void printText_Solid (const Font &f, int x, int y, const std::string &text)
 Render text with solid (no anti-aliasing) blending.
void printText_Blended (const Font &f, int x, int y, const std::string &text)
 Render text with blended (anti-aliased) quality.

Private Attributes

SDL_Renderer * renderer = nullptr
 Active renderer.
SDL_Color color_value
 Current text colour.

Detailed Description

Helper for rendering text strings with SDL_Renderer.

Renders text glyphs onto the active SDL_Renderer using either solid (fast) or blended (anti-aliased) rendering modes.

Definition at line 117 of file font.hpp.

Constructor & Destructor Documentation

◆ Text()

mx::Text::Text ( )
default

Default constructor.

References renderer.

Member Function Documentation

◆ printText_Blended()

void mx::Text::printText_Blended ( const Font & f,
int x,
int y,
const std::string & text )

Render text with blended (anti-aliased) quality.

Parameters
fFont to use.
xX position in renderer coordinates.
yY position in renderer coordinates.
textString to render.

Definition at line 97 of file font.cpp.

References color_value, renderer, mx::system_err, and mx::Font::wrapper().

◆ printText_Solid()

void mx::Text::printText_Solid ( const Font & f,
int x,
int y,
const std::string & text )

Render text with solid (no anti-aliasing) blending.

Parameters
fFont to use.
xX position in renderer coordinates.
yY position in renderer coordinates.
textString to render.

Definition at line 79 of file font.cpp.

References color_value, renderer, mx::system_err, and mx::Font::wrapper().

◆ setColor()

void mx::Text::setColor ( SDL_Color color)

Set the colour used when rendering text.

Parameters
colorDesired text colour.

Definition at line 75 of file font.cpp.

References color_value.

◆ setRenderer()

void mx::Text::setRenderer ( SDL_Renderer * renderer)

Set the SDL renderer used for all draw calls.

Parameters
rendererActive SDL_Renderer.

Definition at line 72 of file font.cpp.

References renderer.

Member Data Documentation

◆ color_value

SDL_Color mx::Text::color_value
private

Current text colour.

Definition at line 153 of file font.hpp.

Referenced by printText_Blended(), printText_Solid(), and setColor().

◆ renderer

SDL_Renderer* mx::Text::renderer = nullptr
private

Active renderer.

Definition at line 152 of file font.hpp.

Referenced by printText_Blended(), printText_Solid(), setRenderer(), and Text().


The documentation for this class was generated from the following files: