This commit is contained in:
Lynix
2021-06-06 18:10:04 +02:00
committed by Jérôme Leclercq
parent 26f5d01c86
commit 54d56abc56
13 changed files with 90 additions and 28 deletions

View File

@@ -0,0 +1,11 @@
// 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/InstancedRenderable.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
InstancedRenderable::~InstancedRenderable() = default;
}

View File

@@ -5,6 +5,8 @@
#include <Nazara/Graphics/Model.hpp>
#include <Nazara/Graphics/GraphicalMesh.hpp>
#include <Nazara/Graphics/Material.hpp>
#include <Nazara/Graphics/ModelInstance.hpp>
#include <Nazara/Renderer/CommandBufferBuilder.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
@@ -26,6 +28,25 @@ namespace Nz
}
}
void Model::Draw(CommandBufferBuilder& commandBuffer, ModelInstance& instance) const
{
commandBuffer.BindShaderBinding(instance.GetShaderBinding());
for (std::size_t i = 0; i < m_subMeshes.size(); ++i)
{
const auto& submeshData = m_subMeshes[i];
const auto& indexBuffer = m_graphicalMesh->GetIndexBuffer(i);
const auto& vertexBuffer = m_graphicalMesh->GetVertexBuffer(i);
const auto& renderPipeline = submeshData.material->GetPipeline()->GetRenderPipeline(submeshData.vertexBufferData);
commandBuffer.BindIndexBuffer(indexBuffer.get());
commandBuffer.BindVertexBuffer(0, vertexBuffer.get());
commandBuffer.BindPipeline(*renderPipeline);
commandBuffer.DrawIndexed(static_cast<Nz::UInt32>(m_graphicalMesh->GetIndexCount(i)));
}
}
const std::shared_ptr<AbstractBuffer>& Model::GetIndexBuffer(std::size_t subMeshIndex) const
{
return m_graphicalMesh->GetIndexBuffer(subMeshIndex);
@@ -47,5 +68,4 @@ namespace Nz
{
return m_graphicalMesh->GetVertexBuffer(subMeshIndex);
}
}