Hi!
I try to render a mesh with GL_LINE_LOOP, but the result is deform:
This image show the vertex of the mesh and the indices:
The code to load and render:
void PhysicObject::Load(void)
{
glGenVertexArrays(1, &BufferIds[0]);
ExitOnGLError("ERROR: No se puede generar el VAO");
glBindVertexArray(BufferIds[0]);
ExitOnGLError("ERROR: No se puede bindear el VAO");
// Activamos dos vertex attribute locations
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
ExitOnGLError("ERROR: No se puede activar los vertex attributes");
// Creamos los VBO
glGenBuffers(2, &BufferIds[1]);
ExitOnGLError("ERROR: No se pueden generar los buffer objects");
// Bindeamos el VBO al VAO
glBindBuffer(GL_ARRAY_BUFFER, BufferIds[1]);
glBufferData(GL_ARRAY_BUFFER, vertices.size()*sizeof(VertexTextureNormal), &vertices[0], GL_STATIC_DRAW);
ExitOnGLError("ERROR: No se puede bindear el VBO al VAO");
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertices[0]) ,0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertices[0]) , (GLvoid*) sizeof(vertices[0].position));
ExitOnGLError("ERROR: Could not set VAO attributes");
// Creamos el IBO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferIds[2]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(GLuint), &indices.front(), GL_STATIC_DRAW);
ExitOnGLError("ERROR: No se puede bindear el IBO al VAO");
glBindVertexArray(0);
}
void PhysicObject::Draw()
{
std::cout<<c<<std::endl;
// Create the ModelMatrix
glm::mat4 ModelMatrix = glm::translate(
glm::mat4(1.0f),
getPosition()
);
colormat->Prepare3dDraw(ModelMatrix);
glBindVertexArray(BufferIds[0]);
ExitOnGLError("ERROR: No se puede bindear el VAO para dibujar");
glDrawElements(GL_LINE_LOOP, indices.size(), GL_UNSIGNED_INT, (GLvoid*)0);
ExitOnGLError("ERROR: No se puede dibujar el meshpart");
glBindVertexArray(0);
}