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

Top-level HUD system. More...

#include <Hud.hpp>

Collaboration diagram for Hud:
[legend]

Public Member Functions

bool init (SDL_GPUDevice *device, SDL_GPUShaderFormat shaderFormat, const SdfAtlas &sdfAtlas, uint32_t screenW, uint32_t screenH)
 Initialise all HUD subsystems and create default widgets.
void quit ()
 Release all resources.
void resize (uint32_t newW, uint32_t newH)
 Notify of window resize.
void processEvent (const SDL_Event *event)
 Forward an SDL event to interactive widgets (buy menu, scoreboard).
void update (float dt, const HudGameState &state)
 Tick widget animations and consume game events.
void render ()
 Draw all widgets and flush to the GPU offscreen target.
SDL_GPUTexture * getOutputTexture () const
 The offscreen texture to blit.
std::vector< std::unique_ptr< HudWidget > > & widgets ()
 Access all widgets (for debug panel iteration).
HudTweenPooltweens ()
 Access the tween pool (for debug panel).

Private Member Functions

void resolveAnchor (const HudWidget &w, float &outX, float &outY) const
 Resolve anchor + offset to pixel coordinates.
void createWidgets ()
 Create all default widgets with initial layout.

Private Attributes

HudRenderer renderer_
HudContext context_
HudTweenPool tweens_
std::vector< std::unique_ptr< HudWidget > > widgets_
float screenW_ = 0.f
float screenH_ = 0.f

Detailed Description

Top-level HUD system.

Owns all layers and widgets.

Game calls update() + render() each frame. The renderer reads getOutputTexture() and blits it after tone mapping.

Member Function Documentation

◆ createWidgets()

void Hud::createWidgets ( )
private

Create all default widgets with initial layout.

Here is the caller graph for this function:

◆ getOutputTexture()

SDL_GPUTexture * Hud::getOutputTexture ( ) const
inlinenodiscard

The offscreen texture to blit.

◆ init()

bool Hud::init ( SDL_GPUDevice * device,
SDL_GPUShaderFormat shaderFormat,
const SdfAtlas & sdfAtlas,
uint32_t screenW,
uint32_t screenH )

Initialise all HUD subsystems and create default widgets.

Here is the call graph for this function:

◆ processEvent()

void Hud::processEvent ( const SDL_Event * event)

Forward an SDL event to interactive widgets (buy menu, scoreboard).

◆ quit()

void Hud::quit ( )

Release all resources.

◆ render()

void Hud::render ( )

Draw all widgets and flush to the GPU offscreen target.

Here is the call graph for this function:

◆ resize()

void Hud::resize ( uint32_t newW,
uint32_t newH )

Notify of window resize.

◆ resolveAnchor()

void Hud::resolveAnchor ( const HudWidget & w,
float & outX,
float & outY ) const
private

Resolve anchor + offset to pixel coordinates.

Here is the caller graph for this function:

◆ tweens()

HudTweenPool & Hud::tweens ( )
inlinenodiscard

Access the tween pool (for debug panel).

◆ update()

void Hud::update ( float dt,
const HudGameState & state )

Tick widget animations and consume game events.

◆ widgets()

std::vector< std::unique_ptr< HudWidget > > & Hud::widgets ( )
inlinenodiscard

Access all widgets (for debug panel iteration).

Here is the caller graph for this function:

Member Data Documentation

◆ context_

HudContext Hud::context_
private

◆ renderer_

HudRenderer Hud::renderer_
private

◆ screenH_

float Hud::screenH_ = 0.f
private

◆ screenW_

float Hud::screenW_ = 0.f
private

◆ tweens_

HudTweenPool Hud::tweens_
private

◆ widgets_

std::vector<std::unique_ptr<HudWidget> > Hud::widgets_
private

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