mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
yes
This commit is contained in:
@@ -5,18 +5,22 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
NonOwningPtr<Texture> PutPixelManager::DrawPixel(int x, int y, std::uint64_t z, std::uint32_t color)
|
||||
NonOwningPtr<Texture> PutPixelManager::DrawPixel(int x, int y, bool insert_new_texture, std::uint32_t color)
|
||||
{
|
||||
Verify((bool)p_renderer, "invalid renderer pointer");
|
||||
|
||||
VkExtent2D swapchain_extent = kvfGetSwapchainImagesSize(p_renderer->GetSwapchain());
|
||||
#ifdef DEBUG
|
||||
auto res = m_textures.try_emplace(z, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_put_pixel_layer_" + std::to_string(z));
|
||||
#else
|
||||
auto res = m_textures.try_emplace(z, CPUBuffer{}, swapchain_extent.width, swapchain_extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, std::string_view{});
|
||||
#endif
|
||||
res.first->second.SetPixel(x, y, color);
|
||||
return (res.second ? &res.first->second : nullptr);
|
||||
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 });
|
||||
}
|
||||
m_textures.back().SetPixel(x, y, color);
|
||||
return (insert_new_texture ? &m_textures.back() : nullptr);
|
||||
}
|
||||
|
||||
void PutPixelManager::ResetRenderData()
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace mlx
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Verify((bool)m_descriptor.renderer, "invalid renderer");
|
||||
m_depth.Init(m_descriptor.renderer->GetSwapchainImages().back().GetWidth(), m_descriptor.renderer->GetSwapchainImages().back().GetHeight(), false, "mlx_scene_depth");
|
||||
}
|
||||
|
||||
Sprite& Scene::CreateSprite(NonOwningPtr<Texture> texture) noexcept
|
||||
@@ -31,6 +30,18 @@ namespace mlx
|
||||
return (it != m_sprites.end() ? it->get() : nullptr);
|
||||
}
|
||||
|
||||
void Scene::BringToFront(NonOwningPtr<Sprite> sprite)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
auto it = std::find_if(m_sprites.begin(), m_sprites.end(), [&sprite](std::shared_ptr<Sprite> sprite_ptr)
|
||||
{
|
||||
return sprite_ptr.get() == sprite.Get();
|
||||
});
|
||||
if(it == m_sprites.end())
|
||||
return;
|
||||
std::rotate(it, it + 1, m_sprites.end());
|
||||
}
|
||||
|
||||
void Scene::TryEraseSpriteFromTexture(NonOwningPtr<Texture> texture)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
@@ -44,9 +55,4 @@ namespace mlx
|
||||
m_sprites.erase(it);
|
||||
} while(it != m_sprites.end());
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
m_depth.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user