this feel so wrong

This commit is contained in:
Namonay
2024-10-24 05:13:41 +02:00
parent 3291e0cd2a
commit e1fefba841
2 changed files with 13 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ namespace mlx
int m_id; int m_id;
bool m_has_window; bool m_has_window;
bool m_putpixel_called = false;
}; };
} }

View File

@@ -9,7 +9,8 @@ namespace mlx
p_scene->ResetSprites(); p_scene->ResetSprites();
m_put_pixel_manager.ResetRenderData(); m_put_pixel_manager.ResetRenderData();
m_draw_layer = 0; 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 void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept
@@ -18,6 +19,7 @@ namespace mlx
NonOwningPtr<Texture> texture = m_put_pixel_manager.DrawPixel(x, y, m_draw_layer, color); NonOwningPtr<Texture> texture = m_put_pixel_manager.DrawPixel(x, y, m_draw_layer, color);
if(texture) if(texture)
{ {
m_putpixel_called = true;
Sprite& new_sprite = p_scene->CreateSprite(texture); Sprite& new_sprite = p_scene->CreateSprite(texture);
new_sprite.SetPosition(Vec2f{ 0.0f, 0.0f }); new_sprite.SetPosition(Vec2f{ 0.0f, 0.0f });
} }
@@ -38,12 +40,20 @@ namespace mlx
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) }); NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) });
if(!sprite) if(!sprite)
{ {
Sprite& new_sprite = p_scene->CreateSprite(texture); Sprite& new_sprite = p_scene->CreateSprite(texture);
new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) }); new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
m_draw_layer++; if (m_putpixel_called)
{
m_draw_layer++;
m_putpixel_called = false;
}
} }
else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer)) else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer))
{
p_scene->BringToFront(std::move(sprite)); p_scene->BringToFront(std::move(sprite));
m_draw_layer++;
}
} }
void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale) void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale)