diff --git a/openVulkanoCpp/Scene/AtlasData.hpp b/openVulkanoCpp/Scene/AtlasData.hpp index 7311239..be784ec 100644 --- a/openVulkanoCpp/Scene/AtlasData.hpp +++ b/openVulkanoCpp/Scene/AtlasData.hpp @@ -12,6 +12,7 @@ #include "Scene/Texture.hpp" #include #include +#include namespace OpenVulkano::Scene { @@ -29,23 +30,27 @@ namespace OpenVulkano::Scene public: enum Type : int16_t { - BITMAP = 0, - SDF, + SDF = 0, MSDF, + BITMAP, UNKNOWN }; - static constexpr std::string_view DEFAULT_FG_SHADERS[] = { "Shader/text", "Shader/sdfText", "Shader/msdfText" }; + static constexpr std::string_view DEFAULT_FG_SHADERS[] = { "Shader/sdfText", "Shader/msdfText", "Shader/text" }; constexpr FontAtlasType(Type type) : m_type(type) {} [[nodiscard]] constexpr Type GetType() const { return m_type; } + [[nodiscard]] constexpr auto GetName() const { return magic_enum::enum_name(m_type); } + [[nodiscard]] constexpr const std::string_view& GetDefaultFragmentShader() const { return DEFAULT_FG_SHADERS[static_cast(m_type)]; } + [[nodiscard]] constexpr operator Type() const { return m_type; } + private: Type m_type; }; @@ -54,7 +59,7 @@ namespace OpenVulkano::Scene { // vertical difference between baselines double lineHeight = 0; - int16_t atlasType = FontAtlasType::UNKNOWN; + FontAtlasType atlasType = FontAtlasType::UNKNOWN; }; struct AtlasData diff --git a/openVulkanoCpp/Scene/Prefabs/LabelDrawable.cpp b/openVulkanoCpp/Scene/Prefabs/LabelDrawable.cpp index 48b03ab..5e5b0c1 100644 --- a/openVulkanoCpp/Scene/Prefabs/LabelDrawable.cpp +++ b/openVulkanoCpp/Scene/Prefabs/LabelDrawable.cpp @@ -74,10 +74,9 @@ namespace OpenVulkano::Scene TextDrawable& textDrawable = m_texts.emplace_back(m_atlasData, config); // do not render glyph's background textDrawable.GetConfig().backgroundColor.a = 0; - textDrawable.SetShader(&m_textShader); double lineHeight = m_atlasData->meta.lineHeight; - textDrawable.GenerateText(text, m_position); + textDrawable.SetShader(&m_textShader); m_bbox.Grow(textDrawable.GetBoundingBox()); // update position for next text entry m_position.y = m_bbox.GetMin().y - lineHeight;