This commit is contained in:
2024-10-21 19:45:33 +02:00
parent 0304834008
commit 7a3e5f37fa
22 changed files with 121 additions and 68 deletions

View File

@@ -5,26 +5,20 @@
namespace mlx
{
NonOwningPtr<Texture> PutPixelManager::DrawPixel(int x, int y, bool insert_new_texture, std::uint32_t color)
NonOwningPtr<Texture> PutPixelManager::DrawPixel(int x, int y, std::uint64_t draw_layer, std::uint32_t color)
{
Verify((bool)p_renderer, "invalid renderer pointer");
VkExtent2D swapchain_extent = kvfGetSwapchainImagesSize(p_renderer->GetSwapchain());
if(insert_new_texture)
{
#ifdef DEBUG
Texture& texture = m_textures.emplace_back(CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_put_pixel_layer_" + std::to_string(m_textures.size()));
#else
Texture& texture = m_textures.emplace_back(CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, std::string_view{});
#endif
texture.Clear(VK_NULL_HANDLE, Vec4f{ 0.0f });
}
if(!m_textures.empty())
{
m_textures.back().SetPixel(x, y, color);
return (insert_new_texture ? &m_textures.back() : nullptr);
}
return nullptr;
#ifdef DEBUG
auto res = m_textures.try_emplace(draw_layer, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_put_pixel_layer_" + std::to_string(draw_layer));
#else
auto res = m_textures.try_emplace(draw_layer, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, std::string_view{});
#endif
if(res.second)
res.first->second.Clear(VK_NULL_HANDLE, Vec4f{ 0.0f });
res.first->second.SetPixel(x, y, color);
return (res.second ? &res.first->second : nullptr);
}
void PutPixelManager::ResetRenderData()