31 bool init(SDL_GPUDevice* device,
32 SDL_GPUShaderFormat shaderFormat,
41 void resize(uint32_t newW, uint32_t newH);
50 void render(std::span<const HudVertex> vertices, std::span<
const std::array<float, 6>> clipRects);
97 loadShader(
const char* name, SDL_GPUShaderStage stage, uint32_t samplerCount, uint32_t uniformBufferCount);
Shared types for the HUD system.
Renders batched HUD geometry to an offscreen RGBA8 texture.
Definition HudRenderer.hpp:22
uint32_t vertexCapacity_
Current buffer capacity in vertices.
Definition HudRenderer.hpp:82
SDL_GPUSampler * iconAtlasSamp_
Owning.
Definition HudRenderer.hpp:77
uint32_t width() const
Current target width.
Definition HudRenderer.hpp:56
SDL_GPUSampler * sdfAtlasSamp_
Non-owning: from SdfAtlas.
Definition HudRenderer.hpp:75
SDL_GPUGraphicsPipeline * pipeline_
Definition HudRenderer.hpp:71
SDL_GPUShader * loadShader(const char *name, SDL_GPUShaderStage stage, uint32_t samplerCount, uint32_t uniformBufferCount)
Load a compiled shader from the shaders/ directory.
Definition HudRenderer.cpp:341
bool ensureVertexBuffer(uint32_t requiredVertices)
Definition HudRenderer.cpp:309
bool init(SDL_GPUDevice *device, SDL_GPUShaderFormat shaderFormat, const SdfAtlas &sdfAtlas, uint32_t screenW, uint32_t screenH)
Initialise GPU resources.
Definition HudRenderer.cpp:16
SDL_GPUTexture * getOutputTexture() const
The offscreen texture to be blitted by the renderer.
Definition HudRenderer.hpp:53
SDL_GPUTexture * offscreenTarget_
Definition HudRenderer.hpp:66
SDL_GPUTexture * sdfAtlasTex_
Non-owning: from SdfAtlas.
Definition HudRenderer.hpp:74
SDL_GPUTexture * iconAtlasTex_
Owning: 1x1 white fallback until real atlas.
Definition HudRenderer.hpp:76
SDL_GPUBuffer * vertexBuffer_
Definition HudRenderer.hpp:80
uint32_t width_
Definition HudRenderer.hpp:67
SDL_GPUDevice * device_
Definition HudRenderer.hpp:62
SDL_GPUTransferBuffer * transferBuffer_
Definition HudRenderer.hpp:81
void render(std::span< const HudVertex > vertices, std::span< const std::array< float, 6 > > clipRects)
Upload vertex data, execute the HUD render pass, and submit.
Definition HudRenderer.cpp:120
void quit()
Release all GPU resources.
Definition HudRenderer.cpp:86
SDL_GPUShaderFormat shaderFormat_
Definition HudRenderer.hpp:63
uint32_t height_
Definition HudRenderer.hpp:68
bool createPipeline()
Definition HudRenderer.cpp:230
bool createOffscreenTarget(uint32_t w, uint32_t h)
Definition HudRenderer.cpp:210
void resize(uint32_t newW, uint32_t newH)
Recreate the offscreen target on window resize.
Definition HudRenderer.cpp:109
uint32_t height() const
Current target height.
Definition HudRenderer.hpp:59
Loads a TTF font, bakes an SDF glyph atlas, and uploads it to the GPU.
Definition SdfAtlas.hpp:18