More text cleanup
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
#include "Base/EngineConfiguration.hpp"
|
#include "Base/EngineConfiguration.hpp"
|
||||||
#include "Controller/FreeCamCameraController.hpp"
|
#include "Controller/FreeCamCameraController.hpp"
|
||||||
#include "Scene/Text/SdfFontAtlasGenerator.hpp"
|
#include "Scene/Text/SdfFontAtlasGenerator.hpp"
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#undef TRANSPARENT
|
#undef TRANSPARENT
|
||||||
@@ -47,7 +46,7 @@ namespace OpenVulkano
|
|||||||
auto& resourceLoader = ResourceLoader::GetInstance();
|
auto& resourceLoader = ResourceLoader::GetInstance();
|
||||||
auto sdfMetadataInfo = resourceLoader.GetResource("sdf_atlas_packed.png");
|
auto sdfMetadataInfo = resourceLoader.GetResource("sdf_atlas_packed.png");
|
||||||
|
|
||||||
TextDrawable textDrawable(sdfMetadataInfo);
|
TextDrawable textDrawable(std::make_shared<FontAtlas>(sdfMetadataInfo));
|
||||||
const std::vector<std::string> texts = { "_!?{}.#@", "1", "XYZ", "12345" };
|
const std::vector<std::string> texts = { "_!?{}.#@", "1", "XYZ", "12345" };
|
||||||
const int N = texts.size();
|
const int N = texts.size();
|
||||||
m_nodesPool.resize(N);
|
m_nodesPool.resize(N);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "Controller/FreeCamCameraController.hpp"
|
#include "Controller/FreeCamCameraController.hpp"
|
||||||
#include "Scene/Text/SdfFontAtlasGenerator.hpp"
|
#include "Scene/Text/SdfFontAtlasGenerator.hpp"
|
||||||
#include "Scene/Text/BitmapFontAtlasGenerator.hpp"
|
#include "Scene/Text/BitmapFontAtlasGenerator.hpp"
|
||||||
#include "Scene/Text/FontAtlasFactory.hpp"
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -90,30 +89,30 @@ namespace OpenVulkano
|
|||||||
{
|
{
|
||||||
t = new TextDrawable(m_atlasGenerator.GetAtlas(), texts[j].second);
|
t = new TextDrawable(m_atlasGenerator.GetAtlas(), texts[j].second);
|
||||||
}
|
}
|
||||||
else
|
else if (i == 1)
|
||||||
{
|
{
|
||||||
t = new TextDrawable(m_msdfAtlasGenerator.GetAtlas(), texts[j].second);
|
t = new TextDrawable(m_msdfAtlasGenerator.GetAtlas(), texts[j].second);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
t = new TextDrawable(sdfMetadataInfo, texts[j].second);
|
t = new TextDrawable(std::make_shared<FontAtlas>(sdfMetadataInfo), texts[j].second);
|
||||||
}
|
}
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
{
|
{
|
||||||
TextConfig cfg = texts[j].second;
|
TextConfig cfg = texts[j].second;
|
||||||
cfg.minimalSpacingBetweenMultipleLines = false;
|
cfg.minimalSpacingBetweenMultipleLines = false;
|
||||||
t = new TextDrawable(msdfMetadataInfo, cfg);
|
t = new TextDrawable(std::make_shared<FontAtlas>(msdfMetadataInfo), cfg);
|
||||||
}
|
}
|
||||||
else if (i == 2)
|
else if (i == 2)
|
||||||
{
|
{
|
||||||
// bitmap
|
// bitmap
|
||||||
t = new TextDrawable(bitmapMetadataInfo, texts[j].second);
|
t = new TextDrawable(std::make_shared<FontAtlas>(bitmapMetadataInfo), texts[j].second);
|
||||||
}
|
}
|
||||||
else if (i == 3)
|
else if (i == 3)
|
||||||
{
|
{
|
||||||
// bitmap subpixel rendering
|
// bitmap subpixel rendering
|
||||||
t = new TextDrawable(bitmapSubpixelRenderingMetadataInfo, texts[j].second);
|
t = new TextDrawable(std::make_shared<FontAtlas>(bitmapSubpixelRenderingMetadataInfo), texts[j].second);
|
||||||
}
|
}
|
||||||
// OR use separate texture + metadata file
|
// OR use separate texture + metadata file
|
||||||
//auto metadataInfo = resourceLoader.GetResource("atlas_metadata");
|
//auto metadataInfo = resourceLoader.GetResource("atlas_metadata");
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ namespace OpenVulkano::Scene
|
|||||||
Shader DEFAULT_SHADER_SDF = TextDrawable::MakeDefaultShader(FontAtlasType::SDF);
|
Shader DEFAULT_SHADER_SDF = TextDrawable::MakeDefaultShader(FontAtlasType::SDF);
|
||||||
Shader DEFAULT_SHADER_MSDF = TextDrawable::MakeDefaultShader(FontAtlasType::MSDF);
|
Shader DEFAULT_SHADER_MSDF = TextDrawable::MakeDefaultShader(FontAtlasType::MSDF);
|
||||||
|
|
||||||
void HandleSpecialCharacter(const std::map<uint32_t, GlyphInfo>& symbols, uint32_t c, float heightBetweenLines,
|
void HandleSpecialCharacter(const std::map<uint32_t, GlyphInfo>& symbols, uint32_t c,
|
||||||
float initialPosX, float& cursorX, float& cursorY, float& prevGlyphXBound)
|
const float heightBetweenLines, const float initialPosX,
|
||||||
|
float& cursorX, float& cursorY, float& prevGlyphXBound)
|
||||||
{
|
{
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
@@ -80,16 +81,6 @@ namespace OpenVulkano::Scene
|
|||||||
: Drawable(DrawEncoder::GetDrawEncoder<TextDrawable>()), m_cfg(config)
|
: Drawable(DrawEncoder::GetDrawEncoder<TextDrawable>()), m_cfg(config)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
TextDrawable::TextDrawable(const std::string& atlasMetadataFile, const TextConfig& config)
|
|
||||||
: TextDrawable(Utils::ReadFile(atlasMetadataFile), config)
|
|
||||||
{}
|
|
||||||
|
|
||||||
TextDrawable::TextDrawable(const Array<char>& atlasMetadata, const TextConfig& config)
|
|
||||||
: Drawable(DrawEncoder::GetDrawEncoder<TextDrawable>()), m_cfg(config)
|
|
||||||
{
|
|
||||||
m_atlasData = std::make_shared<FontAtlas>(atlasMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextDrawable::TextDrawable(const std::shared_ptr<FontAtlas>& atlasData, const TextConfig& config)
|
TextDrawable::TextDrawable(const std::shared_ptr<FontAtlas>& atlasData, const TextConfig& config)
|
||||||
: Drawable(DrawEncoder::GetDrawEncoder<TextDrawable>()), m_atlasData(atlasData), m_cfg(config)
|
: Drawable(DrawEncoder::GetDrawEncoder<TextDrawable>()), m_atlasData(atlasData), m_cfg(config)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include "Drawable.hpp"
|
#include "Drawable.hpp"
|
||||||
#include "Texture.hpp"
|
#include "Texture.hpp"
|
||||||
#include "VertexBuffer.hpp"
|
#include "VertexBuffer.hpp"
|
||||||
#include "Image/Image.hpp"
|
|
||||||
#include "Text/FontAtlas.hpp"
|
#include "Text/FontAtlas.hpp"
|
||||||
|
|
||||||
namespace OpenVulkano::Scene
|
namespace OpenVulkano::Scene
|
||||||
@@ -47,8 +46,6 @@ namespace OpenVulkano::Scene
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TextDrawable(const TextConfig& config = TextConfig());
|
TextDrawable(const TextConfig& config = TextConfig());
|
||||||
TextDrawable(const std::string& atlasMetadataFile, const TextConfig& config = TextConfig());
|
|
||||||
TextDrawable(const Array<char>& atlasMetadata, const TextConfig& config = TextConfig());
|
|
||||||
TextDrawable(const std::shared_ptr<FontAtlas>& atlasData, const TextConfig& config = TextConfig());
|
TextDrawable(const std::shared_ptr<FontAtlas>& atlasData, const TextConfig& config = TextConfig());
|
||||||
|
|
||||||
void GenerateText(const std::string& text, const Math::Vector2f& pos = Math::Vector2f(0.f), float scale = 1.0f);
|
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<FontAtlas>& GetAtlasData() { return m_atlasData; }
|
[[nodiscard]] const std::shared_ptr<FontAtlas>& GetAtlasData() { return m_atlasData; }
|
||||||
|
|
||||||
[[nodiscard]] VertexBuffer* GetVertexBuffer() { return &m_vertexBuffer; }
|
[[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]] size_t GetSymbolCount() const { return m_symbolCount; }
|
||||||
|
|
||||||
[[nodiscard]] static Shader MakeDefaultShader(FontAtlasType type);
|
[[nodiscard]] static Shader MakeDefaultShader(FontAtlasType type);
|
||||||
|
|||||||
Reference in New Issue
Block a user