diff --git a/examples/ExampleApps/LabelDrawableExampleApp.cpp b/examples/ExampleApps/LabelDrawableExampleApp.cpp index 220df1f..0ad6333 100644 --- a/examples/ExampleApps/LabelDrawableExampleApp.cpp +++ b/examples/ExampleApps/LabelDrawableExampleApp.cpp @@ -18,7 +18,6 @@ #include "Base/EngineConfiguration.hpp" #include "Controller/FreeCamCameraController.hpp" #include "Scene/Text/SdfFontAtlasGenerator.hpp" -#include #ifdef _WIN32 #undef TRANSPARENT @@ -47,7 +46,7 @@ namespace OpenVulkano auto& resourceLoader = ResourceLoader::GetInstance(); auto sdfMetadataInfo = resourceLoader.GetResource("sdf_atlas_packed.png"); - TextDrawable textDrawable(sdfMetadataInfo); + TextDrawable textDrawable(std::make_shared(sdfMetadataInfo)); const std::vector texts = { "_!?{}.#@", "1", "XYZ", "12345" }; const int N = texts.size(); m_nodesPool.resize(N); diff --git a/examples/ExampleApps/TextExampleApp.cpp b/examples/ExampleApps/TextExampleApp.cpp index 2c72bf6..ddbaebb 100644 --- a/examples/ExampleApps/TextExampleApp.cpp +++ b/examples/ExampleApps/TextExampleApp.cpp @@ -20,7 +20,6 @@ #include "Controller/FreeCamCameraController.hpp" #include "Scene/Text/SdfFontAtlasGenerator.hpp" #include "Scene/Text/BitmapFontAtlasGenerator.hpp" -#include "Scene/Text/FontAtlasFactory.hpp" #include #ifdef _WIN32 @@ -90,30 +89,30 @@ namespace OpenVulkano { t = new TextDrawable(m_atlasGenerator.GetAtlas(), texts[j].second); } - else + else if (i == 1) { t = new TextDrawable(m_msdfAtlasGenerator.GetAtlas(), texts[j].second); } #else if (i == 0) { - t = new TextDrawable(sdfMetadataInfo, texts[j].second); + t = new TextDrawable(std::make_shared(sdfMetadataInfo), texts[j].second); } else if (i == 1) { TextConfig cfg = texts[j].second; cfg.minimalSpacingBetweenMultipleLines = false; - t = new TextDrawable(msdfMetadataInfo, cfg); + t = new TextDrawable(std::make_shared(msdfMetadataInfo), cfg); } else if (i == 2) { // bitmap - t = new TextDrawable(bitmapMetadataInfo, texts[j].second); + t = new TextDrawable(std::make_shared(bitmapMetadataInfo), texts[j].second); } else if (i == 3) { // bitmap subpixel rendering - t = new TextDrawable(bitmapSubpixelRenderingMetadataInfo, texts[j].second); + t = new TextDrawable(std::make_shared(bitmapSubpixelRenderingMetadataInfo), texts[j].second); } // OR use separate texture + metadata file //auto metadataInfo = resourceLoader.GetResource("atlas_metadata"); diff --git a/openVulkanoCpp/Scene/TextDrawable.cpp b/openVulkanoCpp/Scene/TextDrawable.cpp index c4ced15..2aea099 100644 --- a/openVulkanoCpp/Scene/TextDrawable.cpp +++ b/openVulkanoCpp/Scene/TextDrawable.cpp @@ -23,8 +23,9 @@ namespace OpenVulkano::Scene Shader DEFAULT_SHADER_SDF = TextDrawable::MakeDefaultShader(FontAtlasType::SDF); Shader DEFAULT_SHADER_MSDF = TextDrawable::MakeDefaultShader(FontAtlasType::MSDF); - void HandleSpecialCharacter(const std::map& symbols, uint32_t c, float heightBetweenLines, - float initialPosX, float& cursorX, float& cursorY, float& prevGlyphXBound) + void HandleSpecialCharacter(const std::map& symbols, uint32_t c, + const float heightBetweenLines, const float initialPosX, + float& cursorX, float& cursorY, float& prevGlyphXBound) { if (c == '\n') { @@ -80,16 +81,6 @@ namespace OpenVulkano::Scene : Drawable(DrawEncoder::GetDrawEncoder()), m_cfg(config) {} - TextDrawable::TextDrawable(const std::string& atlasMetadataFile, const TextConfig& config) - : TextDrawable(Utils::ReadFile(atlasMetadataFile), config) - {} - - TextDrawable::TextDrawable(const Array& atlasMetadata, const TextConfig& config) - : Drawable(DrawEncoder::GetDrawEncoder()), m_cfg(config) - { - m_atlasData = std::make_shared(atlasMetadata); - } - TextDrawable::TextDrawable(const std::shared_ptr& atlasData, const TextConfig& config) : Drawable(DrawEncoder::GetDrawEncoder()), m_atlasData(atlasData), m_cfg(config) { diff --git a/openVulkanoCpp/Scene/TextDrawable.hpp b/openVulkanoCpp/Scene/TextDrawable.hpp index 4109b63..e4e8764 100644 --- a/openVulkanoCpp/Scene/TextDrawable.hpp +++ b/openVulkanoCpp/Scene/TextDrawable.hpp @@ -9,7 +9,6 @@ #include "Drawable.hpp" #include "Texture.hpp" #include "VertexBuffer.hpp" -#include "Image/Image.hpp" #include "Text/FontAtlas.hpp" namespace OpenVulkano::Scene @@ -47,8 +46,6 @@ namespace OpenVulkano::Scene public: TextDrawable(const TextConfig& config = TextConfig()); - TextDrawable(const std::string& atlasMetadataFile, const TextConfig& config = TextConfig()); - TextDrawable(const Array& atlasMetadata, const TextConfig& config = TextConfig()); TextDrawable(const std::shared_ptr& atlasData, const TextConfig& config = TextConfig()); void GenerateText(const std::string& text, const Math::Vector2f& pos = Math::Vector2f(0.f), float scale = 1.0f); @@ -61,7 +58,7 @@ namespace OpenVulkano::Scene [[nodiscard]] const std::shared_ptr& GetAtlasData() { return m_atlasData; } [[nodiscard]] VertexBuffer* GetVertexBuffer() { return &m_vertexBuffer; } - [[nodiscard]] Texture* GetTexture() { return m_atlasData->GetTexture(); } + [[nodiscard]] Texture* GetTexture() const { return m_atlasData->GetTexture(); } [[nodiscard]] size_t GetSymbolCount() const { return m_symbolCount; } [[nodiscard]] static Shader MakeDefaultShader(FontAtlasType type);