PDA

View Full Version : I need help on vertex array !!



Arath
01-23-2001, 01:18 PM
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

coco
01-23-2001, 04:48 PM
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...).

Arath
01-23-2001, 11:40 PM
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

Bob
01-23-2001, 11:52 PM
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.

01-24-2001, 12:13 AM
Hello,
I think you should take a look at the Red book, there's in example code on vertex array


Originally posted by Arath:
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

Arath
01-24-2001, 12:27 AM
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

coco
01-24-2001, 06:31 AM
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.