| GL Studio C++ Runtime API

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GlsFontRenderer Class Reference

`#include <gls_font_renderer.h>`

## Public Types
typedef GlsFontBase::Char_t | Char_t
| Shorthand for GlsFontBase::Char_t.
typedef GlsFontBase::CharAttr_t | CharAttr_t
| Shorthand for GlsFontBase::CharAttr_t.

## Public Member Functions
unsigned char | TextureMinFilter ()
void | TextureMinFilter (unsigned char val)
unsigned char | TextureMagFilter ()
void | TextureMagFilter (unsigned char val)
void | SetFont (const GlsFontBase *font)
const GlsFontBase * | GetFont ()
void | InitRendering (unsigned char textureMinFilter, unsigned char textureMagFilter, IGlsStateManager *stateManager)
void | InitRendering (IGlsStateManager *stateManager)
void | DrawCharacter (const bool emphasize, const float emphasisOffset, const bool inverse, GlsQuadListVCT_2D &quadStorage, const GLfloat x1, const GLfloat y1, const GLfloat x2, const GLfloat y2) const
void | DrawCharacter (const bool emphasize, const float emphasisOffset, GlsQuadListVCT_2D &quadStorage, const GLfloat x1, const GLfloat y1, const GLfloat x2, const GLfloat y2) const
void | DrawHalo (const float haloOffset, const float diagonalOffset, GlsQuadListVCT_2D &quadStorage, const GLfloat x1, const GLfloat y1, const GLfloat x2, const GLfloat y2) const
| GlsFontRenderer (const GlsFontBase *font)

## Protected Member Functions
void | SetupTexture (IFontImage *texture, IGlsStateManager *stateManager)

## Protected Attributes
const GlsFontBase * | _font
unsigned char | _textureMinFilter
unsigned char | _textureMagFilter

## Detailed Description

The GlsFontRenderer object can be used to render characters from a GlsFontBase in Open GL at specific locations and with several different text effects. Prior to rendering any characters, InitRendering must be invoked to set up the proper drawing environment. Then call Render for each character to be drawn.

See also
  GlsFontBase

## Constructor & Destructor Documentation

## ◆ GlsFontRenderer()

GlsFontRenderer | ( | const GlsFontBase * | font | ) |
| inline

Create a GlsFontRenderer with the default settings.

Parameters

  font | The font to use for rendering. This may be NULL on creation, but it must be set before rendering.

## Member Function Documentation

## ◆ DrawCharacter() [1/2]

void DrawCharacter | ( | const bool | emphasize,
|  | const float | emphasisOffset,
|  | const bool | inverse,
|  | GlsQuadListVCT_2D & | quadStorage,
|  | const GLfloat | x1,
|  | const GLfloat | y1,
|  | const GLfloat | x2,
|  | const GLfloat | y2
| ) |  | const
| inline

Draw a character by adding it into the supplied QuadStorage object

Deprecated:
  inverse no longer has any effect, use the other overload instead.

Parameters

  emphasize | Whether to draw with emphasize or not
  emphasisOffset | If drawing with emphasize, the offset in logical units
  inverse | Deprecated, has no effect
  quadStorage | The quad storage object to render the characters into
  x1 | lower left corner x coordinate of the polygon
  y1 | lower left corner y coordinate of the polygon
  x2 | upper right corner x coordinate of the polygon
  y2 | upper right corner y coordinate of the polygon

## ◆ DrawCharacter() [2/2]

void DrawCharacter | ( | const bool | emphasize,
|  | const float | emphasisOffset,
|  | GlsQuadListVCT_2D & | quadStorage,
|  | const GLfloat | x1,
|  | const GLfloat | y1,
|  | const GLfloat | x2,
|  | const GLfloat | y2
| ) |  | const
| inline

Draw a character by adding it into the supplied QuadStorage object

