| 715 | } |
| 716 | |
| 717 | void Renderer::drawCustomCommand(RenderCommand* command) |
| 718 | { |
| 719 | auto cmd = static_cast<CustomCommand*>(command); |
| 720 | |
| 721 | if (cmd->getBeforeCallback()) |
| 722 | cmd->getBeforeCallback()(); |
| 723 | |
| 724 | beginRenderPass(); |
| 725 | _commandBuffer->setVertexBuffer(cmd->getVertexBuffer()); |
| 726 | |
| 727 | _commandBuffer->updatePipelineState(_currentRT, cmd->getPipelineDescriptor()); |
| 728 | _commandBuffer->setProgramState(cmd->getPipelineDescriptor().programState); |
| 729 | |
| 730 | auto drawType = cmd->getDrawType(); |
| 731 | if (CustomCommand::DrawType::ELEMENT == drawType) |
| 732 | { |
| 733 | _commandBuffer->setIndexBuffer(cmd->getIndexBuffer()); |
| 734 | _commandBuffer->drawElements(cmd->getPrimitiveType(), cmd->getIndexFormat(), cmd->getIndexDrawCount(), |
| 735 | cmd->getIndexDrawOffset(), cmd->isWireframe()); |
| 736 | _drawnVertices += cmd->getIndexDrawCount(); |
| 737 | } |
| 738 | else if (CustomCommand::DrawType::ELEMENT_INSTANCE == drawType) |
| 739 | { |
| 740 | _commandBuffer->setIndexBuffer(cmd->getIndexBuffer()); |
| 741 | _commandBuffer->setInstanceBuffer(cmd->getInstanceBuffer()); |
| 742 | _commandBuffer->drawElementsInstanced(cmd->getPrimitiveType(), cmd->getIndexFormat(), cmd->getIndexDrawCount(), |
| 743 | cmd->getIndexDrawOffset(), cmd->getInstanceCount(), cmd->isWireframe()); |
| 744 | _drawnVertices += cmd->getIndexDrawCount() * cmd->getInstanceCount(); |
| 745 | } |
| 746 | else |
| 747 | { |
| 748 | _commandBuffer->drawArrays(cmd->getPrimitiveType(), cmd->getVertexDrawStart(), cmd->getVertexDrawCount(), |
| 749 | cmd->isWireframe()); |
| 750 | _drawnVertices += cmd->getVertexDrawCount(); |
| 751 | } |
| 752 | _drawnBatches++; |
| 753 | endRenderPass(); |
| 754 | |
| 755 | if (cmd->getAfterCallback()) |
| 756 | cmd->getAfterCallback()(); |
| 757 | } |
| 758 | |
| 759 | void Renderer::drawMeshCommand(RenderCommand* command) |
| 760 | { |
nothing calls this directly
no test coverage detected