Move GetDefaultShader logic into function
This commit is contained in:
@@ -207,16 +207,7 @@ namespace OpenVulkano::Scene
|
||||
bmin.x = m_geometry.vertices[0].position.x;
|
||||
m_bbox.Init(bmin, bmax);
|
||||
|
||||
if (!GetShader())
|
||||
{
|
||||
switch (m_atlasData->meta.atlasType)
|
||||
{
|
||||
case FontAtlasType::SDF: SetShader(&DEFAULT_SHADER_SDF); break;
|
||||
case FontAtlasType::MSDF: SetShader(&DEFAULT_SHADER_MSDF); break;
|
||||
default: Logger::RENDER->warn("No default shader for atlas type: {}", m_atlasData->meta.atlasType.GetName());
|
||||
case FontAtlasType::BITMAP: SetShader(&DEFAULT_SHADER_BITMAP); break;
|
||||
}
|
||||
}
|
||||
if (!GetShader()) SetShader(GetDefaultShader(m_atlasData->meta.atlasType));
|
||||
}
|
||||
|
||||
void TextDrawable::SetAtlasData(const std::shared_ptr<AtlasData>& atlasData)
|
||||
@@ -224,4 +215,15 @@ namespace OpenVulkano::Scene
|
||||
if (!atlasData || !*atlasData) throw std::runtime_error("Cannot initialize text drawable with empty atlas data");
|
||||
m_atlasData = atlasData;
|
||||
}
|
||||
|
||||
Shader* TextDrawable::GetDefaultShader(const FontAtlasType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case FontAtlasType::SDF: return &DEFAULT_SHADER_SDF;
|
||||
case FontAtlasType::MSDF: return &DEFAULT_SHADER_MSDF;
|
||||
default: Logger::RENDER->warn("No default shader for atlas type: {}", type.GetName());
|
||||
case FontAtlasType::BITMAP: return &DEFAULT_SHADER_BITMAP;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user