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

Glyph cache that maps each ASCII character to a pre-rendered SDL_Surface. More...

#include <console.hpp>

Collaboration diagram for console::ConsoleChars:
[legend]

Public Member Functions

 ConsoleChars ()
 ~ConsoleChars ()
 ConsoleChars (const ConsoleChars &)=delete
ConsoleChars & operator= (const ConsoleChars &)=delete
 ConsoleChars (ConsoleChars &&)=delete
ConsoleChars & operator= (ConsoleChars &&)=delete
void load (const std::string &fnt, int size, const SDL_Color &c)
 Load/reload the glyph cache from a font file.
void clear ()
 Release all cached SDL_Surface objects.

Public Attributes

std::unordered_map< char, SDL_Surface * > characters
 Glyph surfaces keyed by char.

Protected Attributes

std::unique_ptr< mx::Font > font

Detailed Description

Glyph cache that maps each ASCII character to a pre-rendered SDL_Surface.

Surfaces are produced via SDL_ttf and stored in an unordered_map keyed by char. Recreate by calling load() after font changes.

Definition at line 111 of file console.hpp.

Constructor & Destructor Documentation

◆ ConsoleChars() [1/3]

console::ConsoleChars::ConsoleChars ( )

Definition at line 30 of file console.cpp.

References font.

Referenced by ConsoleChars(), ConsoleChars(), operator=(), and operator=().

◆ ~ConsoleChars()

console::ConsoleChars::~ConsoleChars ( )

Definition at line 37 of file console.cpp.

References clear().

◆ ConsoleChars() [2/3]

console::ConsoleChars::ConsoleChars ( const ConsoleChars & )
delete

References ConsoleChars().

◆ ConsoleChars() [3/3]

console::ConsoleChars::ConsoleChars ( ConsoleChars && )
delete

References ConsoleChars().

Member Function Documentation

◆ clear()

void console::ConsoleChars::clear ( )

Release all cached SDL_Surface objects.

Definition at line 57 of file console.cpp.

References characters, and font.

Referenced by load(), and ~ConsoleChars().

◆ load()

void console::ConsoleChars::load ( const std::string & fnt,
int size,
const SDL_Color & c )

Load/reload the glyph cache from a font file.

Parameters
fntPath to a TTF font file.
sizePoint size.
cColour applied to each glyph surface.

Definition at line 41 of file console.cpp.

References characters, clear(), and font.

◆ operator=() [1/2]

ConsoleChars & console::ConsoleChars::operator= ( ConsoleChars && )
delete

References ConsoleChars().

◆ operator=() [2/2]

ConsoleChars & console::ConsoleChars::operator= ( const ConsoleChars & )
delete

References ConsoleChars().

Member Data Documentation

◆ characters

std::unordered_map<char, SDL_Surface *> console::ConsoleChars::characters

Glyph surfaces keyed by char.

Definition at line 132 of file console.hpp.

Referenced by clear(), and load().

◆ font

std::unique_ptr<mx::Font> console::ConsoleChars::font
protected

Definition at line 134 of file console.hpp.

Referenced by clear(), ConsoleChars(), and load().


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