Graphics: Add ModelInstance class

This commit is contained in:
Jérôme Leclercq
2021-01-22 23:32:32 +01:00
parent 19783f7755
commit e3e5c4ba8f
4 changed files with 154 additions and 56 deletions

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_MODELINSTANCE_HPP
#define NAZARA_MODELINSTANCE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Graphics/Config.hpp>
#include <Nazara/Renderer/ShaderBinding.hpp>
#include <memory>
namespace Nz
{
class AbstractBuffer;
class MaterialSettings;
class NAZARA_GRAPHICS_API ModelInstance
{
public:
ModelInstance(const std::shared_ptr<const MaterialSettings>& settings);
ModelInstance(const ModelInstance&) = delete;
ModelInstance(ModelInstance&&) noexcept = default;
~ModelInstance() = default;
inline std::shared_ptr<AbstractBuffer>& GetInstanceBuffer();
inline const std::shared_ptr<AbstractBuffer>& GetInstanceBuffer() const;
inline ShaderBinding& GetShaderBinding();
ModelInstance& operator=(const ModelInstance&) = delete;
ModelInstance& operator=(ModelInstance&&) noexcept = default;
private:
std::shared_ptr<AbstractBuffer> m_instanceDataBuffer;
ShaderBindingPtr m_shaderBinding;
};
}
#include <Nazara/Graphics/ModelInstance.inl>
#endif // NAZARA_MODELINSTANCE_HPP

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ModelInstance.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline std::shared_ptr<AbstractBuffer>& ModelInstance::GetInstanceBuffer()
{
return m_instanceDataBuffer;
}
inline const std::shared_ptr<AbstractBuffer>& ModelInstance::GetInstanceBuffer() const
{
return m_instanceDataBuffer;
}
inline ShaderBinding& ModelInstance::GetShaderBinding()
{
return *m_shaderBinding;
}
}
#include <Nazara/Graphics/DebugOff.hpp>