fixing compilation issues, working on textures

This commit is contained in:
Kbz-8
2024-09-04 02:35:01 +02:00
parent 1b996af83f
commit 0a84ea6a18
15 changed files with 315 additions and 115 deletions

View File

@@ -19,7 +19,7 @@
Error("invalid image ptr (NULL)"); \
retval; \
} \
else if(!m_image_registry.IsTextureKnown(img)) \
else if(!m_image_registry.IsTextureKnown(static_cast<Texture*>(img))) \
{ \
Error("invalid image ptr"); \
retval; \

View File

@@ -29,7 +29,7 @@ namespace mlx
inline void LoadFont(const std::filesystem::path& filepath, float scale);
inline void TryEraseTextureFromRegistry(NonOwningPtr<Texture> texture) noexcept;
inline void TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept;
[[nodiscard]] MLX_FORCEINLINE bool HasWindow() const noexcept { return m_has_window; }
[[nodiscard]] MLX_FORCEINLINE Renderer& GetRenderer() { return m_renderer; }
@@ -42,6 +42,8 @@ namespace mlx
std::shared_ptr<Window> p_window;
std::unique_ptr<Scene> p_scene;
std::uint64_t m_current_depth = 0;
std::size_t m_width = 0;
std::size_t m_height = 0;

View File

@@ -7,6 +7,7 @@ namespace mlx
{
MLX_PROFILE_FUNCTION();
p_scene->ResetSprites();
m_current_depth = 0;
}
void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept
@@ -22,6 +23,15 @@ namespace mlx
void GraphicsSupport::TexturePut(NonOwningPtr<Texture> texture, int x, int y)
{
MLX_PROFILE_FUNCTION();
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) });
if(!sprite)
{
Sprite& new_sprite = p_scene->CreateSprite(texture);
new_sprite.SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
}
else
sprite->SetPosition(Vec3f{ static_cast<float>(x), static_cast<float>(y), static_cast<float>(m_current_depth) });
m_current_depth++;
}
void GraphicsSupport::LoadFont(const std::filesystem::path& filepath, float scale)
@@ -29,8 +39,9 @@ namespace mlx
MLX_PROFILE_FUNCTION();
}
void GraphicsSupport::TryEraseTextureFromRegistry(NonOwningPtr<Texture> texture) noexcept
void GraphicsSupport::TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept
{
MLX_PROFILE_FUNCTION();
p_scene->TryEraseSpriteFromTexture(texture);
}
}