jubilant-funicular
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
nta::SpriteFont Class Reference

Loads in a .ttf file, creates a font texture from it which is then used to render text. More...

#include <SpriteFont.h>

Collaboration diagram for nta::SpriteFont:
Collaboration graph
[legend]

Public Member Functions

 ~SpriteFont ()
 destructor
 
glm::vec2 measure (crstring text) const
 returns the dimensions of the rectangle containing the text
 
int font_height () const
 returns m_fontHeight
 
GLuint getTexture () const
 Returns the (id of) the texture used for rendering font.
 
void drawText (SpriteBatch &batch, crstring text, crvec2 topLeft, crvec2 scale, crvec4 color=glm::vec4(1), float depth=NTA_DEFAULT_DEPTH) const
 renders text with specified location, color, scale, etc.
 
void drawText (SpriteBatch &batch, crstring text, crvec4 posRect, crvec4 color=glm::vec4(1), float depth=NTA_DEFAULT_DEPTH) const
 
void drawText (SpriteBatch &batch, crvec2 corner1, crvec2 corner2, crstring text, crvec4 color=glm::vec4(1), float depth=NTA_DEFAULT_DEPTH) const
 
void drawTexture (SpriteBatch &batch, crvec4 posRect=glm::vec4(-100, 100, 200, 200)) const
 renders texture
 
void destroy ()
 Destroys this SpriteFont.
 

Public Attributes

friend ContextData
 

Private Member Functions

void init (TTF_Font *font)
 

Private Attributes

CharGlyphm_charGlyphs = nullptr
 a collection of glyphs for each char
 
GLuint m_texId = 0
 the idea of the generated texture
 
int m_fontHeight = 0
 the height of the font
 

Detailed Description

Loads in a .ttf file, creates a font texture from it which is then used to render text.

Definition at line 55 of file SpriteFont.h.

Member Function Documentation

◆ init()

void nta::SpriteFont::init ( TTF_Font *  font)
private

Initializes the SpriteFont

Creates a texture from the font

Todo:
Rename now that we're no longer using simulated annealing

Definition at line 5 of file SpriteFont.cpp.


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