working version of glyphs rendering with example

This commit is contained in:
ohyzha
2024-07-31 12:54:24 +03:00
parent 847b8660b5
commit 9b58ba5f55
9 changed files with 352 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "UpdateFrequency.hpp"
#include "Base/ICloseable.hpp"
#include "Math/Math.hpp"
#include "DataFormat.hpp"
#include "SimpleDrawable.hpp"
namespace OpenVulkano::Scene
{
//using namespace msdfgen;
//using namespace msdf_atlas;
struct TextConfig
{
Math::Vector4f textColor = { 1, 1, 1, 0 }; // vec4 to match paddding (multiple of 16)
Math::Vector3f borderColor = { 1, 0, 0 };
int outputSize = 256;
float threshold = 0.5f;
float borderSize = 0.2f;
float smoothing = 1.f/16.f;
bool applyBorder = false;
//bool sdfMultiChannel = false;
};
class Text : public SimpleDrawable
{
public:
Text(const TextConfig& cfg) : m_cfg(cfg) {}
void Init(const std::string_view fontFile, char8_t symbol, const std::string_view outputFile);
void Init(const std::string_view fontFile, std::vector<char8_t> symbols, const std::string_view outputFile);
void setConfig(const TextConfig& cfg) { m_cfg = cfg; }
TextConfig& GetConfig() { return m_cfg; }
private:
TextConfig m_cfg;
};
}