Files
OpenVulkano/openVulkanoCpp/Scene/SimpleDrawable.hpp
Vladyslav Baranovskyi a5f592dc5c Fixed linker error specifically on windows
The error here is that when forward referencing a struct/class what matters is whether the entity actually is a struct or a class. For example, this is what the definitions look like if the entity is:
a class:  ?Init@SimpleDrawable@Scene@OpenVulkano@@QEAAXPEAVShader@23@PEAVGeometry@23@PEAVMaterial@23@@Z
a struct: ?Init@SimpleDrawable@Scene@OpenVulkano@@QEAAXPEAVShader@23@PEAVGeometry@23@PEAUMaterial@23@@Z
2024-05-26 23:15:34 +03:00

48 lines
1.1 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 "Drawable.hpp"
namespace OpenVulkano::Scene
{
class Geometry;
struct Material;
class SimpleDrawable final : public Drawable
{
Geometry* m_mesh = nullptr;
Material* m_material = nullptr;
public:
SimpleDrawable() : Drawable(DrawEncoder::GetDrawEncoder<SimpleDrawable>())
{}
explicit SimpleDrawable(const SimpleDrawable* toCopy)
: Drawable(DrawEncoder::GetDrawEncoder<SimpleDrawable>())
, m_mesh(toCopy->m_mesh)
, m_material(toCopy->m_material)
{
SetShader(toCopy->GetShader());
}
~SimpleDrawable()
{
if (m_mesh) SimpleDrawable::Close();
}
void Init(Shader* shader, Geometry* mesh, Material* material);
void Init(SimpleDrawable* drawable);
[[nodiscard]] Drawable* Copy() override { return new SimpleDrawable(this); }
[[nodiscard]] Geometry* GetMesh() const { return m_mesh; }
[[nodiscard]] Material* GetMaterial() const { return m_material; }
};
}