Problems with vertex arrays

Started by
1 comment, last by richardve 23 years, 9 months ago
Please take a look at the following screenshots and code: As you can see, the normals and texture coords are messed up in the first shot. Am I doing something wrong again??
                
struct vect3D
{
    float x, y, z;
};
//

struct vect2D
{
    float x, y;
};
//

vect3D *m_pNormals;
vect2D *m_pTexCoords;
vect3D *m_pVertices;
UINT   *m_pIndices;
//

// m_pNormals = new vect3D[NormalCnt];

// fill the arrays...

// blah, blah, blah...
//

//

//

glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
//

glNormalPointer  (GL_FLOAT, 0, m_pNormals);
glTexCoordPointer(2, GL_FLOAT, 0, m_pTexCoords);
glVertexPointer  (3, GL_FLOAT, 0, m_pVertices);
//

glDrawElements(GL_TRIANGLES, m_iFaceCnt*3, GL_UNSIGNED_INT, m_pIndices);
//

glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
    
btw. the shot with good normals & tex coords are drawn with the glVertex3f stuff. Edited by - richardve on 7/26/00 2:07:44 AM Edited by - richardve on 7/26/00 2:08:44 AM
Advertisement
I''d say there is a problem with the generation of your indices. Each vertex (3 floats) must be associated to 2 tex. coord. floats and 3 normal floats exactly. Are you sure you aren''t trying to share some vertices ? You can check the size of your arrays. You should have something like Size_array_vertices=Size_array_normals=Size_array_texcoords*2/3 (i think).

Y.
I''ve checked the sizes and they are all good and I''m not sharing any vertices...

AFAIK the indices are good too, but I''ll try to change some things tommorow...

thnx for the reply!

This topic is closed to new replies.

Advertisement