Skip to content

Commit

Permalink
Fix: VAO binding error in Renderer/TextRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed Jun 28, 2023
1 parent 1816e6a commit 5c9582a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/AIAC/LayerModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
//
Expand All @@ -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<glm::vec3>{*pt1, *pt2, *pt3}, std::vector<uint32_t>{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()
Expand Down
6 changes: 3 additions & 3 deletions src/AIAC/Render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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<LayerSlam>()->Slam.getMap(), glm::vec4(1, 0, 0, 1));

Expand Down
1 change: 1 addition & 0 deletions src/AIAC/Render/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace AIAC

GLuint m_BasicShaderProgram;
GLuint m_MatrixId;
GLuint m_VAO;

glm::mat4 m_ProjMatrix;

Expand Down
6 changes: 3 additions & 3 deletions src/AIAC/Render/TextRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char, Character> 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
// --------
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/AIAC/Render/TextRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 5c9582a

Please sign in to comment.