Change shader handling

This commit is contained in:
2023-08-04 20:20:20 +02:00
parent 4dac821abb
commit 836e9dce42
13 changed files with 71 additions and 23 deletions

View File

@@ -8,25 +8,38 @@
#include "Base/ICloseable.hpp"
#include "DrawEncoder.hpp"
#include <memory>
#include <vector>
namespace openVulkanoCpp::Scene
{
class Node;
class Scene;
class Shader;
class Drawable
enum class DrawPhase
{
BACKGROUND = 0, MAIN, TRANSPARENT, POST
};
class Drawable : public ICloseable
{
std::vector<Node*> m_nodes;
Scene* m_scene = nullptr;
Shader* m_shader = nullptr;
const DrawEncoder m_encoder;
const DrawPhase m_drawPhase;
public:
explicit Drawable(const DrawEncoder& encoder) : m_encoder(encoder) {}
explicit Drawable(const DrawEncoder& encoder,
const DrawPhase phase = DrawPhase::MAIN)
: m_encoder(encoder), m_drawPhase(phase) {}
~Drawable() { if (m_scene) Drawable::Close(); }
~Drawable() override { if (m_scene) Drawable::Close(); }
void Close();
void Close() override;
void SetShader(Shader* shader) { m_shader = shader; }
[[nodiscard]] virtual Drawable* Copy() = 0;
@@ -36,6 +49,10 @@ namespace openVulkanoCpp::Scene
[[nodiscard]] const DrawEncoder& GetEncoder() const { return m_encoder; }
[[nodiscard]] DrawPhase GetDrawPhase() const { return m_drawPhase; }
[[nodiscard]] Shader* GetShader() const { return m_shader; }
private:
friend class Node;
friend class Scene;