Parameters

  emphasize | Whether to draw with emphasize or not
  emphasisOffset | If drawing with emphasize, the offset in logical units
  quadStorage | The quad storage object to render the characters into
  x1 | lower left corner x coordinate of the polygon
  y1 | lower left corner y coordinate of the polygon
  x2 | upper right corner x coordinate of the polygon
  y2 | upper right corner y coordinate of the polygon

## ◆ DrawHalo()

void DrawHalo | ( | const float | haloOffset,
|  | const float | diagonalOffset,
|  | GlsQuadListVCT_2D & | quadStorage,
|  | const GLfloat | x1,
|  | const GLfloat | y1,
|  | const GLfloat | x2,
|  | const GLfloat | y2
| ) |  | const
| inline

Draws a halo effect for the given character.

Parameters

  haloOffset | Controls the size of the halo GlsTextGrid uses: (emphasize ? 0.05f : 0.03f) * (character_width) (x2 - x1)
  diagonalOffset | The offset to use for the four diagonal directions.
  quadStorage | A list containing 2D quads from the generated vertices.
  x1 | lower left corner x coordinate of the polygon
  y1 | lower left corner y coordinate of the polygon
  x2 | upper right corner x coordinate of the polygon
  y2 | upper right corner y coordinate of the polygon

## ◆ GetFont()

const GlsFontBase * GetFont | ( |  | ) |
| inline

Returns
  A pointer to the font currently in use.

## ◆ InitRendering() [1/2]

void InitRendering | ( | IGlsStateManager * | stateManager | ) |
| inline

Initializes the font to begin rendering characters. This will set up Open GL texture modes, bind the font's texture, set up minification and magnification filters, etc. This must be called before using any of the Render methods draw characters.

Parameters

  stateManager | The state manager that will handle rendering the font.

## ◆ InitRendering() [2/2]

void InitRendering | ( | unsigned char | textureMinFilter,
|  | unsigned char | textureMagFilter,
|  | IGlsStateManager * | stateManager
| ) |  |
| inline

Initializes the font to begin rendering characters. This will set up Open GL texture modes, bind the font's texture, set up minification and magnification filters, etc. This must be called once before invoking Render to draw characters. This version overwrites the texture minification and magnification filters before initializing.

Parameters

  textureMinFilter | Minification mode for the font texture.
  textureMagFilter | Magnification mode for the font texture.
  stateManager | The object responsible for rendering the font.

## ◆ SetFont()

void SetFont | ( | const GlsFontBase * | font | ) |
| inline

Set the font to use. The font pointer must be set before calling any rendering methods.

Parameters

  font | The new font to use.

## ◆ SetupTexture()

void SetupTexture | ( | IFontImage * | texture,
|  | IGlsStateManager * | stateManager
| ) |  |
| inline protected

Helper method to set up Open GL texture modes, bind the font's texture, set up minification and magnification filters, etc.

Parameters

  texture | The font texture to bind.
  stateManager | The object responsible for rendering the texture.

## ◆ TextureMagFilter() [1/2]

unsigned char TextureMagFilter | ( |  | ) |
| inline

Returns
  The magnification filter for this font.

## ◆ TextureMagFilter() [2/2]

void TextureMagFilter | ( | unsigned char | val | ) |
| inline

Sets the magnification filter for this font.

Parameters

  val | The new magnification to set.

## ◆ TextureMinFilter() [1/2]

unsigned char TextureMinFilter | ( |  | ) |
| inline

Returns
  The minification filter for this font.

## ◆ TextureMinFilter() [2/2]

void TextureMinFilter | ( | unsigned char | val | ) |
| inline

Sets the minification filter for this font.

Parameters

  val | The new minification to set.

## Member Data Documentation

## ◆ _font

const GlsFontBase* _font
| protected

Pointer to the font to use for rendering

## ◆ _textureMagFilter

unsigned char _textureMagFilter
| protected

Magnification mode for the font texture

## ◆ _textureMinFilter

unsigned char _textureMinFilter
| protected

Minification mode for the font texture

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

- gls_font_renderer.h