glVertex3fv

I started using OpenGL. I began reading the Redbook. In one of its examples, the glVertex3fv function is used. However, there is no explanation of how it can be used. What I have to write in the parenthesis after this function.
Can anyone explain clearly?

It wants a pointer to an array of 3 float values (x,y,z) for example:

GLfloat v[ 3] = { 0.0f, 0.0f, 0.0f };
glVertex3fv( &v[ 0]);

or GLfloat* v = …
glVertex3fv( v);

It’s just another way to pass the vertex corrdinates to OpenGL, it may be a little faster then using glVertex3f( v[ 0], v[ 1], v[ 2]);

Mikael

I want to ask something more. What is the meaning of 0 in the below function you wrote.

glVertex3fv( &v[ 0]);

Similarly in the Redbook it is written

glVertex3fv(&vdata[tindices[i][0]][0]);
I understand the part [tindices[i][0]] but what is the meaning of the last zero.

First thanks for your help .
I want to ask something more. What is the meaning of 0 in the below function you wrote.

glVertex3fv( &v[ 0]);

Similarly in the Redbook it is written

glVertex3fv(&vdata[tindices[i][0]][0]);
I understand the part [tindices[i][0]] but what is the meaning of the last zero.

v[0] is the starting address of the array.
There, he is passing the array from the first element.

had he passed v[1], the function would have been given the array starting at the second index (most likely resulting in an error as OpenGL attempts to access the third vertex out of bounds).

v[0] would have been the same as v. that is, he could have passed glVertex3fv(&v) since when not specifying an index, the array name itself refers to the first index.

the second 0 you see in that other example is analogous, that’s just a 2 dimensional array.

Thanks all. I have really liked this site.

I’m sorry, I’m really sorry but I’m a perfectionist and things jump out at me. I’m very sure you caught this yourself but:

that is, he could have passed glVertex3fv(&v) since when not specifying an index, the array name itself refers to the first index.

Ahem:

glVertex3fv(v); // no address-of needed

Since arrays are inherently addresses by name and all… :stuck_out_tongue:

right you are. :smiley: