#include <ttf.h>
Collaboration diagram for gl::ttf:
Public Types | |
typedef std::hash_map< char, glyph *, std::hash< char >, eqchar > | glyph_hash |
Hash of glyphs. | |
Public Methods | |
ttf (void) | |
Constructor. | |
ttf (const ttf &cpy) | |
Copy Constructor. | |
~ttf (void) | |
Destructor. | |
ttf & | operator= (const ttf &cpy) |
Assignment operator. | |
void | render_string (real_t &x, real_t &y, real_t size, const std::string &text) const |
Renders a string of text to the screen. More... | |
std::string | get_name (void) const |
Returns the name (filename) of the font. | |
operator bool (void) const | |
Returns true if the font is not in an error state. | |
texture | get_texture (void) const |
Returns a gl::texture to the texture that stores this font's glyphs. | |
Static Public Methods | |
ttf * | load (const std::string &filename, unsigned int pt_size) |
Loads a font from a file. |
This object enables the rendering of high quality true type fonts to an OpenGL context. Using this object is as simple as:
//load the font (32 is the request height of the font in pixels) gl::ttf *font = gl::ttf::load( "myfont.ttf", 32 ); if( !font) { std::cerr << "could not load font" << std::endl; } //render a string to the screen int x = 0, y = 0; video.render( x, y, font, 32, "I like chessee." ); //x and y now contain the location of the last rendered pixel
Note that the easiest way to render strings is to use Uber's virtual coordinate system with video_base::render_string.
Also note that if you plan on making multiple calls to video_base::render_string it may be benificial to call video_base::enable_2d to avoid unneccessay 2d/3d state flips.
See demos/fontviewer for a demo using this object.
Definition at line 56 of file ttf.h.
|
Renders a string of text to the screen. Renders a string of text to the screen. All values are in frame buffer coordinates NOT virtual coordinates. If you want to use Uber's virtual coordinate system, use video_base::render_string. (0,0) is located at the lower left hand corner of the screen.
Definition at line 52 of file ttf.cpp. References real_t. Referenced by video_base::render_shadowed_string, and video_base::render_string. |