vertex array problem

Started by
2 comments, last by CrazyCdn 18 years ago
In order to learn how to use VBOs, I'm currently trying to make vertex array work. And they don't :-( Not all the polygons are rendered (more or less half of them aren't), but I know that both vertices and faces are correct (if I try to render using immediate mode, everything works). Is there some common mistake that beginners usually make and that can lead to this errot? Don't know if you need code, but anyway:

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glTranslatef(pos[0], pos[1], pos[2]);
    glRotatef(rot_angle, rot_axis[0], rot_axis[1], rot_axis[2]);

    glColor3f(1.0,1.0,1.0);
    //Declares the vertex arrays
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, vertices);
    if(normals)
    {
        glEnableClientState(GL_NORMAL_ARRAY);
        glNormalPointer(GL_FLOAT, 0, normals);
    }
    else glDisableClientState(GL_NORMAL_ARRAY);

    //Draw the geometry
    glDrawElements(GL_TRIANGLES, nfaces, GL_UNSIGNED_SHORT, faces);

Thank you!
Advertisement
change the last line to:

glDrawElements(GL_TRIANGLES, 3 * nfaces, GL_UNSIGNED_SHORT, faces);

The second parameter refers to the number of elements in the connectivity array, not the number of faces.
I-DON'T-BELIVE-IT!!
This is the second dummy error today... Thank you a lot!
Anyway, in my defense, I would like to quote the reference pages that I use:
Quote:
count
Specifies the number of elements to be rendered.

Since the first parameter was GL_TRIANGLES, I interpreted this as number of faces 8-)

Thank you again and rate++!
As you likely know, thats 1.1 specifications. You can get the latest ones, for free, from opengl.org. I think its even a pdf file.

Also, I had the same issue, so don't feel bad.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement