29 bool init(SDL_GPUDevice* dev,
const char* ttfPath);
42 void bindFragment(SDL_GPURenderPass* pass, uint32_t slot)
const;
Glyph metric types for the SDF text rendering system.
std::unordered_map< uint32_t, GlyphInfo > GlyphMap
Immutable glyph metrics table keyed by Unicode codepoint.
Definition SdfFont.hpp:22
Loads a TTF font, bakes an SDF glyph atlas, and uploads it to the GPU.
Definition SdfAtlas.hpp:18
SDL_GPUSampler * sampler_
Definition SdfAtlas.hpp:63
SDL_GPUDevice * device_
Definition SdfAtlas.hpp:61
bool init(SDL_GPUDevice *dev, const char *ttfPath)
Load TTF from path, bake SDF, upload to GPU.
Definition SdfAtlas.cpp:59
SDL_GPUTexture * texture_
Definition SdfAtlas.hpp:62
float scale() const
Raw scale factor: bake pixels per em unit.
Definition SdfAtlas.hpp:46
static constexpr int k_spread
SDF spread in pixels.
Definition SdfAtlas.hpp:23
static constexpr int k_atlasH
Definition SdfAtlas.hpp:21
const GlyphInfo * glyph(uint32_t codepoint) const
Look up glyph metrics.
Definition SdfAtlas.cpp:215
static constexpr int k_atlasW
Definition SdfAtlas.hpp:20
GlyphMap glyphs_
Definition SdfAtlas.hpp:64
SDL_GPUTexture * gpuTexture() const
GPU texture containing the baked SDF atlas (R8_UNORM, 1024x1024).
Definition SdfAtlas.hpp:54
float scale_
Definition SdfAtlas.hpp:65
void quit()
Release GPU resources owned by this atlas.
Definition SdfAtlas.cpp:198
SDL_GPUSampler * gpuSampler() const
Linear-clamp sampler for the SDF atlas.
Definition SdfAtlas.hpp:58
void bindFragment(SDL_GPURenderPass *pass, uint32_t slot) const
Bind the SDF atlas texture and sampler to a fragment sampler slot.
Definition SdfAtlas.cpp:224
static constexpr int k_renderPx
Rasterisation size in pixels.
Definition SdfAtlas.hpp:22
bool ready() const
Check whether the atlas has been successfully initialised.
Definition SdfAtlas.hpp:50
Per-glyph metrics stored after SDF atlas bake.
Definition SdfFont.hpp:12