Files
OpenVulkano/openVulkanoCpp/Scene/Drawable.hpp
2024-07-03 15:43:15 +02:00

71 lines
1.5 KiB
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "Base/ICloseable.hpp"
#include "DrawEncoder.hpp"
#include <memory>
#include <vector>
#ifdef _WIN32
# undef TRANSPARENT
#endif
namespace OpenVulkano::Scene
{
class Node;
class Scene;
class Shader;
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,
const DrawPhase phase = DrawPhase::MAIN)
: m_encoder(encoder), m_drawPhase(phase) {}
~Drawable() override {/* if (m_scene) Drawable::Close();*/ }
void Close() override;
void SetShader(Shader* shader) { m_shader = shader; }
[[nodiscard]] virtual Drawable* Copy() = 0;
[[nodiscard]] Scene* GetScene() const { return m_scene; }
[[nodiscard]] const auto& GetNodes() const { return m_nodes; }
[[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;
void SetScene(Scene* scene);
void AddNode(Node* node);
void RemoveNode(Node* node);
};
}