Textogl
1.1.2
OpenGL Text renderer
|
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... | |
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.
textogl::Static_text::Static_text | ( | Font_sys & | font, |
const std::string & | utf8_input | ||
) |
Create and build text object
font | Font_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_input | Text to render, in UTF-8 encoding. For best performance, normalize the string before rendering |
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.
color | Text Color |
win_size | Window dimensions. A Vec2 with X = width and Y = height |
pos | Render position, in screen pixels |
align_flags | Text Alignment. Should be Text_origin flags bitwise-OR'd together |
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.
color | Text Color |
model_view_projection | Model 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 |
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.
color | Text Color |
win_size | Window dimensions. A Vec2 with X = width and Y = height |
pos | Render position, in screen pixels |
rotation | Clockwise text rotation (in radians) around center as defined in align_flags. 0 is vertical |
align_flags | Text Alignment. Should be Text_origin flags bitwise-OR'd together |
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
font | Font_sys object containing desired font. |
void textogl::Static_text::set_text | ( | const std::string & | utf8_input | ) |
Recreate text object with new string.
utf8_input | Text to render, in UTF-8 encoding. For best performance, normalize the string before rendering |