Render Debug Infos
| 531 | |
| 532 | // Render Debug Infos |
| 533 | void SceneDemo::renderDebugInfos(openglframework::Shader& shader, const openglframework::Matrix4& worldToCameraMatrix) { |
| 534 | |
| 535 | rp3d::DebugRenderer& debugRenderer = mPhysicsWorld->getDebugRenderer(); |
| 536 | |
| 537 | // Render in wireframe mode |
| 538 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
| 539 | |
| 540 | // Bind the shader |
| 541 | shader.bind(); |
| 542 | |
| 543 | // Set the normal matrix (inverse transpose of the 3x3 upper-left sub matrix of the |
| 544 | // model-view matrix) |
| 545 | const openglframework::Matrix4 localToCameraMatrix = worldToCameraMatrix; |
| 546 | const openglframework::Matrix3 normalMatrix = localToCameraMatrix.getUpperLeft3x3Matrix().getInverse().getTranspose(); |
| 547 | shader.setMatrix3x3Uniform("normalMatrix", normalMatrix, false); |
| 548 | |
| 549 | // Set the model to camera matrix |
| 550 | shader.setMatrix4x4Uniform("localToWorldMatrix", openglframework::Matrix4::identity()); |
| 551 | shader.setMatrix4x4Uniform("worldToCameraMatrix", worldToCameraMatrix); |
| 552 | |
| 553 | shader.setIntUniform("isGlobalVertexColorEnabled", 0, false); |
| 554 | |
| 555 | // Get the location of shader attribute variables |
| 556 | GLint vertexPositionLoc = shader.getAttribLocation("vertexPosition"); |
| 557 | GLint vertexColorLoc = shader.getAttribLocation("vertexColor"); |
| 558 | |
| 559 | // Lines |
| 560 | if (debugRenderer.getNbLines() > 0) { |
| 561 | |
| 562 | // Bind the VAO |
| 563 | mDebugLinesVAO.bind(); |
| 564 | |
| 565 | mDebugVBOLinesVertices.bind(); |
| 566 | |
| 567 | glEnableVertexAttribArray(vertexPositionLoc); |
| 568 | glVertexAttribPointer(vertexPositionLoc, 3, GL_FLOAT, GL_FALSE, sizeof(rp3d::Vector3) + sizeof(rp3d::uint32), (char*)nullptr); |
| 569 | |
| 570 | glEnableVertexAttribArray(vertexColorLoc); |
| 571 | glVertexAttribIPointer(vertexColorLoc, 3, GL_UNSIGNED_INT, sizeof(rp3d::Vector3) + sizeof(rp3d::uint32), (void*)sizeof(rp3d::Vector3)); |
| 572 | |
| 573 | // Draw the lines geometry |
| 574 | glDrawArrays(GL_LINES, 0, debugRenderer.getNbLines() * 2); |
| 575 | |
| 576 | glDisableVertexAttribArray(vertexPositionLoc); |
| 577 | glDisableVertexAttribArray(vertexColorLoc); |
| 578 | |
| 579 | mDebugVBOLinesVertices.unbind(); |
| 580 | |
| 581 | // Unbind the VAO |
| 582 | mDebugLinesVAO.unbind(); |
| 583 | } |
| 584 | |
| 585 | // Triangles |
| 586 | if (debugRenderer.getNbTriangles() > 0) { |
| 587 | |
| 588 | // Bind the VAO |
| 589 | mDebugTrianglesVAO.bind(); |
| 590 |
nothing calls this directly
no test coverage detected