working on texts and fonts

This commit is contained in:
2024-10-27 01:14:07 +02:00
parent 3aaa5df929
commit 028cb57ff4
31 changed files with 414 additions and 187 deletions

View File

@@ -2,24 +2,38 @@
#define __MLX_TEXT__
#include <Graphics/Font.h>
#include <Graphics/Mesh.h>
#include <Graphics/Drawable.h>
namespace mlx
{
class Text
class Text : public Drawable
{
friend class Render2DPass;
public:
Text(const std::string& text, std::shared_ptr<Font> font);
inline Text(const std::string& text, std::shared_ptr<Font> font, std::shared_ptr<Mesh> mesh) : Drawable(DrawableType::Text) { Init(text, font, mesh); }
[[nodiscard]] inline const std::string& GetText() const { return m_text; }
[[nodiscard]] inline std::shared_ptr<Font> GetFont() const { return p_font; }
[[nodiscard]] MLX_FORCEINLINE std::uint32_t GetColor() const noexcept { return m_color; }
~Text();
virtual ~Text() = default;
private:
void Init(const std::string& text, std::shared_ptr<Font> font, std::shared_ptr<Mesh> mesh);
inline void Bind(std::size_t frame_index, VkCommandBuffer cmd) override
{
if(!p_set)
return;
p_set->SetImage(frame_index, 0, const_cast<Texture&>(p_font->GetTexture()));
p_set->Update(frame_index, cmd);
}
private:
std::shared_ptr<Font> p_font;
std::string m_text;
std::uint32_t m_color;
};
}