Jump to content
  • Advertisement
Sign in to follow this  

vertex array problem

This topic is 4607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:

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

    //Declares the vertex arrays
    glVertexPointer(3, GL_FLOAT, 0, vertices);
        glNormalPointer(GL_FLOAT, 0, normals);
    else glDisableClientState(GL_NORMAL_ARRAY);

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

Thank you!

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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:

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++!

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!