mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
fixing put pixel, adding scene change checker
This commit is contained in:
@@ -19,8 +19,12 @@ namespace mlx
|
||||
#endif
|
||||
texture.Clear(VK_NULL_HANDLE, Vec4f{ 0.0f });
|
||||
}
|
||||
m_textures.back().SetPixel(x, y, color);
|
||||
return (insert_new_texture ? &m_textures.back() : nullptr);
|
||||
if(!m_textures.empty())
|
||||
{
|
||||
m_textures.back().SetPixel(x, y, color);
|
||||
return (insert_new_texture ? &m_textures.back() : nullptr);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PutPixelManager::ResetRenderData()
|
||||
|
||||
@@ -5,17 +5,10 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
Scene::Scene(SceneDescriptor desc)
|
||||
: m_descriptor(std::move(desc))
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Verify((bool)m_descriptor.renderer, "invalid renderer");
|
||||
}
|
||||
|
||||
Sprite& Scene::CreateSprite(NonOwningPtr<Texture> texture) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
std::shared_ptr<Sprite> sprite = std::make_shared<Sprite>(*m_descriptor.renderer, texture);
|
||||
std::shared_ptr<Sprite> sprite = std::make_shared<Sprite>(texture);
|
||||
m_sprites.push_back(sprite);
|
||||
return *sprite;
|
||||
}
|
||||
@@ -52,7 +45,15 @@ namespace mlx
|
||||
{
|
||||
return sprite->GetTexture() == texture;
|
||||
});
|
||||
m_sprites.erase(it);
|
||||
if(it != m_sprites.end())
|
||||
m_sprites.erase(it);
|
||||
} while(it != m_sprites.end());
|
||||
}
|
||||
|
||||
bool Scene::IsTextureAtGivenDrawLayer(NonOwningPtr<Texture> texture, std::uint64_t draw_layer) const
|
||||
{
|
||||
if(draw_layer >= m_sprites.size())
|
||||
return false;
|
||||
return m_sprites[draw_layer]->GetTexture() == texture;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,18 +37,11 @@ namespace mlx
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Sprite::Sprite(Renderer& renderer, NonOwningPtr<Texture> texture)
|
||||
Sprite::Sprite(NonOwningPtr<Texture> texture)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
Verify((bool)texture, "Sprite: invalid texture (internal mlx issue, please report to devs)");
|
||||
p_mesh = CreateQuad(0, 0, texture->GetWidth(), texture->GetHeight());
|
||||
p_texture = texture;
|
||||
|
||||
func::function<void(const EventBase&)> functor = [this, &renderer](const EventBase& event)
|
||||
{
|
||||
if(event.What() == Event::DescriptorPoolResetEventCode)
|
||||
m_set.Reallocate(renderer.GetCurrentFrameIndex());
|
||||
};
|
||||
EventBus::RegisterListener({ functor, "__MlxSprite" + std::to_string(reinterpret_cast<std::uintptr_t>(this)) });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user