WIP
This commit is contained in:
parent
26f5d01c86
commit
54d56abc56
|
|
@ -646,31 +646,11 @@ int main()
|
||||||
builder.SetScissor(Nz::Recti{ 0, 0, int(offscreenWidth), int(offscreenHeight) });
|
builder.SetScissor(Nz::Recti{ 0, 0, int(offscreenWidth), int(offscreenHeight) });
|
||||||
builder.SetViewport(Nz::Recti{ 0, 0, int(offscreenWidth), int(offscreenHeight) });
|
builder.SetViewport(Nz::Recti{ 0, 0, int(offscreenWidth), int(offscreenHeight) });
|
||||||
|
|
||||||
for (Nz::ModelInstance& modelInstance : { std::ref(modelInstance1), std::ref(modelInstance2) })
|
spaceshipModel.Draw(builder, modelInstance1);
|
||||||
{
|
spaceshipModel.Draw(builder, modelInstance2);
|
||||||
builder.BindShaderBinding(modelInstance.GetShaderBinding());
|
|
||||||
|
|
||||||
for (std::size_t i = 0; i < spaceshipModel.GetSubMeshCount(); ++i)
|
|
||||||
{
|
|
||||||
builder.BindIndexBuffer(spaceshipModel.GetIndexBuffer(i).get());
|
|
||||||
builder.BindVertexBuffer(0, spaceshipModel.GetVertexBuffer(i).get());
|
|
||||||
builder.BindPipeline(*spaceshipModel.GetRenderPipeline(i));
|
|
||||||
|
|
||||||
builder.DrawIndexed(static_cast<Nz::UInt32>(spaceshipModel.GetIndexCount(i)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plane
|
// Plane
|
||||||
builder.BindShaderBinding(planeInstance.GetShaderBinding());
|
planeModel.Draw(builder, planeInstance);
|
||||||
|
|
||||||
for (std::size_t i = 0; i < planeModel.GetSubMeshCount(); ++i)
|
|
||||||
{
|
|
||||||
builder.BindIndexBuffer(planeModel.GetIndexBuffer(i).get());
|
|
||||||
builder.BindVertexBuffer(0, planeModel.GetVertexBuffer(i).get());
|
|
||||||
builder.BindPipeline(*planeModel.GetRenderPipeline(i));
|
|
||||||
|
|
||||||
builder.DrawIndexed(static_cast<Nz::UInt32>(planeModel.GetIndexCount(i)));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Nz::FramePass& lightingPass = graph.AddPass("Lighting pass");
|
Nz::FramePass& lightingPass = graph.AddPass("Lighting pass");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
// 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_INSTANCEDRENDERABLE_HPP
|
||||||
|
#define NAZARA_INSTANCEDRENDERABLE_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequisites.hpp>
|
||||||
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
|
|
||||||
|
namespace Nz
|
||||||
|
{
|
||||||
|
class CommandBufferBuilder;
|
||||||
|
class ModelInstance;
|
||||||
|
|
||||||
|
class NAZARA_GRAPHICS_API InstancedRenderable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InstancedRenderable() = default;
|
||||||
|
InstancedRenderable(const InstancedRenderable&) = delete;
|
||||||
|
InstancedRenderable(InstancedRenderable&&) noexcept = default;
|
||||||
|
~InstancedRenderable();
|
||||||
|
|
||||||
|
virtual void Draw(CommandBufferBuilder& commandBuffer, ModelInstance& instance) const = 0;
|
||||||
|
|
||||||
|
InstancedRenderable& operator=(const InstancedRenderable&) = delete;
|
||||||
|
InstancedRenderable& operator=(InstancedRenderable&&) noexcept = default;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/InstancedRenderable.inl>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Nazara/Graphics/DebugOff.hpp>
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Graphics/Config.hpp>
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
|
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||||
#include <Nazara/Renderer/RenderPipeline.hpp>
|
#include <Nazara/Renderer/RenderPipeline.hpp>
|
||||||
#include <Nazara/Utility/Mesh.hpp>
|
#include <Nazara/Utility/Mesh.hpp>
|
||||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||||
|
|
@ -19,7 +20,7 @@ namespace Nz
|
||||||
class GraphicalMesh;
|
class GraphicalMesh;
|
||||||
class Material;
|
class Material;
|
||||||
|
|
||||||
class NAZARA_GRAPHICS_API Model
|
class NAZARA_GRAPHICS_API Model : public InstancedRenderable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Model(std::shared_ptr<GraphicalMesh> graphicalMesh);
|
Model(std::shared_ptr<GraphicalMesh> graphicalMesh);
|
||||||
|
|
@ -27,6 +28,8 @@ namespace Nz
|
||||||
Model(Model&&) noexcept = default;
|
Model(Model&&) noexcept = default;
|
||||||
~Model() = default;
|
~Model() = default;
|
||||||
|
|
||||||
|
void Draw(CommandBufferBuilder& commandBuffer, ModelInstance& instance) const override;
|
||||||
|
|
||||||
const std::shared_ptr<AbstractBuffer>& GetIndexBuffer(std::size_t subMeshIndex) const;
|
const std::shared_ptr<AbstractBuffer>& GetIndexBuffer(std::size_t subMeshIndex) const;
|
||||||
std::size_t GetIndexCount(std::size_t subMeshIndex) const;
|
std::size_t GetIndexCount(std::size_t subMeshIndex) const;
|
||||||
const std::shared_ptr<RenderPipeline>& GetRenderPipeline(std::size_t subMeshIndex) const;
|
const std::shared_ptr<RenderPipeline>& GetRenderPipeline(std::size_t subMeshIndex) const;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
#include <Nazara/Graphics/Model.hpp>
|
#include <Nazara/Graphics/Model.hpp>
|
||||||
#include <Nazara/Graphics/GraphicalMesh.hpp>
|
#include <Nazara/Graphics/GraphicalMesh.hpp>
|
||||||
#include <Nazara/Graphics/Material.hpp>
|
#include <Nazara/Graphics/Material.hpp>
|
||||||
|
#include <Nazara/Graphics/ModelInstance.hpp>
|
||||||
|
#include <Nazara/Renderer/CommandBufferBuilder.hpp>
|
||||||
#include <Nazara/Graphics/Debug.hpp>
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
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
|
const std::shared_ptr<AbstractBuffer>& Model::GetIndexBuffer(std::size_t subMeshIndex) const
|
||||||
{
|
{
|
||||||
return m_graphicalMesh->GetIndexBuffer(subMeshIndex);
|
return m_graphicalMesh->GetIndexBuffer(subMeshIndex);
|
||||||
|
|
@ -47,5 +68,4 @@ namespace Nz
|
||||||
{
|
{
|
||||||
return m_graphicalMesh->GetVertexBuffer(subMeshIndex);
|
return m_graphicalMesh->GetVertexBuffer(subMeshIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ local modules = {
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
Graphics = {
|
Graphics = {
|
||||||
Deps = {"NazaraRenderer"}
|
Deps = {"NazaraRenderer"},
|
||||||
|
Packages = {"entt"}
|
||||||
},
|
},
|
||||||
Network = {
|
Network = {
|
||||||
Deps = {"NazaraCore"},
|
Deps = {"NazaraCore"},
|
||||||
|
|
@ -77,7 +78,7 @@ local modules = {
|
||||||
},
|
},
|
||||||
Utility = {
|
Utility = {
|
||||||
Deps = {"NazaraCore"},
|
Deps = {"NazaraCore"},
|
||||||
Packages = {"freetype", "stb"}
|
Packages = {"entt", "freetype", "stb"}
|
||||||
},
|
},
|
||||||
VulkanRenderer = {
|
VulkanRenderer = {
|
||||||
Deps = {"NazaraRenderer"},
|
Deps = {"NazaraRenderer"},
|
||||||
|
|
@ -98,7 +99,7 @@ local modules = {
|
||||||
|
|
||||||
add_repositories("local-repo xmake-repo")
|
add_repositories("local-repo xmake-repo")
|
||||||
|
|
||||||
add_requires("chipmunk2d", "dr_wav", "freetype", "libflac", "libsdl", "minimp3", "stb")
|
add_requires("chipmunk2d", "dr_wav", "entt", "freetype", "libflac", "libsdl", "minimp3", "stb")
|
||||||
add_requires("libvorbis", { configs = { with_vorbisenc = false } })
|
add_requires("libvorbis", { configs = { with_vorbisenc = false } })
|
||||||
add_requires("openal-soft", { configs = { shared = true }})
|
add_requires("openal-soft", { configs = { shared = true }})
|
||||||
add_requires("newtondynamics", { debug = is_plat("windows") and is_mode("debug") }) -- Newton doesn't like compiling in Debug on Linux
|
add_requires("newtondynamics", { debug = is_plat("windows") and is_mode("debug") }) -- Newton doesn't like compiling in Debug on Linux
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue