Stores character glyphs corresponding to a ttf file and draws text to the screen.
More...
#include <Font.hpp>
|
| | Font ()=delete |
| | do not allow default Font objects to be constructed
|
| |
| | Font (const char *filename) |
| | Create a Font object containing the glyphs from a given ttf file.
|
| |
|
| ~Font () |
| | cleanup CPU and GPU memory
|
| |
| GLboolean | isLoaded () const |
| | tracks if font file was loaded successfully
|
| |
| void | setScale (GLfloat scaleX, GLfloat scaleY) |
| | set the amount to scale each glyph when drawing
|
| |
| void | bind () const |
| | make this font active, binding its VAO, VBO, and 2D texture to GL_TEXTURE0
|
| |
| void | draw (const char *str, GLfloat x, GLfloat y) const |
| | draws a text string at a given (x,y) window coordinate with the currently set scale
|
| |
Stores character glyphs corresponding to a ttf file and draws text to the screen.
◆ Font() [1/2]
◆ Font() [2/2]
| CSCI441::Font::Font |
( |
const char * |
filename | ) |
|
|
inlineexplicit |
Create a Font object containing the glyphs from a given ttf file.
- Parameters
-
| filename | ttf file to load glyphs from |
◆ bind()
| void CSCI441::Font::bind |
( |
| ) |
const |
|
inline |
make this font active, binding its VAO, VBO, and 2D texture to GL_TEXTURE0
- Note
- must be called immediately before CSCI441::Font::draw()
◆ draw()
| void CSCI441::Font::draw |
( |
const char * |
str, |
|
|
GLfloat |
x, |
|
|
GLfloat |
y |
|
) |
| const |
|
inline |
draws a text string at a given (x,y) window coordinate with the currently set scale
- Parameters
-
| str | string to display |
| x | window X-coordinate to draw text at |
| y | window Y-coordinate to draw text at |
- Precondition
- MUST call CSCI441::Font::bind() prior to this call
- Note
- see CSCI441::Font::setScale()
◆ isLoaded()
| GLboolean CSCI441::Font::isLoaded |
( |
| ) |
const |
|
inline |
tracks if font file was loaded successfully
- Returns
- true iff font file was successfully loaded
◆ setScale()
| void CSCI441::Font::setScale |
( |
GLfloat |
scaleX, |
|
|
GLfloat |
scaleY |
|
) |
| |
|
inline |
set the amount to scale each glyph when drawing
- Parameters
-
| scaleX | amount to scale glyph horizontally |
| scaleY | amount to scale glyph vertically |
- Note
- values typically refer to inverse screen size, e.g. the size of each pixel
The documentation for this class was generated from the following file: