adding clear color in mlx_clear_window

This commit is contained in:
2024-11-04 21:21:46 +01:00
parent b59888efb3
commit e8de2c169d
15 changed files with 62 additions and 37 deletions

View File

@@ -27,7 +27,7 @@ namespace mlx
inline void SetFPSCap(std::uint32_t fps) noexcept;
inline Handle NewGraphicsSuport(std::size_t w, std::size_t h, const char* title, bool is_resizable);
inline void ClearGraphicsSupport(Handle win);
inline void ClearGraphicsSupport(Handle win, int color);
inline void DestroyGraphicsSupport(Handle win);
inline void SetGraphicsSupportPosition(Handle win, int x, int y);

View File

@@ -101,11 +101,11 @@ namespace mlx
return static_cast<void*>(&m_graphics.back()->GetID());
}
void Application::ClearGraphicsSupport(Handle win)
void Application::ClearGraphicsSupport(Handle win, int color)
{
MLX_PROFILE_FUNCTION();
CHECK_WINDOW_PTR(win);
m_graphics[*static_cast<int*>(win)]->ResetRenderData();
m_graphics[*static_cast<int*>(win)]->ResetRenderData(color);
}
void Application::DestroyGraphicsSupport(Handle win)

View File

@@ -22,7 +22,7 @@ namespace mlx
void Render() noexcept;
inline void ResetRenderData() noexcept;
inline void ResetRenderData(int color) noexcept;
inline void PixelPut(int x, int y, std::uint32_t color) noexcept;
inline void StringPut(int x, int y, std::uint32_t color, std::string str);

View File

@@ -3,10 +3,16 @@
namespace mlx
{
void GraphicsSupport::ResetRenderData() noexcept
void GraphicsSupport::ResetRenderData(int color) noexcept
{
MLX_PROFILE_FUNCTION();
p_scene->ResetScene();
Vec4f vec_color = {
static_cast<float>((color & 0x000000FF)) / 255.0f,
static_cast<float>((color & 0x0000FF00) >> 8) / 255.0f,
static_cast<float>((color & 0x00FF0000) >> 16) / 255.0f,
static_cast<float>((color & 0xFF000000) >> 24) / 255.0f
};
p_scene->ResetScene(std::move(vec_color));
m_put_pixel_manager.ResetRenderData();
m_draw_layer = 0;
m_pixelput_called = false;