Textogl  1.1.2
OpenGL Text renderer
Public Member Functions | List of all members
textogl::Static_text Class Reference

Object for text which does not change often. More...

#include <static_text.hpp>

Public Member Functions

 Static_text (Font_sys &font, const std::string &utf8_input)
 
void set_font_sys (Font_sys &font)
 Recreate text object with new Font_sys. More...
 
void set_text (const std::string &utf8_input)
 Recreate text object with new string. More...
 
void render_text (const Color &color, const Vec2< float > &win_size, const Vec2< float > &pos, const int align_flags=0)
 Render the previously set text. More...
 
void render_text_rotate (const Color &color, const Vec2< float > &win_size, const Vec2< float > &pos, const float rotation, const int align_flags=0)
 Render the previously set text, with rotation. More...
 
void render_text_mat (const Color &color, const Mat4< float > &model_view_projection)
 Render the previously set text, using a model view projection matrix. More...
 

Detailed Description

Object for text which does not change often.

Font_sys::render_text will re-build the OpenGL primitives on each call, which is inefficient if the text doesn't change every frame.

This class is for text that doesn't need to change frequently. Text is initially built with the Static_text constructor and can be changed with set_text.

Constructor & Destructor Documentation

◆ Static_text()

textogl::Static_text::Static_text ( Font_sys font,
const std::string &  utf8_input 
)

Create and build text object

Parameters
fontFont_sys object containing desired font. This Static_text will retain a shared_ptr to the Font_sys, but will not automatically rebuild when Font_sys::resize is called. Use Static_text::set_font_sys
utf8_inputText to render, in UTF-8 encoding. For best performance, normalize the string before rendering

Member Function Documentation

◆ render_text()

void textogl::Static_text::render_text ( const Color color,
const Vec2< float > &  win_size,
const Vec2< float > &  pos,
const int  align_flags = 0 
)

Render the previously set text.

Parameters
colorText Color
win_sizeWindow dimensions. A Vec2 with X = width and Y = height
posRender position, in screen pixels
align_flagsText Alignment. Should be Text_origin flags bitwise-OR'd together

◆ render_text_mat()

void textogl::Static_text::render_text_mat ( const Color color,
const Mat4< float > &  model_view_projection 
)

Render the previously set text, using a model view projection matrix.

Parameters
colorText Color
model_view_projectionModel view projection matrix. The text will be rendered as quads, one for each glyph, with vertex coordinates centered on the baselines and sized in pixels. This matrix will be used to transform that geometry

◆ render_text_rotate()

void textogl::Static_text::render_text_rotate ( const Color color,
const Vec2< float > &  win_size,
const Vec2< float > &  pos,
const float  rotation,
const int  align_flags = 0 
)

Render the previously set text, with rotation.

Parameters
colorText Color
win_sizeWindow dimensions. A Vec2 with X = width and Y = height
posRender position, in screen pixels
rotationClockwise text rotation (in radians) around center as defined in align_flags. 0 is vertical
align_flagsText Alignment. Should be Text_origin flags bitwise-OR'd together

◆ set_font_sys()

void textogl::Static_text::set_font_sys ( Font_sys font)

Recreate text object with new Font_sys.

When Font_sys::resize has been called, call this to rebuild this Static_text with the new size

Parameters
fontFont_sys object containing desired font.

◆ set_text()

void textogl::Static_text::set_text ( const std::string &  utf8_input)

Recreate text object with new string.

Parameters
utf8_inputText to render, in UTF-8 encoding. For best performance, normalize the string before rendering

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