From 101b8dac7b6f5bf5c21418a5b6c9f83f586aab8c Mon Sep 17 00:00:00 2001 From: Namonay Date: Thu, 24 Oct 2024 05:13:41 +0200 Subject: [PATCH 1/3] this feel so wrong --- runtime/Includes/Core/Graphics.h | 1 + runtime/Includes/Core/Graphics.inl | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/runtime/Includes/Core/Graphics.h b/runtime/Includes/Core/Graphics.h index 9da8029..6259f59 100644 --- a/runtime/Includes/Core/Graphics.h +++ b/runtime/Includes/Core/Graphics.h @@ -49,6 +49,7 @@ namespace mlx int m_id; bool m_has_window; + bool m_putpixel_called = false; }; } diff --git a/runtime/Includes/Core/Graphics.inl b/runtime/Includes/Core/Graphics.inl index a860896..24cb961 100644 --- a/runtime/Includes/Core/Graphics.inl +++ b/runtime/Includes/Core/Graphics.inl @@ -9,7 +9,8 @@ namespace mlx p_scene->ResetSprites(); m_put_pixel_manager.ResetRenderData(); m_draw_layer = 0; - PixelPut(0, 0, 0x00000000); // bozoman solution FIXME + m_putpixel_called = false; + // PixelPut(0, 0, 0x00000000); // bozoman solution FIXME } void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept @@ -18,6 +19,7 @@ namespace mlx NonOwningPtr texture = m_put_pixel_manager.DrawPixel(x, y, m_draw_layer, color); if(texture) { + m_putpixel_called = true; Sprite& new_sprite = p_scene->CreateSprite(texture); new_sprite.SetPosition(Vec2f{ 0.0f, 0.0f }); } @@ -38,12 +40,20 @@ namespace mlx NonOwningPtr sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast(x), static_cast(y) }); if(!sprite) { + Sprite& new_sprite = p_scene->CreateSprite(texture); new_sprite.SetPosition(Vec2f{ static_cast(x), static_cast(y) }); - m_draw_layer++; + if (m_putpixel_called) + { + m_draw_layer++; + m_putpixel_called = false; + } } else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer)) + { p_scene->BringToFront(std::move(sprite)); + m_draw_layer++; + } } void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale) From 47d0cfb20b54d5281462e4fda0b1ceb93f9dabdd Mon Sep 17 00:00:00 2001 From: Namonay Date: Thu, 24 Oct 2024 05:16:37 +0200 Subject: [PATCH 2/3] this feels wrong --- runtime/Includes/Core/Graphics.inl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/runtime/Includes/Core/Graphics.inl b/runtime/Includes/Core/Graphics.inl index bff2386..2c43035 100644 --- a/runtime/Includes/Core/Graphics.inl +++ b/runtime/Includes/Core/Graphics.inl @@ -9,12 +9,8 @@ namespace mlx p_scene->ResetSprites(); m_put_pixel_manager.ResetRenderData(); m_draw_layer = 0; -<<<<<<< HEAD m_putpixel_called = false; // PixelPut(0, 0, 0x00000000); // bozoman solution FIXME -======= - PixelPut(0, 0, 0x00000000); // bozoman solution FIXME WTF ->>>>>>> cfb41b7b2706234ac514c2daab7c3717863af115 } void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept From d8a66760638881cb606748e67ce71ecbb482ae84 Mon Sep 17 00:00:00 2001 From: Namonay Date: Thu, 24 Oct 2024 05:30:37 +0200 Subject: [PATCH 3/3] =?UTF-8?q?better=20naming=20and=20removed=20todo?= =?UTF-8?q?=F0=9F=A4=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/Includes/Core/Graphics.h | 2 +- runtime/Includes/Core/Graphics.inl | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/runtime/Includes/Core/Graphics.h b/runtime/Includes/Core/Graphics.h index e338694..8593523 100644 --- a/runtime/Includes/Core/Graphics.h +++ b/runtime/Includes/Core/Graphics.h @@ -47,7 +47,7 @@ namespace mlx int m_id; bool m_has_window; - bool m_putpixel_called = false; + bool m_pixelput_called = false; }; } diff --git a/runtime/Includes/Core/Graphics.inl b/runtime/Includes/Core/Graphics.inl index 2c43035..f4386a0 100644 --- a/runtime/Includes/Core/Graphics.inl +++ b/runtime/Includes/Core/Graphics.inl @@ -9,8 +9,7 @@ namespace mlx p_scene->ResetSprites(); m_put_pixel_manager.ResetRenderData(); m_draw_layer = 0; - m_putpixel_called = false; - // PixelPut(0, 0, 0x00000000); // bozoman solution FIXME + m_pixelput_called = false; } void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept @@ -19,7 +18,7 @@ namespace mlx NonOwningPtr texture = m_put_pixel_manager.DrawPixel(x, y, m_draw_layer, color); if(texture) { - m_putpixel_called = true; + m_pixelput_called = true; Sprite& new_sprite = p_scene->CreateSprite(texture); new_sprite.SetPosition(Vec2f{ 0.0f, 0.0f }); } @@ -43,10 +42,10 @@ namespace mlx Sprite& new_sprite = p_scene->CreateSprite(texture); new_sprite.SetPosition(Vec2f{ static_cast(x), static_cast(y) }); - if (m_putpixel_called) + if(m_pixelput_called) { m_draw_layer++; - m_putpixel_called = false; + m_pixelput_called = false; } } else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer))