MCPcopy Create free account
hub / github.com/axmolengine/axmol / drawCustomCommand

Method drawCustomCommand

core/renderer/Renderer.cpp:717–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

715}
716
717void 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
759void Renderer::drawMeshCommand(RenderCommand* command)
760{

Callers

nothing calls this directly

Calls 12

updatePipelineStateMethod · 0.80
drawElementsMethod · 0.80
getIndexFormatMethod · 0.80
setInstanceBufferMethod · 0.80
drawArraysMethod · 0.80
setVertexBufferMethod · 0.45
getVertexBufferMethod · 0.45
setProgramStateMethod · 0.45
setIndexBufferMethod · 0.45
getIndexBufferMethod · 0.45
getPrimitiveTypeMethod · 0.45
drawElementsInstancedMethod · 0.45

Tested by

no test coverage detected