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 ()
 
void ResetTranslate (const CVector2D &translate=CVector2D{})
 Reset the text transform to the default, with (0,0) in the top-left corner. More...
 
const CVector2DGetTranslate () const
 
void Translate (float x, float y)
 
void SetClippingRect (const CRect &rect)
 Set clipping rectangle, in pre-transform coordinates (i.e. More...
 
void SetCurrentColor (const CColor &color)
 Set the color for subsequent print calls. More...
 
void SetCurrentFont (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 (Renderer::Backend::IDeviceCommandContext *deviceCommandContext, Renderer::Backend::IShaderProgram *shader, const CVector2D &transformScale, const CVector2D &translation)
 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

CVector2D m_Translate
 
CRect m_Clipping
 
CColor m_Color
 
CStrIntern m_FontName
 
std::shared_ptr< CFontm_Font
 
bool m_Dirty = true
 
std::list< SBatchm_Batches
 

Friends

struct SBatchCompare
 

Constructor & Destructor Documentation

◆ CTextRenderer()

CTextRenderer::CTextRenderer ( )

Member Function Documentation

◆ GetTranslate()

const CVector2D & CTextRenderer::GetTranslate ( ) const
inline

◆ PrintfAdvance()

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.

◆ PrintfAt()

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.

◆ Put() [1/3]

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.

◆ Put() [2/3]

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.)

◆ Put() [3/3]

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.

◆ PutAdvance()

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.

◆ PutString()

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

◆ Render()

void CTextRenderer::Render ( Renderer::Backend::IDeviceCommandContext deviceCommandContext,
Renderer::Backend::IShaderProgram shader,
const CVector2D transformScale,
const CVector2D translation 
)

Render all of the previously printed text calls.

◆ ResetTranslate()

void CTextRenderer::ResetTranslate ( const CVector2D translate = CVector2D{})

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

◆ SetClippingRect()

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 SetScissors for precise clipping - this is just an optimisation.

◆ SetCurrentColor()

void CTextRenderer::SetCurrentColor ( const CColor color)

Set the color for subsequent print calls.

◆ SetCurrentFont()

void CTextRenderer::SetCurrentFont ( CStrIntern  font)

Set the font for subsequent print calls.

◆ Translate()

void CTextRenderer::Translate ( float  x,
float  y 
)

Friends And Related Function Documentation

◆ SBatchCompare

friend struct SBatchCompare
friend

Member Data Documentation

◆ m_Batches

std::list<SBatch> CTextRenderer::m_Batches
private

◆ m_Clipping

CRect CTextRenderer::m_Clipping
private

◆ m_Color

CColor CTextRenderer::m_Color
private

◆ m_Dirty

bool CTextRenderer::m_Dirty = true
private

◆ m_Font

std::shared_ptr<CFont> CTextRenderer::m_Font
private

◆ m_FontName

CStrIntern CTextRenderer::m_FontName
private

◆ m_Translate

CVector2D CTextRenderer::m_Translate
private

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