diff --git a/openVulkanoCpp/Scene/TextDrawable.cpp b/openVulkanoCpp/Scene/TextDrawable.cpp index 1dba011..b127b1d 100644 --- a/openVulkanoCpp/Scene/TextDrawable.cpp +++ b/openVulkanoCpp/Scene/TextDrawable.cpp @@ -207,16 +207,7 @@ namespace OpenVulkano::Scene bmin.x = m_geometry.vertices[0].position.x; m_bbox.Init(bmin, bmax); - if (!GetShader()) - { - switch (m_atlasData->meta.atlasType) - { - case FontAtlasType::SDF: SetShader(&DEFAULT_SHADER_SDF); break; - case FontAtlasType::MSDF: SetShader(&DEFAULT_SHADER_MSDF); break; - default: Logger::RENDER->warn("No default shader for atlas type: {}", m_atlasData->meta.atlasType.GetName()); - case FontAtlasType::BITMAP: SetShader(&DEFAULT_SHADER_BITMAP); break; - } - } + if (!GetShader()) SetShader(GetDefaultShader(m_atlasData->meta.atlasType)); } void TextDrawable::SetAtlasData(const std::shared_ptr& atlasData) @@ -224,4 +215,15 @@ namespace OpenVulkano::Scene if (!atlasData || !*atlasData) throw std::runtime_error("Cannot initialize text drawable with empty atlas data"); m_atlasData = atlasData; } + + Shader* TextDrawable::GetDefaultShader(const FontAtlasType type) + { + switch (type) + { + case FontAtlasType::SDF: return &DEFAULT_SHADER_SDF; + case FontAtlasType::MSDF: return &DEFAULT_SHADER_MSDF; + default: Logger::RENDER->warn("No default shader for atlas type: {}", type.GetName()); + case FontAtlasType::BITMAP: return &DEFAULT_SHADER_BITMAP; + } + } } \ No newline at end of file diff --git a/openVulkanoCpp/Scene/TextDrawable.hpp b/openVulkanoCpp/Scene/TextDrawable.hpp index 4547464..c4eb502 100644 --- a/openVulkanoCpp/Scene/TextDrawable.hpp +++ b/openVulkanoCpp/Scene/TextDrawable.hpp @@ -49,10 +49,12 @@ namespace OpenVulkano::Scene [[nodiscard]] Math::AABB& GetBoundingBox() { return m_bbox; } [[nodiscard]] TextConfig& GetConfig() { return m_cfg; } [[nodiscard]] const std::string& GetText() const { return m_text; } - [[nodiscard]] const std::shared_ptr GetAtlasData() { return m_atlasData; } + [[nodiscard]] const std::shared_ptr& GetAtlasData() { return m_atlasData; } [[nodiscard]] Geometry* GetGeometry() { return &m_geometry; } [[nodiscard]] Texture* GetTexture() { return &m_atlasData->texture; } [[nodiscard]] UniformBuffer* GetUniformBuffer() { return &m_uniBuffer; } + + [[nodiscard]] static Shader* GetDefaultShader(FontAtlasType type); }; }