mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
fixing compilation issues
This commit is contained in:
32
runtime/Sources/Graphics/PixelPutManager.cpp
git.filemode.normal_file
32
runtime/Sources/Graphics/PixelPutManager.cpp
git.filemode.normal_file
@@ -0,0 +1,32 @@
|
||||
#include <PreCompiled.h>
|
||||
|
||||
#include <Graphics/PutPixelManager.h>
|
||||
#include <Renderer/Renderer.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
NonOwningPtr<Texture> PutPixelManager::DrawPixel(int x, int y, std::uint64_t z, std::uint32_t color)
|
||||
{
|
||||
Verify((bool)p_renderer, "invalid renderer pointer");
|
||||
auto it = m_textures.find(z);
|
||||
if(it == m_textures.end())
|
||||
{
|
||||
VkExtent2D swapchain_extent = kvfGetSwapchainImagesSize(p_renderer->GetSwapchain());
|
||||
Texture& texture = m_textures[z] = Texture({}, swapchain_extent.width, swapchain_extent.height);
|
||||
texture.SetPixel(x, y, color);
|
||||
return &texture;
|
||||
}
|
||||
it->second.SetPixel(x, y, color);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PutPixelManager::ResetRenderData()
|
||||
{
|
||||
m_textures.clear();
|
||||
}
|
||||
|
||||
PutPixelManager::~PutPixelManager()
|
||||
{
|
||||
ResetRenderData();
|
||||
}
|
||||
}
|
||||
@@ -21,20 +21,21 @@ namespace mlx
|
||||
|
||||
NonOwningPtr<Sprite> Scene::GetSpriteFromTextureAndPosition(NonOwningPtr<Texture> texture, const Vec2f& position) const
|
||||
{
|
||||
auto it = std::find_if(m_sprites.begin(), m_sprites.end(), [texture, position](const Sprite& sprite)
|
||||
auto it = std::find_if(m_sprites.begin(), m_sprites.end(), [texture, position](std::shared_ptr<Sprite> sprite)
|
||||
{
|
||||
return sprite.GetPosition().x == position.x && sprite.GetPosition().y == position.y && sprite.GetTexture() == texture;
|
||||
return sprite->GetPosition().x == position.x && sprite->GetPosition().y == position.y && sprite->GetTexture() == texture;
|
||||
});
|
||||
return (it != m_sprites.end() ? &(*it) : nullptr);
|
||||
return (it != m_sprites.end() ? it->get() : nullptr);
|
||||
}
|
||||
|
||||
void Scene::TryEraseSpriteFromTexture(NonOwningPtr<Texture> texture)
|
||||
{
|
||||
auto it = m_sprites.begin();
|
||||
do
|
||||
{
|
||||
auto it = std::find_if(m_sprites.begin(), m_sprites.end(), [texture, position](const Sprite& sprite)
|
||||
it = std::find_if(m_sprites.begin(), m_sprites.end(), [texture](std::shared_ptr<Sprite> sprite)
|
||||
{
|
||||
return sprite.GetPosition().x == position.x && sprite.GetPosition().y == position.y && sprite.GetTexture() == texture;
|
||||
return sprite->GetTexture() == texture;
|
||||
});
|
||||
m_sprites.erase(it);
|
||||
} while(it != m_sprites.end());
|
||||
|
||||
Reference in New Issue
Block a user