mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
fixing compilation issues, working on textures
This commit is contained in:
@@ -12,10 +12,31 @@ namespace mlx
|
||||
m_depth.Init(m_descriptor.renderer->GetSwapchainImages().back().GetWidth(), m_descriptor.renderer->GetSwapchainImages().back().GetHeight());
|
||||
}
|
||||
|
||||
Sprite& Scene::CreateSprite(std::shared_ptr<Texture> texture) noexcept
|
||||
Sprite& Scene::CreateSprite(NonOwningPtr<Texture> texture) noexcept
|
||||
{
|
||||
std::shared_ptr<Sprite> sprite = std::make_shared<Sprite>(texture);
|
||||
m_sprites.push_back(sprite);
|
||||
return *sprite;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return sprite.GetPosition().x == position.x && sprite.GetPosition().y == position.y && sprite.GetTexture() == texture;
|
||||
});
|
||||
return (it != m_sprites.end() ? &(*it) : nullptr);
|
||||
}
|
||||
|
||||
void Scene::TryEraseSpriteFromTexture(NonOwningPtr<Texture> texture)
|
||||
{
|
||||
do
|
||||
{
|
||||
auto it = std::find_if(m_sprites.begin(), m_sprites.end(), [texture, position](const Sprite& sprite)
|
||||
{
|
||||
return sprite.GetPosition().x == position.x && sprite.GetPosition().y == position.y && sprite.GetTexture() == texture;
|
||||
});
|
||||
m_sprites.erase(it);
|
||||
} while(it != m_sprites.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace mlx
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Sprite::Sprite(std::shared_ptr<Texture> texture)
|
||||
Sprite::Sprite(NonOwningPtr<Texture> texture)
|
||||
{
|
||||
Verify((bool)texture, "Sprite: invalid texture");
|
||||
p_mesh = CreateQuad(0, 0, texture->GetWidth(), texture->GetHeight());
|
||||
|
||||
Reference in New Issue
Block a user