Hello,
I am trying to render a simple flat mesh plane with glDrawElements, so far i only have the correct vertices and indices but having trouble with using the glDrawElements function and placing the needed render calls in order .
I am also using glPrimitiveRestart, if it helps, I am pretty confident that the indices and the vertices are being used correctly and Im guessing the problem is being my opengl code being in incorrect order.
When ran I do not have any of the vertices drawn, only stuff from other separate draw calls.
Here is the code i have gotten done so farβ¦
[HR][/HR]
This code is only ran once
glGenVertexArrays(1, &meshVAO);
glBindVertexArray(meshVAO);
glGenBuffers(1, &meshVertexVBO); // Vertices
glBindBuffer(GL_ARRAY_BUFFER, meshVertexVBO);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); // Position attribute in shader
glBufferData(GL_ARRAY_BUFFER, groundMesh.m_vertices.size() * sizeof(glm::vec3), &groundMesh.m_vertices, GL_STATIC_DRAW);
glGenBuffers(1, &meshIndexVBO); // For the indices
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshIndexVBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, groundMesh.m_indices.size() * sizeof(unsigned int), &groundMesh.m_indices, GL_STATIC_DRAW);
glBindVertexArray(0);
And this code is looped
m_meshShader.useShader();
glBindVertexArray(meshVAO);
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(16);
GLint camMatLoc = m_meshShader.getUniform("mvpMat");
glUniformMatrix4fv(camMatLoc, 1, GL_FALSE, &(m_camera.getTransformationMatrix()[0][0]));
glDrawElements(GL_TRIANGLE_STRIP, groundMesh.m_indices.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glDisable(GL_PRIMITIVE_RESTART);
m_meshShader.unuseShader();
[HR][/HR]
I can post more code if needed, any help is appreciated