MCPcopy Create free account
hub / github.com/LukasBanana/LLGL / CreateFontAtlas

Method CreateFontAtlas

examples/Cpp/Fonts/Example.cpp:172–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170 }
171
172 void CreateFontAtlas(const char* fontName, int fontSize)
173 {
174 Font font;
175
176 const std::string fontAtlasName = std::string(fontName) + ".atlas-" + std::to_string(fontSize);
177
178 // Load glyph texture as alpha-only texture (automatically interprets color input as alpha channel for transparency)
179 font.atlasTexture = LoadTexture(
180 fontAtlasName + ".png",
181 (LLGL::BindFlags::Sampled | LLGL::BindFlags::ColorAttachment),
182 LLGL::Format::A8UNorm
183 );
184
185 // Store size and inverse size of glyph texture
186 font.atlasSize = font.atlasTexture->GetMipExtent(0);
187
188 // Create default linear sampler state
189 linearSampler = renderer->CreateSampler(LLGL::Parse("filter.mip=none"));
190
191 // Build glyph set with font meta data
192 BuildGlyphSet(font, fontAtlasName + ".map", ' ', '~', font.atlasSize.width, font.atlasSize.height);
193
194 // Store font height to render appropriately for the loaded font
195 font.fontHeight = fontSize;
196
197 fonts.push_back(std::move(font));
198 }
199
200 bool BuildGlyphSet(Font& font, const std::string& mapFilename, char firstChar, char lastChar, std::uint32_t atlasWidth, std::uint32_t atlasHeight)
201 {

Callers

nothing calls this directly

Calls 2

GetMipExtentMethod · 0.65
CreateSamplerMethod · 0.65

Tested by

no test coverage detected