feat: add text rendering with SDF's

This commit is contained in:
2026-10-17 16:00:51 +02:00
parent 7dd5ee7903
commit 67c685a158
12 changed files with 746 additions and 51 deletions
+13
View File
@@ -41,6 +41,9 @@ void LightKeeper::customInit()
debug2DTexture = resources.loadImageFromFile(
gfxDevice, AssetFS::GetInstance().GetFullPath("engine://textures/kobe.png"));
hudFont = Font::LoadFromFile(AssetFS::GetInstance().GetFullPath("engine://fonts/Roboto-Medium.ttf"));
hudFont.Upload(gfxDevice, resources);
}
void LightKeeper::setupSkybox()
@@ -91,6 +94,16 @@ void LightKeeper::drawCrosshair()
renderer2D.DrawLine(center - glm::vec2{0.0f, halfArm}, center + glm::vec2{0.0f, halfArm}, thickness, color);
if (focused) {
renderer2D.DrawEllipseOutline(center, glm::vec2{14.0f}, thickness, color);
constexpr std::string_view prompt = "[E] Interact";
constexpr float promptSize = 22.0f;
const glm::vec2 promptExtent = hudFont.MeasureText(prompt, promptSize);
renderer2D.DrawText(
hudFont,
prompt,
center + glm::vec2{-promptExtent.x * 0.5f, 28.0f},
promptSize,
TextStyle{.color = color, .outline = 2.0f, .outlineColor = {0.0f, 0.0f, 0.0f, 0.75f}});
}
}