mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
pushing for vavaas to debug
This commit is contained in:
@@ -148,20 +148,22 @@ namespace mlx
|
|||||||
void Application::LoadFont(const std::filesystem::path& filepath, float scale)
|
void Application::LoadFont(const std::filesystem::path& filepath, float scale)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
std::shared_ptr<Font> font;
|
std::shared_ptr<Font> font = m_font_registry.GetFont(filepath, scale);
|
||||||
if(filepath.string() == "default")
|
if(!font)
|
||||||
font = std::make_shared<Font>("default", dogica_ttf, scale);
|
{
|
||||||
else
|
if(filepath.string() == "default")
|
||||||
font = std::make_shared<Font>(filepath, scale);
|
font = std::make_shared<Font>("default", dogica_ttf, scale);
|
||||||
|
else
|
||||||
|
font = std::make_shared<Font>(filepath, scale);
|
||||||
|
font->BuildFont();
|
||||||
|
m_font_registry.RegisterFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
for(auto& gs : m_graphics)
|
for(auto& gs : m_graphics)
|
||||||
{
|
{
|
||||||
if(gs)
|
if(gs)
|
||||||
gs->GetScene().BindFont(font);
|
gs->GetScene().BindFont(font);
|
||||||
}
|
}
|
||||||
if(m_font_registry.IsFontKnown(font))
|
|
||||||
return;
|
|
||||||
font->BuildFont();
|
|
||||||
m_font_registry.RegisterFont(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::TexturePut(Handle win, Handle img, int x, int y)
|
void Application::TexturePut(Handle win, Handle img, int x, int y)
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ namespace mlx
|
|||||||
void GraphicsSupport::StringPut(int x, int y, std::uint32_t color, std::string str)
|
void GraphicsSupport::StringPut(int x, int y, std::uint32_t color, std::string str)
|
||||||
{
|
{
|
||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
|
if(str.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
Vec4f vec_color = {
|
Vec4f vec_color = {
|
||||||
static_cast<float>((color & 0x000000FF)) / 255.f,
|
static_cast<float>((color & 0x000000FF)) / 255.f,
|
||||||
static_cast<float>((color & 0x0000FF00) >> 8) / 255.f,
|
static_cast<float>((color & 0x0000FF00) >> 8) / 255.f,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace mlx
|
|||||||
|
|
||||||
inline void RegisterFont(std::shared_ptr<Font> font);
|
inline void RegisterFont(std::shared_ptr<Font> font);
|
||||||
inline void UnregisterFont(std::shared_ptr<Font> font);
|
inline void UnregisterFont(std::shared_ptr<Font> font);
|
||||||
inline bool IsFontKnown(std::shared_ptr<Font> font);
|
inline std::shared_ptr<Font> GetFont(const std::filesystem::path& name, float scale);
|
||||||
|
|
||||||
~FontRegistry() = default;
|
~FontRegistry() = default;
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,12 @@ namespace mlx
|
|||||||
m_fonts_registry.erase(font);
|
m_fonts_registry.erase(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FontRegistry::IsFontKnown(std::shared_ptr<Font> font)
|
std::shared_ptr<Font> FontRegistry::GetFont(const std::filesystem::path& name, float scale)
|
||||||
{
|
{
|
||||||
return std::find_if(m_fonts_registry.begin(), m_fonts_registry.end(), [&font](std::shared_ptr<Font> rhs)
|
auto it = std::find_if(m_fonts_registry.begin(), m_fonts_registry.end(), [&name, scale](std::shared_ptr<Font> rhs)
|
||||||
{
|
{
|
||||||
return font->GetName() == rhs->GetName() && font->GetScale() == rhs->GetScale();
|
return name == rhs->GetName() && scale == rhs->GetScale();
|
||||||
}) != m_fonts_registry.end();
|
});
|
||||||
|
return (it != m_fonts_registry.end() ? *it : nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace mlx
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, m_name + "_font_altas");
|
m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, m_name + "_font_atlas");
|
||||||
#else
|
#else
|
||||||
m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, {});
|
m_atlas.Init(vulkan_bitmap, RANGE, RANGE, VK_FORMAT_R8G8B8A8_SRGB, false, {});
|
||||||
#endif
|
#endif
|
||||||
@@ -61,5 +61,6 @@ namespace mlx
|
|||||||
void Font::Destroy()
|
void Font::Destroy()
|
||||||
{
|
{
|
||||||
m_atlas.Destroy();
|
m_atlas.Destroy();
|
||||||
|
DebugLog("Font: unloaded %", m_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ namespace mlx
|
|||||||
|
|
||||||
std::size_t index = vertex_data.size();
|
std::size_t index = vertex_data.size();
|
||||||
|
|
||||||
vertex_data.emplace_back(Vec4f{ q.x0, q.y0, 0.0f, 0.0f }, Vec2f{ q.s0, q.t0 });
|
vertex_data.emplace_back(Vec4f{ q.x0, q.y0, 0.0f, 1.0f }, Vec2f{ q.s0, q.t0 });
|
||||||
vertex_data.emplace_back(Vec4f{ q.x1, q.y0, 0.0f, 0.0f }, Vec2f{ q.s1, q.t0 });
|
vertex_data.emplace_back(Vec4f{ q.x1, q.y0, 0.0f, 1.0f }, Vec2f{ q.s1, q.t0 });
|
||||||
vertex_data.emplace_back(Vec4f{ q.x1, q.y1, 0.0f, 0.0f }, Vec2f{ q.s1, q.t1 });
|
vertex_data.emplace_back(Vec4f{ q.x1, q.y1, 0.0f, 1.0f }, Vec2f{ q.s1, q.t1 });
|
||||||
vertex_data.emplace_back(Vec4f{ q.x0, q.y1, 0.0f, 0.0f }, Vec2f{ q.s0, q.t1 });
|
vertex_data.emplace_back(Vec4f{ q.x0, q.y1, 0.0f, 1.0f }, Vec2f{ q.s0, q.t1 });
|
||||||
|
|
||||||
index_data.emplace_back(index + 0);
|
index_data.emplace_back(index + 0);
|
||||||
index_data.emplace_back(index + 1);
|
index_data.emplace_back(index + 1);
|
||||||
|
|||||||
@@ -118,7 +118,16 @@ namespace mlx
|
|||||||
return;
|
return;
|
||||||
RenderCore::Get().GetAllocator().UnmapMemory(m_allocation);
|
RenderCore::Get().GetAllocator().UnmapMemory(m_allocation);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
RenderCore::Get().GetAllocator().DestroyBuffer(m_allocation, m_buffer, m_debug_name.c_str());
|
std::string alloc_name{ m_debug_name };
|
||||||
|
if(m_usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT)
|
||||||
|
alloc_name.append("_index_buffer");
|
||||||
|
else if(m_usage & VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)
|
||||||
|
alloc_name.append("_vertex_buffer");
|
||||||
|
else if(m_usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)
|
||||||
|
alloc_name.append("_uniform_buffer");
|
||||||
|
else
|
||||||
|
alloc_name.append("_buffer");
|
||||||
|
RenderCore::Get().GetAllocator().DestroyBuffer(m_allocation, m_buffer, alloc_name.c_str());
|
||||||
#else
|
#else
|
||||||
RenderCore::Get().GetAllocator().DestroyBuffer(m_allocation, m_buffer, nullptr);
|
RenderCore::Get().GetAllocator().DestroyBuffer(m_allocation, m_buffer, nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user