This commit is contained in:
Kbz-8
2024-10-19 00:43:39 +02:00
parent 0ea0cde668
commit 632117a3a3
19 changed files with 109 additions and 174 deletions

View File

@@ -11,13 +11,13 @@ namespace mlx
PutPixelManager(NonOwningPtr<class Renderer> renderer) : p_renderer(renderer) {}
// Return a valid pointer when a new texture has been created
NonOwningPtr<Texture> DrawPixel(int x, int y, std::uint64_t z, std::uint32_t color);
NonOwningPtr<Texture> DrawPixel(int x, int y, bool insert_new_texture, std::uint32_t color);
void ResetRenderData();
~PutPixelManager();
private:
std::map<std::uint64_t, Texture> m_textures;
std::list<Texture> m_textures;
NonOwningPtr<class Renderer> p_renderer;
};
}

View File

@@ -20,21 +20,20 @@ namespace mlx
Sprite& CreateSprite(NonOwningPtr<class Texture> texture) noexcept;
NonOwningPtr<Sprite> GetSpriteFromTextureAndPosition(NonOwningPtr<Texture> texture, const Vec2f& position) const;
void BringToFront(NonOwningPtr<Sprite> sprite);
void TryEraseSpriteFromTexture(NonOwningPtr<Texture> texture);
inline void ResetSprites() { m_sprites.clear(); }
[[nodiscard]] MLX_FORCEINLINE const std::vector<std::shared_ptr<Sprite>>& GetSprites() const noexcept { return m_sprites; }
[[nodiscard]] MLX_FORCEINLINE const SceneDescriptor& GetDescription() const noexcept { return m_descriptor; }
[[nodiscard]] MLX_FORCEINLINE DepthImage& GetDepth() noexcept { return m_depth; }
[[nodiscard]] MLX_FORCEINLINE ViewerData& GetViewerData() noexcept { return m_viewer_data; }
~Scene();
~Scene() = default;
private:
SceneDescriptor m_descriptor;
std::vector<std::shared_ptr<Sprite>> m_sprites;
DepthImage m_depth;
ViewerData m_viewer_data;
};
}

View File

@@ -17,10 +17,10 @@ namespace mlx
Sprite(class Renderer& renderer, NonOwningPtr<Texture> texture);
inline void SetColor(Vec4f color) noexcept { m_color = color; }
inline void SetPosition(Vec3f position) noexcept { m_position = position; }
inline void SetPosition(Vec2f position) noexcept { m_position = position; }
[[nodiscard]] MLX_FORCEINLINE const Vec4f& GetColor() const noexcept { return m_color; }
[[nodiscard]] MLX_FORCEINLINE const Vec3f& GetPosition() const noexcept { return m_position; }
[[nodiscard]] MLX_FORCEINLINE const Vec2f& GetPosition() const noexcept { return m_position; }
[[nodiscard]] MLX_FORCEINLINE std::shared_ptr<Mesh> GetMesh() const { return p_mesh; }
[[nodiscard]] MLX_FORCEINLINE NonOwningPtr<Texture> GetTexture() const { return p_texture; }
@@ -46,7 +46,7 @@ namespace mlx
NonOwningPtr<Texture> p_texture;
std::shared_ptr<Mesh> p_mesh;
Vec4f m_color = Vec4f{ 1.0f, 1.0f, 1.0f, 1.0f };
Vec3f m_position = Vec3f{ 0.0f, 0.0f, 0.0f };
Vec2f m_position = Vec2f{ 0.0f, 0.0f };
};
}