29 bool init(SDL_GPUDevice* dev,
const char* ttfPath);
42 void bindFragment(SDL_GPURenderPass* pass, uint32_t slot)
const;
46 [[nodiscard]]
float scale()
const {
return scale_; }
50 [[nodiscard]]
bool ready()
const {
return texture_ !=
nullptr; }
54 [[nodiscard]] SDL_GPUTexture*
gpuTexture()
const {
return texture_; }
58 [[nodiscard]] SDL_GPUSampler*
gpuSampler()
const {
return sampler_; }
61 SDL_GPUDevice* device_ =
nullptr;
62 SDL_GPUTexture* texture_ =
nullptr;
63 SDL_GPUSampler* sampler_ =
nullptr;
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
bool init(SDL_GPUDevice *dev, const char *ttfPath)
Load TTF from path, bake SDF, upload to GPU.
Definition SdfAtlas.cpp:100
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:252
static constexpr int k_atlasW
Definition SdfAtlas.hpp:20
SDL_GPUTexture * gpuTexture() const
GPU texture containing the baked SDF atlas (R8_UNORM, 1024x1024).
Definition SdfAtlas.hpp:54
void quit()
Release GPU resources owned by this atlas.
Definition SdfAtlas.cpp:235
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:261
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