rename main sdf class for convenient synonym names

This commit is contained in:
ohyzha
2024-12-31 12:15:15 +02:00
parent 43842d6ece
commit 0dd0532775
3 changed files with 16 additions and 16 deletions

View File

@@ -80,7 +80,7 @@ namespace OpenVulkano
} }
#if defined(MSDFGEN_AVAILABLE) && CREATE_NEW_ATLAS #if defined(MSDFGEN_AVAILABLE) && CREATE_NEW_ATLAS
std::set<uint32_t> s = SdfFontAtlasGeneratorT::LoadAllGlyphs(fontPath); std::set<uint32_t> s = SdfFontAtlasGenerator::LoadAllGlyphs(fontPath);
m_atlasGenerator.GenerateAtlas(fontPath, s); m_atlasGenerator.GenerateAtlas(fontPath, s);
m_msdfAtlasGenerator.GenerateAtlas(fontPath, s); m_msdfAtlasGenerator.GenerateAtlas(fontPath, s);
m_atlasGenerator.SaveAtlasMetadataInfo("sdf_atlas.png"); m_atlasGenerator.SaveAtlasMetadataInfo("sdf_atlas.png");
@@ -176,7 +176,7 @@ namespace OpenVulkano
PerspectiveCamera m_cam; PerspectiveCamera m_cam;
OpenVulkano::FreeCamCameraController m_camController; OpenVulkano::FreeCamCameraController m_camController;
#ifdef MSDFGEN_AVAILABLE #ifdef MSDFGEN_AVAILABLE
SdfFontAtlasGeneratorT m_atlasGenerator; SdfFontAtlasGenerator m_atlasGenerator;
MsdfFontAtlasGenerator m_msdfAtlasGenerator; MsdfFontAtlasGenerator m_msdfAtlasGenerator;
#endif #endif
std::vector<SimpleDrawable*> m_drawablesPool; std::vector<SimpleDrawable*> m_drawablesPool;

View File

@@ -21,7 +21,7 @@ namespace OpenVulkano::Scene
SdfFontAtlasGeneratorConfig SdfFontAtlasGeneratorConfig::msdfDefaultConfig = { 32, 1.0, 3 }; SdfFontAtlasGeneratorConfig SdfFontAtlasGeneratorConfig::msdfDefaultConfig = { 32, 1.0, 3 };
template<int Channels> template<int Channels>
void SdfFontAtlasGenerator<Channels>::GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset, void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput) const std::optional<std::string>& pngOutput)
{ {
FreetypeHandle* ft; FreetypeHandle* ft;
@@ -32,14 +32,14 @@ namespace OpenVulkano::Scene
Generate(ft, font, s, pngOutput); Generate(ft, font, s, pngOutput);
} }
template<int Channels> SdfFontAtlasGenerator<Channels>::SdfFontAtlasGenerator() : FontAtlasGeneratorBase(Channels) template<int Channels> SdfFontAtlasGeneratorGeneric<Channels>::SdfFontAtlasGeneratorGeneric() : FontAtlasGeneratorBase(Channels)
{ {
if constexpr (Channels == 1) m_config = SdfFontAtlasGeneratorConfig::sdfDefaultConfig; if constexpr (Channels == 1) m_config = SdfFontAtlasGeneratorConfig::sdfDefaultConfig;
else m_config = SdfFontAtlasGeneratorConfig::msdfDefaultConfig; else m_config = SdfFontAtlasGeneratorConfig::msdfDefaultConfig;
} }
template<int Channels> template<int Channels>
void SdfFontAtlasGenerator<Channels>::GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset, void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput) const std::optional<std::string>& pngOutput)
{ {
FreetypeHandle* ft; FreetypeHandle* ft;
@@ -51,7 +51,7 @@ namespace OpenVulkano::Scene
} }
template<int Channels> template<int Channels>
void SdfFontAtlasGenerator<Channels>::GenerateAtlas(const std::string& fontFile, const Charset& charset, void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const std::string& fontFile, const Charset& charset,
const std::optional<std::string>& pngOutput) const std::optional<std::string>& pngOutput)
{ {
// TODO: dynamic atlas and add only those symbols which are not present yet in current atlas // TODO: dynamic atlas and add only those symbols which are not present yet in current atlas
@@ -62,7 +62,7 @@ namespace OpenVulkano::Scene
} }
template<int Channels> template<int Channels>
void SdfFontAtlasGenerator<Channels>::GenerateAtlas(const msdfgen::byte* fontData, int length, void SdfFontAtlasGeneratorGeneric<Channels>::GenerateAtlas(const msdfgen::byte* fontData, int length,
const Charset& charset, const Charset& charset,
const std::optional<std::string>& pngOutput) const std::optional<std::string>& pngOutput)
{ {
@@ -73,7 +73,7 @@ namespace OpenVulkano::Scene
} }
template<int Channels> template<int Channels>
void SdfFontAtlasGenerator<Channels>::InitFreetypeFromFile(FreetypeHandle*& ft, FontHandle*& font, void SdfFontAtlasGeneratorGeneric<Channels>::InitFreetypeFromFile(FreetypeHandle*& ft, FontHandle*& font,
const std::string& fontFile) const std::string& fontFile)
{ {
ft = initializeFreetype(); ft = initializeFreetype();
@@ -88,7 +88,7 @@ namespace OpenVulkano::Scene
} }
template<int Channels> template<int Channels>
void SdfFontAtlasGenerator<Channels>::InitFreetypeFromBuffer(FreetypeHandle*& ft, FontHandle*& font, void SdfFontAtlasGeneratorGeneric<Channels>::InitFreetypeFromBuffer(FreetypeHandle*& ft, FontHandle*& font,
const msdfgen::byte* fontData, int length) const msdfgen::byte* fontData, int length)
{ {
ft = initializeFreetype(); ft = initializeFreetype();
@@ -103,7 +103,7 @@ namespace OpenVulkano::Scene
} }
template<int Channels> template<int Channels>
void SdfFontAtlasGenerator<Channels>::Generate(FreetypeHandle* ft, FontHandle* font, const Charset& chset, void SdfFontAtlasGeneratorGeneric<Channels>::Generate(FreetypeHandle* ft, FontHandle* font, const Charset& chset,
const std::optional<std::string>& pngOutput) const std::optional<std::string>& pngOutput)
{ {
m_atlasData.reset(new AtlasData); m_atlasData.reset(new AtlasData);
@@ -200,7 +200,7 @@ namespace OpenVulkano::Scene
deinitializeFreetype(ft); deinitializeFreetype(ft);
} }
template class SdfFontAtlasGenerator<1>; template class SdfFontAtlasGeneratorGeneric<1>;
template class SdfFontAtlasGenerator<3>; template class SdfFontAtlasGeneratorGeneric<3>;
} }
#endif #endif

