PDA

View Full Version : normal,vertex,indexed array,just little confuse



zydgyy
12-06-2011, 07:36 PM
Here is my question:
if i want to draw a triangle


...
glBegin(GL_TRIANGLES)
glNormal(...)
glVertex(...)
glVertex(...)
glVertex(...)
glEnd()
...

and now assume i want use index array to draw it,how can i organize the arrays,--normals,verteices!!!dupicate the normals for these three vertices,since all arrays have to same size in OPENGL!!!!????

V-man
12-07-2011, 01:26 AM
yes, duplicate the normals.
You might also want to make a vertex structure.
THE WIKI has a page
http://www.opengl.org/wiki/Vertex_Arrays

http://www.opengl.org/wiki/FAQ#Multi_indexed_rendering

zydgyy
12-08-2011, 07:28 PM
Hi,i read the link you sent,here is a sinnpet code from it, little question:
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
why call it mutilple times,is it neccessary???

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(MyVertex), &vertex[0].x);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(MyVertex), &vertex[0].nx);
glClientActiveTexture(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(MyVertex), &vertex[0].s0);
glClientActiveTexture(GL_TEXTURE1);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(MyVertex), &vertex[0].s1);
glClientActiveTexture(GL_TEXTURE2);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(MyVertex), &vertex[0].s2);

_arts_
12-09-2011, 03:19 AM
Call it to enable texture coordinate array for each texture unit you need.

If you just use a single texture unit (default is GL_TEXTURE0), then you don't need to call it several times.