mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
working on texts and fonts
This commit is contained in:
@@ -6,10 +6,11 @@
|
||||
#include <Graphics/Mesh.h>
|
||||
#include <Renderer/Descriptor.h>
|
||||
#include <Renderer/Image.h>
|
||||
#include <Graphics/Drawable.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class Sprite
|
||||
class Sprite : public Drawable
|
||||
{
|
||||
friend class Render2DPass;
|
||||
|
||||
@@ -17,26 +18,18 @@ namespace mlx
|
||||
Sprite(NonOwningPtr<Texture> texture);
|
||||
Sprite(std::shared_ptr<Mesh> mesh, NonOwningPtr<Texture> texture);
|
||||
|
||||
inline void SetColor(Vec4f color) noexcept { m_color = color; }
|
||||
inline void SetPosition(Vec2f position) noexcept { m_position = position; }
|
||||
|
||||
[[nodiscard]] MLX_FORCEINLINE const Vec4f& GetColor() const noexcept { return m_color; }
|
||||
[[nodiscard]] MLX_FORCEINLINE const Vec2f& GetPosition() const noexcept { return m_position; }
|
||||
[[nodiscard]] MLX_FORCEINLINE std::shared_ptr<Mesh> GetMesh() const { return p_mesh; }
|
||||
[[nodiscard]] MLX_FORCEINLINE NonOwningPtr<Texture> GetTexture() const { return p_texture; }
|
||||
|
||||
inline ~Sprite() { if(p_set) p_set->ReturnDescriptorSetToPool(); }
|
||||
|
||||
private:
|
||||
[[nodiscard]] inline bool IsSetInit() const noexcept { return p_set && p_set->IsInit(); }
|
||||
[[nodiscard]] inline VkDescriptorSet GetSet(std::size_t frame_index) const noexcept { return p_set ? p_set->GetSet(frame_index) : VK_NULL_HANDLE; }
|
||||
|
||||
inline void UpdateDescriptorSet(std::shared_ptr<DescriptorSet> set)
|
||||
MLX_FORCEINLINE void Update(VkCommandBuffer cmd) override
|
||||
{
|
||||
p_set = RenderCore::Get().GetDescriptorPoolManager().GetAvailablePool().RequestDescriptorSet(set->GetShaderLayout(), set->GetShaderType());
|
||||
Verify((bool)p_texture, "a sprite has no texture attached (internal mlx issue, please report to the devs)");
|
||||
p_texture->Update(cmd);
|
||||
}
|
||||
|
||||
inline void Bind(std::size_t frame_index, VkCommandBuffer cmd)
|
||||
[[nodiscard]] MLX_FORCEINLINE NonOwningPtr<Texture> GetTexture() const { return p_texture; }
|
||||
|
||||
inline ~Sprite() = default;
|
||||
|
||||
private:
|
||||
inline void Bind(std::size_t frame_index, VkCommandBuffer cmd) override
|
||||
{
|
||||
if(!p_set)
|
||||
return;
|
||||
@@ -45,11 +38,7 @@ namespace mlx
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<DescriptorSet> p_set;
|
||||
NonOwningPtr<Texture> p_texture;
|
||||
std::shared_ptr<Mesh> p_mesh;
|
||||
Vec4f m_color = Vec4f{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
Vec2f m_position = Vec2f{ 0.0f, 0.0f };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user