View File

@@ -30,7 +30,7 @@ namespace OpenVulkano::Scene
}; };
template<int Channels> template<int Channels>
class SdfFontAtlasGenerator final : public FontAtlasGeneratorBase class SdfFontAtlasGeneratorGeneric final : public FontAtlasGeneratorBase
{ {
private: private:
using SdfGenerator = msdf_atlas::ImmediateAtlasGenerator<float, 1, msdf_atlas::sdfGenerator, using SdfGenerator = msdf_atlas::ImmediateAtlasGenerator<float, 1, msdf_atlas::sdfGenerator,
@@ -41,7 +41,7 @@ namespace OpenVulkano::Scene
using Generator = std::conditional<Channels == 1, SdfGenerator, MsdfGenerator>::type; using Generator = std::conditional<Channels == 1, SdfGenerator, MsdfGenerator>::type;
using Config = SdfFontAtlasGeneratorConfig; using Config = SdfFontAtlasGeneratorConfig;
static constexpr int channelsCount = (Channels == 1 ? 1 : 4); static constexpr int channelsCount = (Channels == 1 ? 1 : 4);
SdfFontAtlasGenerator(); SdfFontAtlasGeneratorGeneric();
void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset, void GenerateAtlas(const std::string& fontFile, const std::set<uint32_t>& charset,
const std::optional<std::string>& pngOutput = std::nullopt) override; const std::optional<std::string>& pngOutput = std::nullopt) override;
void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset, void GenerateAtlas(const Array<char>& fontData, const std::set<uint32_t>& charset,
@@ -62,7 +62,7 @@ namespace OpenVulkano::Scene
private: private:
Config m_config; Config m_config;
}; };
using SdfFontAtlasGeneratorT = SdfFontAtlasGenerator<1>; using SdfFontAtlasGenerator = SdfFontAtlasGeneratorGeneric<1>;
using MsdfFontAtlasGenerator = SdfFontAtlasGenerator<3>; using MsdfFontAtlasGenerator = SdfFontAtlasGeneratorGeneric<3>;
} }
#endif #endif