Unify text shader handling

This commit is contained in:
Georg Hagen
2025-01-04 02:46:24 +01:00
parent bc78af70e8
commit 94025c79c6
7 changed files with 60 additions and 51 deletions

View File

@@ -62,7 +62,6 @@ namespace OpenVulkano
texts.push_back(std::make_pair("\u0410\u0411\u0412\u041F", TextConfig()));
texts.push_back(std::make_pair("Unsupported glyphs \u1E30\u1E31 are coming", TextConfig()));
texts.push_back(std::make_pair("This is first line\nSecond gg line\nThird G line", TextConfig()));
texts[0].second.applyBorder = true;
texts[1].second.backgroundColor.a = 1;
const int N = texts.size();
@@ -98,32 +97,27 @@ namespace OpenVulkano
#if defined(MSDFGEN_AVAILABLE) && CREATE_NEW_ATLAS
if (i < texts.size())
{
t = new TextDrawable(m_atlasGenerator.GetAtlasData(), texts[textIdx].second);
t->SetShader(&TextDrawable::GetSdfDefaultShader());
t = new TextDrawable(m_atlasGenerator.GetAtlasData(), texts[textIdx].second);
}
else
{
t = new TextDrawable(m_msdfAtlasGenerator.GetAtlasData(), texts[textIdx].second);
t->SetShader(&TextDrawable::GetMsdfDefaultShader());
t = new TextDrawable(m_msdfAtlasGenerator.GetAtlasData(), texts[textIdx].second);
}
#else
int xOffset = 0;
if (i < N)
{
t = new TextDrawable(sdfMetadataInfo, texts[textIdx].second);
t->SetShader(&TextDrawable::GetSdfDefaultShader());
t = new TextDrawable(sdfMetadataInfo, texts[textIdx].second);
xOffset = -5;
}
else if (i >= N && i < N * 2)
{
t = new TextDrawable(msdfMetadataInfo, texts[textIdx].second);
t->SetShader(&TextDrawable::GetMsdfDefaultShader());
t = new TextDrawable(msdfMetadataInfo, texts[textIdx].second);
xOffset = 15;
}
else
{
t = new TextDrawable(bitmapMetadataInfo, texts[textIdx].second);
t->SetShader(&TextDrawable::GetBitmapDefaultShader());
t = new TextDrawable(bitmapMetadataInfo, texts[textIdx].second);
xOffset = 35;
}
// OR use separate texture + metadata file