Reputation: 2786
Here is my function:
void Object::draw2()
{
if(!mIsInitialised) { return; }
//Tell OpenGL about our vertex and normal data
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &Vertices.front());
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, &Temp2.front());
//draw the .txt-file
glDrawElements(GL_TRIANGLES, Indices.size(), GL_UNSIGNED_INT, &Indices.front());
//restore the state GL back
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
}
My indices-vector contains: 1 2 3 1 3 4
My vertices-vector contains: -1 -1 0 1 -1 0 1 1 0 -1 1 0
When I run the program, it only draws half a quad - I.e a triangle.
The result -> https://i.sstatic.net/jZALG.png
Upvotes: 3
Views: 1287
Reputation: 25396
Your indices vector should contain:
0 1 2 0 2 3
Otherwise, you never touch the vertex number 0
and end up with the half of the quad.
Upvotes: 7