Files
Seele/src/Engine/Graphics/RenderPass/MeshProcessor.cpp
T

61 lines
1.9 KiB
C++
Raw Normal View History

2020-06-02 11:46:18 +02:00
#include "MeshProcessor.h"
#include "Graphics/Graphics.h"
#include "VertexFactory.h"
using namespace Seele;
MeshProcessor::MeshProcessor(const PScene scene, Gfx::PGraphics graphics)
: scene(scene)
, graphics(graphics)
{
}
MeshProcessor::~MeshProcessor()
{
}
2020-06-08 01:44:47 +02:00
void MeshProcessor::buildMeshDrawCommand(
2020-06-02 11:46:18 +02:00
const MeshBatch& meshBatch,
2020-06-08 01:44:47 +02:00
const PPrimitiveComponent primitiveComponent,
const Gfx::PRenderPass renderPass,
Gfx::PRenderCommand drawCommand,
2020-06-02 11:46:18 +02:00
PMaterial material,
Gfx::PVertexShader vertexShader,
Gfx::PControlShader controlShader,
Gfx::PEvaluationShader evaluationShader,
Gfx::PGeometryShader geometryShader,
Gfx::PFragmentShader fragmentShader,
bool positionOnly)
{
const PVertexFactory vertexFactory = meshBatch.vertexFactory;
GraphicsPipelineCreateInfo pipelineInitializer;
pipelineInitializer.topology = meshBatch.topology;
Gfx::PVertexDeclaration vertexDecl = positionOnly ? vertexFactory->getPositionDeclaration() : vertexFactory->getDeclaration();
pipelineInitializer.vertexDeclaration = vertexDecl;
pipelineInitializer.vertexShader = vertexShader;
pipelineInitializer.controlShader = controlShader;
pipelineInitializer.evalShader = evaluationShader;
pipelineInitializer.geometryShader = geometryShader;
pipelineInitializer.fragmentShader = fragmentShader;
2020-06-08 01:44:47 +02:00
pipelineInitializer.renderPass = renderPass;
2020-06-02 11:46:18 +02:00
VertexInputStreamArray vertexStreams;
if(positionOnly)
{
vertexFactory->getPositionOnlyStream(vertexStreams);
}
else
{
vertexFactory->getStreams(vertexStreams);
}
2020-06-08 01:44:47 +02:00
drawCommand->bindVertexBuffer(vertexStreams);
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(pipelineInitializer);
drawCommand->bindPipeline(pipeline);
for(auto element : meshBatch.elements)
2020-06-02 11:46:18 +02:00
{
2020-06-08 01:44:47 +02:00
drawCommand->bindIndexBuffer(element.indexBuffer);
drawCommand->draw(element);
}
2020-06-02 11:46:18 +02:00
}