group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
SdfRenderer Class Reference

Queues SDF glyph quads for world-space and screen-space text. More...

#include <SdfRenderer.hpp>

Public Member Functions

bool init (SDL_GPUDevice *dev, const char *ttfPath)
 Initialise the renderer by loading a font and baking the SDF atlas.
 
void quit ()
 Release all resources owned by this renderer.
 
void drawWorldText (glm::vec3 worldPos, std::string_view text, glm::vec4 color, float worldHeight, glm::vec3 camRight, glm::vec3 camUp)
 Queue world-space billboard text (faces camera, depth-tested).
 
void drawScreenText (glm::vec2 pixelPos, std::string_view text, glm::vec4 color, float pixelHeight)
 Queue HUD text in pixel coordinates (no depth test).
 
void clear ()
 Clear queues (called at start of each frame).
 
const SdfGlyphGPUworldData () const
 Get a pointer to the world-space glyph data buffer.
 
uint32_t worldCount () const
 Get the number of queued world-space glyphs.
 
const SdfGlyphGPUhudData () const
 Get a pointer to the HUD glyph data buffer.
 
uint32_t hudCount () const
 Get the number of queued HUD glyphs.
 
bool ready () const
 Check whether the underlying atlas is ready for rendering.
 
const SdfAtlasatlas () const
 Access the underlying SDF atlas (provides GPU texture binding).
 

Detailed Description

Queues SDF glyph quads for world-space and screen-space text.

Call drawWorldText() / drawScreenText() each frame to queue text. The ParticleSystem flushes the queues during uploadToGpu() / render().

Member Function Documentation

◆ atlas()

const SdfAtlas & SdfRenderer::atlas ( ) const
inline

Access the underlying SDF atlas (provides GPU texture binding).

Returns
Const reference to the SdfAtlas.
Here is the caller graph for this function:

◆ clear()

void SdfRenderer::clear ( )

Clear queues (called at start of each frame).

Clear all queued glyph data for the current frame.

Here is the caller graph for this function:

◆ drawScreenText()

void SdfRenderer::drawScreenText ( glm::vec2  pixelPos,
std::string_view  text,
glm::vec4  color,
float  pixelHeight 
)

Queue HUD text in pixel coordinates (no depth test).

Parameters
pixelPosScreen-space position in pixels.
textUTF-8 text string to render.
colorRGBA colour for all glyphs.
pixelHeightDesired text height in pixels.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawWorldText()

void SdfRenderer::drawWorldText ( glm::vec3  worldPos,
std::string_view  text,
glm::vec4  color,
float  worldHeight,
glm::vec3  camRight,
glm::vec3  camUp 
)

Queue world-space billboard text (faces camera, depth-tested).

Parameters
worldPosWorld-space origin of the text baseline.
textUTF-8 text string to render.
colorRGBA colour for all glyphs.
worldHeightDesired text height in world units.
camRightCamera right vector for billboarding.
camUpCamera up vector for billboarding.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hudCount()

uint32_t SdfRenderer::hudCount ( ) const
inline

Get the number of queued HUD glyphs.

Returns
HUD glyph count.
Here is the caller graph for this function:

◆ hudData()

const SdfGlyphGPU * SdfRenderer::hudData ( ) const
inline

Get a pointer to the HUD glyph data buffer.

Returns
Pointer to the first HUD glyph, or nullptr if empty.
Here is the caller graph for this function:

◆ init()

bool SdfRenderer::init ( SDL_GPUDevice *  dev,
const char *  ttfPath 
)

Initialise the renderer by loading a font and baking the SDF atlas.

Parameters
devGPU device used for atlas texture creation.
ttfPathFilesystem path to the TTF font file.
Returns
true on success.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ quit()

void SdfRenderer::quit ( )

Release all resources owned by this renderer.

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

◆ ready()

bool SdfRenderer::ready ( ) const
inline

Check whether the underlying atlas is ready for rendering.

Returns
true if the atlas texture is valid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ worldCount()

uint32_t SdfRenderer::worldCount ( ) const
inline

Get the number of queued world-space glyphs.

Returns
World glyph count.
Here is the caller graph for this function:

◆ worldData()

const SdfGlyphGPU * SdfRenderer::worldData ( ) const
inline

Get a pointer to the world-space glyph data buffer.

Returns
Pointer to the first world glyph, or nullptr if empty.
Here is the caller graph for this function:

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