|
CSD462 Library Documentation
1.0
15-462/15-662: Computer Graphics (Fall 2015)
|
Provides an interface for text on-screen display. More...
#include <osdtext.h>
Public Member Functions | |
| OSDText () | |
| Constructor. More... | |
| ~OSDText () | |
| Destructor. More... | |
| int | init () |
| Initializes resources required for rendering text. More... | |
| void | render () |
| Draw the text OSD. More... | |
| void | resize (size_t w, size_t h) |
| Resize internal scales when context size has changed. More... | |
| int | add_line (float x, float y, std::string text="", size_t size=16, Color color=Color::White) |
| Add a line of text to the OSD. More... | |
| void | del_line (int line_id) |
| Deletes a line. More... | |
| void | set_anchor (int line_id, float x, float y) |
| Set the anchor position of a given line. More... | |
| void | set_text (int line_id, std::string text) |
| Set the text of a given line. More... | |
| void | set_size (int line_id, size_t size) |
| Set the font size of a given line. More... | |
| void | set_color (int line_id, Color color) |
| Set the font color of a given line. More... | |
Provides an interface for text on-screen display.
Note that this requires GL_BLEND enabled to work. Do note this is a very basic implementation and the cost of all operations increases linearly with respect to the number of lines and the length of the lines.
| CSD462::OSDText::OSDText | ( | ) |
Constructor.
Creates an empty text OSD.
| CSD462::OSDText::~OSDText | ( | ) |
Destructor.
Destroys the textOSD instance and free resources.
| int CSD462::OSDText::init | ( | ) |
Initializes resources required for rendering text.
This will load a freetype font and compile shaders, etc.
| void CSD462::OSDText::render | ( | ) |
Draw the text OSD.
Render all the lines.
| void CSD462::OSDText::resize | ( | size_t | w, |
| size_t | h | ||
| ) |
Resize internal scales when context size has changed.
This should be called on a window resize, etc.
| int CSD462::OSDText::add_line | ( | float | x, |
| float | y, | ||
| std::string | text = "", |
||
| size_t | size = 16, |
||
| Color | color = Color::White |
||
| ) |
Add a line of text to the OSD.
This uses GL's screen space standard and maps the horizontal space to [-1, 1] from left to right and the vertical space to [-1, 1] from bottom to top.
| x | Horizontal coordinate of the anchor. |
| y | Vertical coordinate of the anchor. |
| text | The text to add. |
| size | The font size of the text. |
| color | The color of the text. |
| void CSD462::OSDText::del_line | ( | int | line_id | ) |
Deletes a line.
If the given id is not valid, the call has no effect.
| line_id | Index of the line to be removed. |
| void CSD462::OSDText::set_anchor | ( | int | line_id, |
| float | x, | ||
| float | y | ||
| ) |
Set the anchor position of a given line.
If the given id is not valid, the call has no effect.
| line_id | Index of the line to set the text. |
| x | The new x coordinate to set for the line. |
| y | The new y coordinate to set for the line. |
| void CSD462::OSDText::set_text | ( | int | line_id, |
| std::string | text | ||
| ) |
Set the text of a given line.
If the given id is not valid, the call has no effect.
| line_id | Index of the line to set the text. |
| text | The new text to set for the line. |
| void CSD462::OSDText::set_size | ( | int | line_id, |
| size_t | size | ||
| ) |
Set the font size of a given line.
If the given id is not valid, the call has no effect.
| line_id | Index of the line to set the text. |
| size | The new size to set for the line. |
| void CSD462::OSDText::set_color | ( | int | line_id, |
| Color | color | ||
| ) |
Set the font color of a given line.
If the given id is not valid, the call has no effect.
| line_id | Index of the line to set the text. |
| color | The new color to set for the line. |
1.8.9.1