xoreos  0.0.5
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Graphics::Aurora::TextureFont Class Reference

A texture font, as used by NWN and KotOR/KotOR2. More...

#include <texturefont.h>

Inheritance diagram for Graphics::Aurora::TextureFont:
Inheritance graph
[legend]
Collaboration diagram for Graphics::Aurora::TextureFont:
Collaboration graph
[legend]

Classes

struct  Char
 A font character. More...
 

Public Member Functions

 TextureFont (const Common::UString &name)
 
 ~TextureFont ()
 
float getWidth (uint32 c) const
 Return the width of a character. More...
 
float getHeight () const
 Return the height of a character. More...
 
float getLineSpacing () const
 Return the size of space between lines. More...
 
void draw (uint32 c) const
 Draw this character. More...
 
virtual void renderBind (const glm::mat4 &transform) const
 Bind the font for rendering. More...
 
virtual void render (uint32 c, float &x, float &y, float *rgba) const
 
virtual void renderUnbind () const
 
- Public Member Functions inherited from Graphics::Font
 Font ()
 
virtual ~Font ()
 
size_t getLineCount (const Common::UString &text, float maxWidth=0.0f, float maxHeight=0.0f) const
 Return the number of lines this text spans. More...
 
float getWidth (const Common::UString &text, float maxWidth=0.0f) const
 Return the width this string would take. More...
 
float getHeight (const Common::UString &text, float maxWidth=0.0f, float maxHeight=0.0f) const
 Return the height this string would take. More...
 
float getLineWidth (const Common::UString &text) const
 Return the width of this string. More...
 
virtual void buildChars (const Common::UString &str)
 Build all necessary characters to display this string. More...
 
float split (const Common::UString &line, std::vector< Common::UString > &lines, float maxWidth=0.0f, float maxHeight=0.0f, bool trim=true) const
 
float split (Common::UString &line, float maxWidth, float maxHeight=0.0f, bool trim=true) const
 
float split (const Common::UString &line, Common::UString &lines, float maxWidth, float maxHeight=0.0f, bool trim=true) const
 

Private Member Functions

void load ()
 
void drawMissing () const
 

Private Attributes

TextureHandle _texture
 
std::map< uint32, Char_chars
 
float _height
 
float _spaceR
 
float _spaceB
 
Mesh::MeshFont_mesh
 
Shader::ShaderMaterial_material
 
Shader::ShaderRenderable_renderable
 

Detailed Description

A texture font, as used by NWN and KotOR/KotOR2.

Definition at line 51 of file texturefont.h.

Constructor & Destructor Documentation

◆ TextureFont()

Graphics::Aurora::TextureFont::TextureFont ( const Common::UString name)

◆ ~TextureFont()

Graphics::Aurora::TextureFont::~TextureFont ( )

Definition at line 77 of file texturefont.cpp.

References _material, and _renderable.

Member Function Documentation

◆ draw()

void Graphics::Aurora::TextureFont::draw ( uint32  c) const
virtual

Draw this character.

Implements Graphics::Font.

Definition at line 116 of file texturefont.cpp.

References _chars, _spaceR, _texture, drawMissing(), and TextureMan.

Here is the call graph for this function:

◆ drawMissing()

void Graphics::Aurora::TextureFont::drawMissing ( ) const
private

Definition at line 101 of file texturefont.cpp.

References _height, _spaceR, getWidth(), and TextureMan.

Referenced by draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHeight()

float Graphics::Aurora::TextureFont::getHeight ( ) const
virtual

Return the height of a character.

Implements Graphics::Font.

Definition at line 93 of file texturefont.cpp.

References _height.

◆ getLineSpacing()

float Graphics::Aurora::TextureFont::getLineSpacing ( ) const
virtual

Return the size of space between lines.

Reimplemented from Graphics::Font.

Definition at line 97 of file texturefont.cpp.

References _spaceB.

◆ getWidth()

float Graphics::Aurora::TextureFont::getWidth ( uint32  c) const
virtual

Return the width of a character.

Implements Graphics::Font.

Definition at line 82 of file texturefont.cpp.

References _chars, and _spaceR.

Referenced by drawMissing().

Here is the caller graph for this function:

◆ load()

void Graphics::Aurora::TextureFont::load ( )
private

◆ render()

void Graphics::Aurora::TextureFont::render ( uint32  c,
float &  x,
float &  y,
float *  rgba 
) const
virtual

Reimplemented from Graphics::Font.

Definition at line 153 of file texturefont.cpp.

References _chars, _mesh, _spaceR, and Graphics::Mesh::MeshFont::render().

Here is the call graph for this function:

◆ renderBind()

void Graphics::Aurora::TextureFont::renderBind ( const glm::mat4 &  transform) const
virtual

Bind the font for rendering.

Must be performed before render is called.

Parameters
transformBase modelview transform. Under most circumstances this is expected to be the identity matrix.

Mesh data will be dynamically updated for each character drawn to the screen (at least for now), so make sure the mesh VBO is bound. This isn't required for GL2.1, but is for GL3.2 because using the VAO doesn't automatically bind the VBO for data updates.

Reimplemented from Graphics::Font.

Definition at line 136 of file texturefont.cpp.

References _material, _mesh, _renderable, Graphics::Shader::ShaderSurface::bindGLState(), Graphics::Shader::ShaderMaterial::bindGLState(), Graphics::Shader::ShaderSurface::bindProgram(), Graphics::Shader::ShaderMaterial::bindProgram(), Graphics::Shader::ShaderRenderable::getProgram(), Graphics::Shader::ShaderRenderable::getSurface(), Graphics::VertexBuffer::getVBO(), Graphics::Mesh::Mesh::getVertexBuffer(), Graphics::Shader::ShaderProgram::glid, and Graphics::Mesh::Mesh::renderBind().

Here is the call graph for this function:

◆ renderUnbind()

void Graphics::Aurora::TextureFont::renderUnbind ( ) const
virtual

Member Data Documentation

◆ _chars

std::map<uint32, Char> Graphics::Aurora::TextureFont::_chars
private

Definition at line 82 of file texturefont.h.

Referenced by draw(), getWidth(), load(), and render().

◆ _height

float Graphics::Aurora::TextureFont::_height
private

Definition at line 84 of file texturefont.h.

Referenced by drawMissing(), getHeight(), and load().

◆ _material

Shader::ShaderMaterial* Graphics::Aurora::TextureFont::_material
private

Definition at line 89 of file texturefont.h.

Referenced by renderBind(), renderUnbind(), TextureFont(), and ~TextureFont().

◆ _mesh

Mesh::MeshFont* Graphics::Aurora::TextureFont::_mesh
private

Definition at line 88 of file texturefont.h.

Referenced by render(), renderBind(), renderUnbind(), and TextureFont().

◆ _renderable

Shader::ShaderRenderable* Graphics::Aurora::TextureFont::_renderable
private

Definition at line 90 of file texturefont.h.

Referenced by renderBind(), renderUnbind(), TextureFont(), and ~TextureFont().

◆ _spaceB

float Graphics::Aurora::TextureFont::_spaceB
private

Definition at line 86 of file texturefont.h.

Referenced by getLineSpacing(), and load().

◆ _spaceR

float Graphics::Aurora::TextureFont::_spaceR
private

Definition at line 85 of file texturefont.h.

Referenced by draw(), drawMissing(), getWidth(), load(), and render().

◆ _texture

TextureHandle Graphics::Aurora::TextureFont::_texture
private

Definition at line 80 of file texturefont.h.

Referenced by draw(), load(), and TextureFont().


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