I need help on vertex array !!

hi,

I can’t find a tutorial or any examples (with source code) of vertex array … and I don’t understand how I can use glTexCoord since I use a index pointer. I can not also use glNormalPointer, is it for normal by face, I need to put a normal by vertex, and why I can’t specify the size of my normal as with glVertexPointer ??

if someone got some answer, anything on that subject, or a URL …

Cheers,
Arath

They are simple enough so I can explain them to you here (I hope):
-you specify an array for vertices, an array for normals, an array for texcoords, and whatever else you need.
-arrays must be logically defined so element #n in the vertex array uses normal #n in the normal array and texcoord #n in the texcoord array… So, if you want multiple normals or texcoords for a vertex, you need to specify multiple vertices (with same xyz).
-you must use glEnableClientState for the arrays you need. Generally, the vertex array is on always, and the others are set on or off depending on your needs.
-try to use glDrawElements whenever posible. Its fast!
-glDrawArrays should be fast too, but might not be as flexible as glDrawElements

The rest can be found in the standard OpenGL 1.1 docs (about the function I talked about, etc…).

thx coco,

I’m sorry, but I’ve got another question : can I throw texture coordinate with “old” glTextCoord() whereas I use buffer array for normal and vertex? Because for each vertex, there is only one normal but there are many texture coordinates. And I don’t want to rebuild my vertex and face hierarchy to use vertex array (a triangle with 3 vertex not shared and 3 texture coordinate), as I need shared vertex, to calculate vertex normal, and to animate my mesh (it’s faster to move one vertex shared than many …)

regards,
Arath

You can use glArrayElement (i think that’s what it’s called), and call glTexCoord for each glArrayElement.

If you use glArrayElement, you have to manually call each vertex, with a for-loop for example, containing first glTexCoord and then glArrayElement.

Hello,
I think you should take a look at the Red book, there’s in example code on vertex array

Originally posted by Arath:
[b]hi,

I can’t find a tutorial or any examples (with source code) of vertex array … and I don’t understand how I can use glTexCoord since I use a index pointer. I can not also use glNormalPointer, is it for normal by face, I need to put a normal by vertex, and why I can’t specify the size of my normal as with glVertexPointer ??

if someone got some answer, anything on that subject, or a URL …

Cheers,
Arath[/b]

thx Bob,
I’ll try it this evening, hope it works.

Slash, I read the red-book but there is no examples with texture coordinate or normal array … so that’s why I post a topic here!

Arath

I prefer to use glDrawElements and split vertices that have more than one normal, texcoord, etc. But, if all your vertices need multiple texcoords, you’re better with glArrayElement or with inmediate triangles.