group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
SdfRenderer.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "SdfAtlas.hpp"
8
9#include <glm/glm.hpp>
10#include <string_view>
11#include <vector>
12
18{
19public:
24 bool init(SDL_GPUDevice* dev, const char* ttfPath);
25
27 void quit();
28
36 void drawWorldText(glm::vec3 worldPos,
37 std::string_view text,
38 glm::vec4 color,
39 float worldHeight,
40 glm::vec3 camRight,
41 glm::vec3 camUp);
42
48 void drawScreenText(glm::vec2 pixelPos, std::string_view text, glm::vec4 color, float pixelHeight);
49
51 void clear();
52
55 [[nodiscard]] const SdfGlyphGPU* worldData() const { return worldGlyphs_.data(); }
56
59 [[nodiscard]] uint32_t worldCount() const { return static_cast<uint32_t>(worldGlyphs_.size()); }
60
63 [[nodiscard]] const SdfGlyphGPU* hudData() const { return hudGlyphs_.data(); }
64
67 [[nodiscard]] uint32_t hudCount() const { return static_cast<uint32_t>(hudGlyphs_.size()); }
68
71 [[nodiscard]] bool ready() const { return atlas_.ready(); }
72
75 [[nodiscard]] const SdfAtlas& atlas() const { return atlas_; }
76
77private:
79 std::vector<SdfGlyphGPU> worldGlyphs_;
80 std::vector<SdfGlyphGPU> hudGlyphs_;
81};
GPU-uploadable particle structs for all effect categories.
SDF glyph atlas loader and GPU texture manager.
Loads a TTF font, bakes an SDF glyph atlas, and uploads it to the GPU.
Definition SdfAtlas.hpp:18
Queues SDF glyph quads for world-space and screen-space text.
Definition SdfRenderer.hpp:18
void drawScreenText(glm::vec2 pixelPos, std::string_view text, glm::vec4 color, float pixelHeight)
Queue HUD text in pixel coordinates (no depth test).
Definition SdfRenderer.cpp:71
bool ready() const
Check whether the underlying atlas is ready for rendering.
Definition SdfRenderer.hpp:71
uint32_t worldCount() const
Get the number of queued world-space glyphs.
Definition SdfRenderer.hpp:59
const SdfGlyphGPU * hudData() const
Get a pointer to the HUD glyph data buffer.
Definition SdfRenderer.hpp:63
const SdfGlyphGPU * worldData() const
Get a pointer to the world-space glyph data buffer.
Definition SdfRenderer.hpp:55
uint32_t hudCount() const
Get the number of queued HUD glyphs.
Definition SdfRenderer.hpp:67
void quit()
Release all resources owned by this renderer.
Definition SdfRenderer.cpp:13
const SdfAtlas & atlas() const
Access the underlying SDF atlas (provides GPU texture binding).
Definition SdfRenderer.hpp:75
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).
Definition SdfRenderer.cpp:28
void clear()
Clear queues (called at start of each frame).
Definition SdfRenderer.cpp:21
std::vector< SdfGlyphGPU > worldGlyphs_
Definition SdfRenderer.hpp:79
std::vector< SdfGlyphGPU > hudGlyphs_
Definition SdfRenderer.hpp:80
bool init(SDL_GPUDevice *dev, const char *ttfPath)
Initialise the renderer by loading a font and baking the SDF atlas.
Definition SdfRenderer.cpp:7
SdfAtlas atlas_
Definition SdfRenderer.hpp:78
SDF glyph quad (world-space or screen-space HUD).
Definition ParticleTypes.hpp:94