working version of text rendering
This commit is contained in:
@@ -11,20 +11,24 @@
|
||||
#include "Math/Math.hpp"
|
||||
#include "DataFormat.hpp"
|
||||
#include "SimpleDrawable.hpp"
|
||||
#include "FontAtlasGenerator.hpp"
|
||||
#include "Texture.hpp"
|
||||
#include "msdfgen.h"
|
||||
#include "msdfgen-ext.h"
|
||||
#include "msdf-atlas-gen/msdf-atlas-gen.h"
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
//using namespace msdfgen;
|
||||
//using namespace msdf_atlas;
|
||||
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;
|
||||
float threshold = 0.4f;
|
||||
float borderSize = 0.05f;
|
||||
float smoothing = 1.f/32.f;
|
||||
bool applyBorder = false;
|
||||
//bool sdfMultiChannel = false;
|
||||
};
|
||||
@@ -32,12 +36,16 @@ namespace OpenVulkano::Scene
|
||||
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; }
|
||||
Text() = default;
|
||||
~Text();
|
||||
void SetUniformBuffer(UniformBuffer* buffer) { m_uniBuffer = buffer; }
|
||||
void GenerateText(const std::string& text, const Math::Vector3f& pos = Math::Vector3f(0.f));
|
||||
void SetConfig(const TextConfig& cfg) { m_cfg = cfg; }
|
||||
TextConfig& GetConfig() { return m_cfg; }
|
||||
void SetFontAtlasGenerator(FontAtlasGenerator* fontAtlasGenerator) { m_fontAtlasGenerator = fontAtlasGenerator; }
|
||||
FontAtlasGenerator* GetFontAtlasGenerator() { return m_fontAtlasGenerator; }
|
||||
private:
|
||||
FontAtlasGenerator* m_fontAtlasGenerator = nullptr;
|
||||
TextConfig m_cfg;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user