feat: add text rendering with SDF's
This commit is contained in:
@@ -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}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user