vertex arrays help

Hi
I have this piece of functional code, that renders some geometric shapes to the screen.

apont=init;
int count=0;
do{
setTexture(apont->texture);

glBegin(GL_TRIANGLE_STRIP);

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;

glTexture2d(apont->u,apont->v);
glVertex3f(apont->x,apont->y,apont->z);
apont=apont->prox;
count+=4;
glEnd();

}while(apont!=NULL);

Now, i’m tryng to make this with vertex arrays, and this is what i
got so far:

I’m defining an array, where the first 3 digits, are for coords, the
next 2 are for u,v coords, and the last one if for the texture
identification.

float varray[count*6]; --> like this i should have the number
of positions i want in the array.
int total = count;
glVertexPointer ( 3, GL_FLOAT, 3, &v_array );

glTexCoordPointer (2, GL_FLOAT, 1 , &v_array[3]);

num=0;
do{

setTexture(v_array[num+4]);
glBegin(GL_TRIANGLE_STRIP);
glArrayElement(num);
num++;
glArrayElement(num);
num++;
glArrayElement(num);
num++;
glArrayElement(num);
num++;
glEnd();

}until(num!=count); -->the variable count comes

With the vertex arrays, i just get i piece of junk on the screen.
Can someone plese, look at this, and tell me what i’m doinf wrong here?

thanks
Bruno

Here is what I do where:
vertex_list is an array of floats,
normal_vertex_list is an array of floats,
tex_coordinate_list is an array of floats,
face_index_list is an array of shorts,

Notice that I draw the whole thing at once and don’t loop through every element. The faces_index_list is is an array of three elements per poly. Each element represents the index into the vertex_list to use.

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertex_list);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, normal_vertex_list);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, tex_coordinate_list);
// ok display our stuff
glDrawElements(GL_TRIANGLES, number_of_faces*3, GL_UNSIGNED_SHORT, face_index_list);
// now disable stuff for the next guy
glDisableClientState(GL_VERTEX_ARRAY);
// turn of the normal and tex coordinate client states
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

glVertexPointer ( 3, GL_FLOAT, 3, &v_array );

If I am noy mistaken, your stride count needs to be much bigger. The stride is the size of one whole set of your data, 6 * sizeof( GL_FLOAT) in your case.

Later, Guy

To be even more correct about data types, it should be 6*sizeof(float). GL_FLOAT is just a #define, and does not have a specific type.