void SubMesh::bindDrawIndexedRecursive(const std::string& nodeName, const ICommandBuffersSP& cmdBuffer, const SmartPointerVector<IGraphicsPipelineSP>& allGraphicsPipelines, const overwrite* renderOverwrite, const uint32_t bufferIndex) const { const overwrite* currentOverwrite = renderOverwrite; while (currentOverwrite) { if (!currentOverwrite->submeshBindDrawIndexedRecursive(*this, cmdBuffer, allGraphicsPipelines, bufferIndex)) { return; } currentOverwrite = currentOverwrite->getNextOverwrite(); } if (bsdfMaterial.get()) { // TODO: Add again. } else if (phongMaterial.get()) { IGraphicsPipelineSP graphicsPipeline; for (size_t i = 0; i < allGraphicsPipelines.size(); i++) { if (allGraphicsPipelines[i]->getVertexBufferType() == vertexBufferType) { graphicsPipeline = allGraphicsPipelines[i]; break; } } if (!graphicsPipeline.get()) { logPrint(VKTS_LOG_SEVERE, "SubMesh: Vertex buffer type not found %x", vertexBufferType); return; } vkCmdBindPipeline(cmdBuffer->getCommandBuffer(), VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline->getPipeline()); phongMaterial->bindDrawIndexedRecursive(nodeName,cmdBuffer, graphicsPipeline, renderOverwrite, bufferIndex); } else { return; } bindIndexBuffer(cmdBuffer, bufferIndex); bindVertexBuffers(cmdBuffer, bufferIndex); drawIndexed(cmdBuffer, bufferIndex); }
void Shader::drawMesh(const Mesh& mesh) { bindIndexBuffer(mesh.index_buffer_object); bindAndEnableAttributes(mesh.attribute_buffer_objects); glDrawElements(GL_TRIANGLES, mesh.index_buffer_object.size, GL_UNSIGNED_SHORT, 0); disableAttributes(mesh.attribute_buffer_objects); }