|
group2 0.1.0
CSE 125 Group 2
|
Accumulates HUD geometry during a frame for batch rendering. More...
#include <HudContext.hpp>
Public Member Functions | |
| void | init (const SdfAtlas *atlas, HudSvgAtlas *svgAtlas=nullptr) |
| Bind the SDF atlas for text layout (glyph metrics). | |
| void | beginFrame () |
| Clear all geometry for a new frame. | |
| void | rect (float x, float y, float w, float h, HudColor color) |
| void | rectOutline (float x, float y, float w, float h, float thickness, HudColor color) |
| void | roundedRect (float x, float y, float w, float h, float radius, HudColor color) |
| void | rotatedRect (float cx, float cy, float w, float h, float angleDeg, HudColor color) |
| void | gradientRect (float x, float y, float w, float h, HudColor leftColor, HudColor rightColor) |
| Filled rect with a horizontal color gradient. | |
| void | triangle (float x0, float y0, float x1, float y1, float x2, float y2, HudColor color) |
| Emit a single solid-colored triangle (3 vertices). | |
| void | triangleColors (float x0, float y0, HudColor c0, float x1, float y1, HudColor c1, float x2, float y2, HudColor c2) |
| Triangle with per-vertex colors — the rasteriser interpolates across the surface. | |
| void | polyline (const float *points, int numPoints, float thickness, HudColor color) |
| Stroke a polyline with sharp-mitred corners using rotated rects. | |
| void | bar (float x, float y, float w, float h, float fill01, HudColor fg, HudColor bg) |
| void | text (const char *str, float x, float y, float size, HudColor color, HudAlign align=HudAlign::Left, bool outlined=false) |
| Render a UTF-8 ASCII string via SDF. | |
| void | knockoutText (const char *str, float x, float y, float size, HudAlign align=HudAlign::Left) |
| float | measureText (const char *str, float size) const |
| void | measureTextVerticalBounds (const char *str, float size, float &outTop, float &outBottom) const |
| bool | icon (HudIcon id, float x, float y, float size, HudColor tint=HudColor::white()) |
| bool | svg (HudIcon id, float x, float y, float w, float h, HudColor tint=HudColor::white()) |
| bool | svgFlipped (HudIcon id, float x, float y, float w, float h, bool flipX, bool flipY, HudColor tint=HudColor::white()) |
| bool | svgPartialX (HudIcon id, float x, float y, float w, float h, float fraction, HudColor tint=HudColor::white()) |
| bool | svgMask (HudIcon id, float x, float y, float w, float h, HudColor color) |
| bool | svgMaskFlipped (HudIcon id, float x, float y, float w, float h, bool flipX, bool flipY, HudColor color) |
| bool | svgMaskPartialX (HudIcon id, float x, float y, float w, float h, float fraction, HudColor color) |
| bool | svgMaskRangeX (HudIcon id, float x, float y, float w, float h, float startFraction, float endFraction, HudColor color) |
| bool | svgMaskPartialXFlipped (HudIcon id, float x, float y, float w, float h, float fraction, bool fromRight, bool flipX, bool flipY, HudColor color) |
| void | crosshair (const CrosshairStyle &style, float screenW, float screenH) |
| void | vignette (float screenW, float screenH, HudColor color) |
| Draw a full-screen radial vignette overlay. | |
| void | scopeMask (float screenW, float screenH, float radiusPx, HudColor color) |
| Draw a full-screen scope mask with a transparent circular cut-out. | |
| void | pushClipRect (float x, float y, float w, float h) |
| void | popClipRect () |
| void | endFrame () |
| Flush any remaining unflushed vertices into a final clip span. | |
| void | tintVertices (std::size_t startVertex, HudColor tint) |
| Multiply already-emitted vertex colors by a tint. | |
| void | rotateVertices (std::size_t startVertex, float cx, float cy, float angleDeg) |
| Rotate vertices emitted since startVertex around a screen-space point. | |
| const std::vector< HudVertex > & | vertices () const |
| const std::vector< std::array< float, 6 > > & | clipSpans () const |
| Clip rect spans: {startVertex, vertexCount, x, y, w, h}. | |
Private Member Functions | |
| void | emitQuad (float x, float y, float w, float h, float u0, float v0, float u1, float v1, HudColor color, float texMode, float sd0=0.f, float sd1=0.f, float sd2=0.f) |
| Emit 6 vertices for a textured quad. | |
| void | flushClipSpan () |
| Flush the current clip span before changing scissor state. | |
Private Attributes | |
| const SdfAtlas * | sdfAtlas_ = nullptr |
| HudSvgAtlas * | svgAtlas_ = nullptr |
| std::vector< HudVertex > | vertices_ |
| std::vector< std::array< float, 6 > > | clipSpans_ |
| std::vector< std::array< float, 4 > > | clipStack_ |
| uint32_t | spanStartVertex_ = 0 |
| Vertex index where current clip span started. | |
| bool | spanDirty_ = false |
Accumulates HUD geometry during a frame for batch rendering.
Widgets call rect(), text(), bar(), etc. to emit quads. At the end of the frame, HudRenderer consumes the vertex buffer and clip rect list.
| void HudContext::beginFrame | ( | ) |
Clear all geometry for a new frame.
|
inlinenodiscard |
Clip rect spans: {startVertex, vertexCount, x, y, w, h}.
Negative w means "full viewport" (no scissor).
| void HudContext::crosshair | ( | const CrosshairStyle & | style, |
| float | screenW, | ||
| float | screenH ) |
|
private |
Emit 6 vertices for a textured quad.
| void HudContext::endFrame | ( | ) |
Flush any remaining unflushed vertices into a final clip span.
Must be called after all draw() calls, before accessing vertices/clipSpans.
|
private |
Flush the current clip span before changing scissor state.
| void HudContext::gradientRect | ( | float | x, |
| float | y, | ||
| float | w, | ||
| float | h, | ||
| HudColor | leftColor, | ||
| HudColor | rightColor ) |
Filled rect with a horizontal color gradient.
leftColor is at the left edge, rightColor at the right. The rasteriser perspective-correct-interpolates per-vertex colors across the quad, so the gradient is exact at any size and any rotation (though we only emit axis-aligned gradients here — the design's HP / shield bars are horizontal).
| bool HudContext::icon | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | size, | ||
| HudColor | tint = HudColor::white() ) |
| void HudContext::init | ( | const SdfAtlas * | atlas, |
| HudSvgAtlas * | svgAtlas = nullptr ) |
Bind the SDF atlas for text layout (glyph metrics).
| void HudContext::knockoutText | ( | const char * | str, |
| float | x, | ||
| float | y, | ||
| float | size, | ||
| HudAlign | align = HudAlign::Left ) |
| float HudContext::measureText | ( | const char * | str, |
| float | size ) const |
| void HudContext::measureTextVerticalBounds | ( | const char * | str, |
| float | size, | ||
| float & | outTop, | ||
| float & | outBottom ) const |
| void HudContext::polyline | ( | const float * | points, |
| int | numPoints, | ||
| float | thickness, | ||
| HudColor | color ) |
Stroke a polyline with sharp-mitred corners using rotated rects.
| points | 2*N pairs (x0,y0,x1,y1,...) — N >= 2. |
| numPoints | Number of (x,y) points. |
| thickness | Line width in pixels. |
| color | Stroke color. |
| void HudContext::popClipRect | ( | ) |
| void HudContext::pushClipRect | ( | float | x, |
| float | y, | ||
| float | w, | ||
| float | h ) |
| void HudContext::rect | ( | float | x, |
| float | y, | ||
| float | w, | ||
| float | h, | ||
| HudColor | color ) |
| void HudContext::rectOutline | ( | float | x, |
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | thickness, | ||
| HudColor | color ) |
| void HudContext::rotatedRect | ( | float | cx, |
| float | cy, | ||
| float | w, | ||
| float | h, | ||
| float | angleDeg, | ||
| HudColor | color ) |
| void HudContext::rotateVertices | ( | std::size_t | startVertex, |
| float | cx, | ||
| float | cy, | ||
| float | angleDeg ) |
Rotate vertices emitted since startVertex around a screen-space point.
| void HudContext::roundedRect | ( | float | x, |
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | radius, | ||
| HudColor | color ) |
| void HudContext::scopeMask | ( | float | screenW, |
| float | screenH, | ||
| float | radiusPx, | ||
| HudColor | color ) |
Draw a full-screen scope mask with a transparent circular cut-out.
| screenW | Viewport width in pixels. |
| screenH | Viewport height in pixels. |
| radiusPx | Radius of the clear scope glass in pixels. |
| color | Mask tint; alpha controls opacity outside the cut-out. |
| bool HudContext::svg | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| HudColor | tint = HudColor::white() ) |
| bool HudContext::svgFlipped | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| bool | flipX, | ||
| bool | flipY, | ||
| HudColor | tint = HudColor::white() ) |
| bool HudContext::svgMaskFlipped | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| bool | flipX, | ||
| bool | flipY, | ||
| HudColor | color ) |
| bool HudContext::svgMaskPartialX | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | fraction, | ||
| HudColor | color ) |
| bool HudContext::svgMaskPartialXFlipped | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | fraction, | ||
| bool | fromRight, | ||
| bool | flipX, | ||
| bool | flipY, | ||
| HudColor | color ) |
| bool HudContext::svgMaskRangeX | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | startFraction, | ||
| float | endFraction, | ||
| HudColor | color ) |
| bool HudContext::svgPartialX | ( | HudIcon | id, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | fraction, | ||
| HudColor | tint = HudColor::white() ) |
| void HudContext::text | ( | const char * | str, |
| float | x, | ||
| float | y, | ||
| float | size, | ||
| HudColor | color, | ||
| HudAlign | align = HudAlign::Left, | ||
| bool | outlined = false ) |
Render a UTF-8 ASCII string via SDF.
| outlined | When true the glyph picks up a 1-px dark outline for legibility against bright/varied backgrounds (damage numbers over the world, etc.). Defaults to off so text rendered onto the dark Voidfall panel chrome stays clean and doesn't gain a "sticker" look. |
| void HudContext::tintVertices | ( | std::size_t | startVertex, |
| HudColor | tint ) |
Multiply already-emitted vertex colors by a tint.
| void HudContext::triangle | ( | float | x0, |
| float | y0, | ||
| float | x1, | ||
| float | y1, | ||
| float | x2, | ||
| float | y2, | ||
| HudColor | color ) |
Emit a single solid-colored triangle (3 vertices).
| void HudContext::triangleColors | ( | float | x0, |
| float | y0, | ||
| HudColor | c0, | ||
| float | x1, | ||
| float | y1, | ||
| HudColor | c1, | ||
| float | x2, | ||
| float | y2, | ||
| HudColor | c2 ) |
Triangle with per-vertex colors — the rasteriser interpolates across the surface.
Used by chamfered / pentagon panels that need a horizontal or radial gradient.
|
inlinenodiscard |
| void HudContext::vignette | ( | float | screenW, |
| float | screenH, | ||
| HudColor | color ) |
Draw a full-screen radial vignette overlay.
| screenW | Viewport width in pixels. |
| screenH | Viewport height in pixels. |
| color | Tint color with alpha controlling intensity. |
|
private |
|
private |
|
private |
|
private |
|
private |
Vertex index where current clip span started.
|
private |
|
private |