Pyrogenesis  trunk
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CTextRenderer Class Reference

#include <TextRenderer.h>

Collaboration diagram for CTextRenderer:
Collaboration graph
[legend]

Classes

struct  SBatch
 A list of SBatchRuns, with a single font/color/transform, to be rendered in a single GL call. More...
 
struct  SBatchRun
 A string (optionally owned by this object, or else pointing to an externally-owned string) with a position. More...
 

Public Member Functions

 CTextRenderer (const CShaderProgramPtr &shader)
 
void ResetTransform ()
 Reset the text transform to the default, with (0,0) in the top-left of the screen. More...
 
CMatrix3D GetTransform ()
 
void SetTransform (const CMatrix3D &transform)
 
void Translate (float x, float y, float z)
 
void SetClippingRect (const CRect &rect)
 Set clipping rectangle, in pre-transform coordinates (i.e. More...
 
void Color (const CColor &color)
 Set the color for subsequent print calls. More...
 
void Color (float r, float g, float b, float a=1.0)
 Set the color for subsequent print calls. More...
 
void Font (CStrIntern font)
 Set the font for subsequent print calls. More...
 
void PrintfAdvance (const wchar_t *fmt,...)
 Print formatted text at (0,0) under the current transform, and advance the transform by the width of the text. More...
 
void PrintfAt (float x, float y, const wchar_t *fmt,...)
 Print formatted text at (x,y) under the current transform. More...
 
void PutAdvance (const wchar_t *buf)
 Print text at (0,0) under the current transform, and advance the transform by the width of the text. More...
 
void Put (float x, float y, const wchar_t *buf)
 Print text at (x,y) under the current transform. More...
 
void Put (float x, float y, const char *buf)
 Print text at (x,y) under the current transform. More...
 
void Put (float x, float y, const std::wstring *buf)
 Print text at (x,y) under the current transform. More...
 
void Render ()
 Render all of the previously printed text calls. More...
 

Private Member Functions

void PutString (float x, float y, const std::wstring *buf, bool owned)
 

Private Attributes

CShaderProgramPtr m_Shader
 
CMatrix3D m_Transform
 
CRect m_Clipping
 
CColor m_Color
 
CStrIntern m_FontName
 
shared_ptr< CFontm_Font
 
bool m_Dirty
 
std::list< SBatchm_Batches
 

Friends

struct SBatchCompare
 

Constructor & Destructor Documentation

CTextRenderer::CTextRenderer ( const CShaderProgramPtr shader)

Member Function Documentation

void CTextRenderer::Color ( const CColor color)

Set the color for subsequent print calls.

void CTextRenderer::Color ( float  r,
float  g,
float  b,
float  a = 1.0 
)

Set the color for subsequent print calls.

void CTextRenderer::Font ( CStrIntern  font)

Set the font for subsequent print calls.

CMatrix3D CTextRenderer::GetTransform ( )
void CTextRenderer::PrintfAdvance ( const wchar_t fmt,
  ... 
)

Print formatted text at (0,0) under the current transform, and advance the transform by the width of the text.

void CTextRenderer::PrintfAt ( float  x,
float  y,
const wchar_t fmt,
  ... 
)

Print formatted text at (x,y) under the current transform.

Does not alter the current transform.

void CTextRenderer::Put ( float  x,
float  y,
const wchar_t buf 
)

Print text at (x,y) under the current transform.

Does not alter the current transform.

void CTextRenderer::Put ( float  x,
float  y,
const char *  buf 
)

Print text at (x,y) under the current transform.

Does not alter the current transform. buf must be a UTF-8 string.

void CTextRenderer::Put ( float  x,
float  y,
const std::wstring *  buf 
)

Print text at (x,y) under the current transform.

Does not alter the current transform. buf must remain valid until Render() is called. (This should be used to minimise memory copies when possible.)

void CTextRenderer::PutAdvance ( const wchar_t buf)

Print text at (0,0) under the current transform, and advance the transform by the width of the text.

void CTextRenderer::PutString ( float  x,
float  y,
const std::wstring *  buf,
bool  owned 
)
private
void CTextRenderer::Render ( )

Render all of the previously printed text calls.

void CTextRenderer::ResetTransform ( )

Reset the text transform to the default, with (0,0) in the top-left of the screen.

void CTextRenderer::SetClippingRect ( const CRect rect)

Set clipping rectangle, in pre-transform coordinates (i.e.

text is clipped against this rect based purely on the x,y values passed into Put()). Text fully outside the clipping rectangle may not be rendered. Should be used in conjunction with glScissor for precise clipping - this is just an optimisation.

void CTextRenderer::SetTransform ( const CMatrix3D transform)
void CTextRenderer::Translate ( float  x,
float  y,
float  z 
)

Friends And Related Function Documentation

friend struct SBatchCompare
friend

Member Data Documentation

std::list<SBatch> CTextRenderer::m_Batches
private
CRect CTextRenderer::m_Clipping
private
CColor CTextRenderer::m_Color
private
bool CTextRenderer::m_Dirty
private
shared_ptr<CFont> CTextRenderer::m_Font
private
CStrIntern CTextRenderer::m_FontName
private
CShaderProgramPtr CTextRenderer::m_Shader
private
CMatrix3D CTextRenderer::m_Transform
private

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