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 - Ie a triangle.
The result -> http://i.stack.imgur.com/jZALG.png
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.