From 5c9582a20d98de2b4d90afd1ecec37bf44444394 Mon Sep 17 00:00:00 2001 From: 9and3 Date: Wed, 28 Jun 2023 15:13:10 +0200 Subject: [PATCH] Fix: VAO binding error in Renderer/TextRenderer --- src/AIAC/LayerModel.cpp | 10 +++++----- src/AIAC/Render/Renderer.cpp | 6 +++--- src/AIAC/Render/Renderer.h | 1 + src/AIAC/Render/TextRenderer.cpp | 6 +++--- src/AIAC/Render/TextRenderer.h | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/AIAC/LayerModel.cpp b/src/AIAC/LayerModel.cpp index 9851f9aa..007a7548 100644 --- a/src/AIAC/LayerModel.cpp +++ b/src/AIAC/LayerModel.cpp @@ -42,11 +42,11 @@ namespace AIAC auto transMat = GetRigidTransformationMatrix(cadBox, fabBox); cout << glm::to_string(transMat) << endl; - // // >>>>>>>>>>>>>> TEST for the Render parsing >>>>>>>>>>>>>> - uint32_t idPt1 = GOPoint::Add(1, 1, 1, 5.0f); +// // >>>>>>>>>>>>>> TEST for the Render parsing >>>>>>>>>>>>>> +// uint32_t idPt1 = GOPoint::Add(1, 1, 1, 5.0f); // uint32_t idPt2 = GOPoint::Add(20, 50, 20, 5.0f); // uint32_t idPt3 = GOPoint::Add(30, 30, 30, 5.0f); - auto pt1 = GOPoint::Get(idPt1); +// auto pt1 = GOPoint::Get(idPt1); // auto pt2 = GOPoint::Get(idPt2); // auto pt3 = GOPoint::Get(idPt3); // @@ -65,11 +65,11 @@ namespace AIAC // uint32_t triangle2 = GOTriangle::Add(*pt2, *pt3, *pt1); // uint32_t triangle3 = GOTriangle::Add(*pt3, *pt1, *pt2); // uint32_t mesh1 = GOMesh::Add(std::vector{*pt1, *pt2, *pt3}, std::vector{0,1,2}); - uint32_t text1 = GOText::Add("Hello World1", *pt1, 1.0f); +// uint32_t text1 = GOText::Add("Hello World1", *pt1, 1.0f); // GOText::Remove(text1); // uint32_t text2 = GOText::Add("Hello World2", *pt2, 1.0f); // uint32_t text3 = GOText::Add("Hello World3", *pt3, 1.0f); - // >>>>>>>>>>>>>> TEST for the Render parsing >>>>>>>>>>>>>> +// // >>>>>>>>>>>>>> TEST for the Render parsing >>>>>>>>>>>>>> } void LayerModel::OnFrameStart() diff --git a/src/AIAC/Render/Renderer.cpp b/src/AIAC/Render/Renderer.cpp index eb0c5cb7..fb972b47 100644 --- a/src/AIAC/Render/Renderer.cpp +++ b/src/AIAC/Render/Renderer.cpp @@ -27,6 +27,9 @@ namespace AIAC m_BasicShaderProgram = LoadShaders(vertexFilePath, fragmentFilePath); + glGenVertexArrays(1, &m_VAO); + glBindVertexArray(m_VAO); + // Get a handle for our "MVP" uniform m_MatrixId = glGetUniformLocation(m_BasicShaderProgram, "MVP"); @@ -188,9 +191,6 @@ namespace AIAC DigitalModel.DrawBoundingBoxEdges(m_DigitalModelBoundingBoxColor); DigitalModel.DrawFaces(m_DigitalModelFaceColor); } - for (auto& mesh : Meshes) { - mesh.DrawEdges(m_DefaultEdgeColor); - } DrawSlamMap(AIAC_APP.GetLayer()->Slam.getMap(), glm::vec4(1, 0, 0, 1)); diff --git a/src/AIAC/Render/Renderer.h b/src/AIAC/Render/Renderer.h index 228f083f..f17559d5 100644 --- a/src/AIAC/Render/Renderer.h +++ b/src/AIAC/Render/Renderer.h @@ -68,6 +68,7 @@ namespace AIAC GLuint m_BasicShaderProgram; GLuint m_MatrixId; + GLuint m_VAO; glm::mat4 m_ProjMatrix; diff --git a/src/AIAC/Render/TextRenderer.cpp b/src/AIAC/Render/TextRenderer.cpp index 3b1fc887..1e6edc45 100644 --- a/src/AIAC/Render/TextRenderer.cpp +++ b/src/AIAC/Render/TextRenderer.cpp @@ -15,14 +15,14 @@ namespace AIAC{ TextRenderer* TextRenderer::s_instance = nullptr; bool TextRenderer::s_Initialized; GLuint TextRenderer::s_ShaderProgram; - GLuint TextRenderer::s_VAO, TextRenderer::s_VBO; + GLuint TextRenderer::s_VBO; std::map TextRenderer::Characters; glm::mat4 TextRenderer::s_Projection = glm::mat4(1.0f); void TextRenderer::Init() { s_instance = new TextRenderer(); - glGenVertexArrays(1, &s_VAO); + // glGenVertexArrays(1, &s_VAO); // Load FreeType // -------- @@ -155,7 +155,7 @@ namespace AIAC{ glActiveTexture(GL_TEXTURE0); - glBindVertexArray(s_VAO); + // glBindVertexArray(s_VAO); glBindBuffer(GL_ARRAY_BUFFER, s_VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 6 * 4, nullptr, GL_DYNAMIC_DRAW); glEnableVertexAttribArray(0); diff --git a/src/AIAC/Render/TextRenderer.h b/src/AIAC/Render/TextRenderer.h index 75acb6f3..dbc6bdb6 100644 --- a/src/AIAC/Render/TextRenderer.h +++ b/src/AIAC/Render/TextRenderer.h @@ -64,7 +64,7 @@ namespace AIAC private: static bool s_Initialized; static GLuint s_ShaderProgram; - static GLuint s_VAO, s_VBO; + static GLuint s_VBO; static TextRenderer* s_instance; static glm::mat4 s_Projection; };