Fix bugs introduced by refactoring

This commit is contained in:
Georg Hagen
2025-01-04 02:45:46 +01:00
parent 884949f92f
commit bc78af70e8
2 changed files with 10 additions and 6 deletions

View File

@@ -12,6 +12,7 @@
#include "Scene/Texture.hpp"
#include <string_view>
#include <map>
#include <magic_enum.hpp>
namespace OpenVulkano::Scene
{
@@ -29,23 +30,27 @@ namespace OpenVulkano::Scene
public:
enum Type : int16_t
{
BITMAP = 0,
SDF,
SDF = 0,
MSDF,
BITMAP,
UNKNOWN
};
static constexpr std::string_view DEFAULT_FG_SHADERS[] = { "Shader/text", "Shader/sdfText", "Shader/msdfText" };
static constexpr std::string_view DEFAULT_FG_SHADERS[] = { "Shader/sdfText", "Shader/msdfText", "Shader/text" };
constexpr FontAtlasType(Type type) : m_type(type) {}
[[nodiscard]] constexpr Type GetType() const { return m_type; }
[[nodiscard]] constexpr auto GetName() const { return magic_enum::enum_name(m_type); }
[[nodiscard]] constexpr const std::string_view& GetDefaultFragmentShader() const
{
return DEFAULT_FG_SHADERS[static_cast<int>(m_type)];
}
[[nodiscard]] constexpr operator Type() const { return m_type; }
private:
Type m_type;
};
@@ -54,7 +59,7 @@ namespace OpenVulkano::Scene
{
// vertical difference between baselines
double lineHeight = 0;
int16_t atlasType = FontAtlasType::UNKNOWN;
FontAtlasType atlasType = FontAtlasType::UNKNOWN;
};
struct AtlasData

View File

@@ -74,10 +74,9 @@ namespace OpenVulkano::Scene
TextDrawable& textDrawable = m_texts.emplace_back(m_atlasData, config);
// do not render glyph's background
textDrawable.GetConfig().backgroundColor.a = 0;
textDrawable.SetShader(&m_textShader);
double lineHeight = m_atlasData->meta.lineHeight;
textDrawable.GenerateText(text, m_position);
textDrawable.SetShader(&m_textShader);
m_bbox.Grow(textDrawable.GetBoundingBox());
// update position for next text entry
m_position.y = m_bbox.GetMin().y - lineHeight;