GL Studio SCECpp Runtime Library
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
GlsFontBase Class Reference

#include <gls_font_base.h>

Classes

struct  FontAttributes
 
struct  GlyphAttribute
 
struct  InitParameters
 
struct  RenderAttributes
 

Public Types

typedef GlsUInt32 CharCode
 

Public Member Functions

void BindFontTexture (GlsStateManager &gl) const
 
void RenderString (GlsStateManager &gl, const GlsChar *const str, const GlsUInt32 numChars, const RenderAttributes &renderAttributes) const
 
const FontAttributesGetFontAttributes (void) const
 
const GlyphAttributeGetGlyphAttribute (const GlsChar c, const GlsBool uppercase) const
 

Static Public Attributes

static const GlsChar TAB_CHAR
 

Protected Member Functions

 GlsFontBase (const InitParameters &initParameters)
 
void DrawMappedQuad (const GlsVector2D &p1, const GlsVector2D &p2, const GlsVector2D &t1, const GlsVector2D &t2) const
 
virtual ~GlsFontBase ()
 

Protected Attributes

const FontAttributes _fontAttributes
 
const GlsUInt32 _numGlyphAttributes
 
GlyphAttribute *const _glyphAttributes
 
const GlsImage *const _fontImage
 

Detailed Description

This class serves as the base class for all fonts

Invariant
_fontAttributes.IsValid(), _numGlyphAttributes > 0, _glyphAttributes != GLS_NULL and array contains valid elements, _fontImage invariant holds

Member Typedef Documentation

code associated with a character in the font

Constructor & Destructor Documentation

GlsFontBase::GlsFontBase ( const InitParameters initParameters)
protected

Constructor - called by derived font classes

Parameters
initParametersinitialization parameters
Precondition
initParameters.IsValid(), a GlsStateManager instance does not yet exist
Postcondition
object is constructed
virtual GlsFontBase::~GlsFontBase ( )
protectedvirtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

void GlsFontBase::BindFontTexture ( GlsStateManager gl) const

Initializes the font to begin rendering characters. This will bind the font's texture. This must be called once before invoking RenderString to draw characters.

Parameters
glstate manager for OpenGL
Precondition
none
Postcondition
2D texturing is enabled in GL and the font texture is bound to OpenGL with the GL_MODULATE texture env mode
void GlsFontBase::DrawMappedQuad ( const GlsVector2D p1,
const GlsVector2D p2,
const GlsVector2D t1,
const GlsVector2D t2 
) const
protected

Issue the GL vertex and texture coordinates for the quad described by the given points and texture coordinates

Parameters
p1first corner of quad
p2opposite corner of quad
t1texture coord for first corner
t2texture coord for opposite corner
Precondition
p1.IsValid(), p2.IsValid(), t1.IsValid(), t2.IsValid()
Postcondition
GL vertex and texture coordinates for the quad are issued to GL
const FontAttributes& GlsFontBase::GetFontAttributes ( void  ) const

Get the font attributes for this font

Returns
font attributes for this font
Precondition
none
Postcondition
none
const GlyphAttribute& GlsFontBase::GetGlyphAttribute ( const GlsChar  c,
const GlsBool  uppercase 
) const

Get the glyph attributes for a given char

Parameters
cchar in question
uppercaseGLS_TRUE to use uppercase version of char else GLS_FALSE
Returns
glyph attributes for c else glyph attributes for first character in font if c is not in range for this font
Precondition
none
Postcondition
none
void GlsFontBase::RenderString ( GlsStateManager gl,
const GlsChar *const  str,
const GlsUInt32  numChars,
const RenderAttributes renderAttributes 
) const

Renders the specified character string with the given render attributes.

Parameters
glState Manager for OpenGL where character will be drawn
strstring to render ( must contain at least numChars characters )
numCharsnumber of characters in str to render (>0)
renderAttributesdesired render attributes for character
Precondition
str != GLS_NULL, numChars > 0, renderAttributues.IsValid(), font texture is bound to GL using BindFontTexture() and setup with the desired texture filter modes
Postcondition
string is drawn to OpenGL

Member Data Documentation

const FontAttributes GlsFontBase::_fontAttributes
protected

font attributes

const GlsImage* const GlsFontBase::_fontImage
protected

font texture

GlyphAttribute* const GlsFontBase::_glyphAttributes
protected

array of glyph attributes

const GlsUInt32 GlsFontBase::_numGlyphAttributes
protected

number of glyph attribues in glyphAttributes array

const GlsChar GlsFontBase::TAB_CHAR
static

tab character constant