Difference between glVertex3fv and glVertex3f

static GLfloat vdata[12][3] = {
    {-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z},
    {0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X},
    {Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0}
};
static GLint tindices[20][3] = {
    {0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},
    {8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3},
    {7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
    {6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11}
};

...

for (i = 0; i < 20; i++) {
    glBegin(GL_TRIANGLES);
    glColor3f(0.5, 0.0, 0.0);
    glVertex3fv(&vdata[tindices[i][0]][0]);
    glColor3f(0.0, 1.0, 1.0);
    glVertex3fv(&vdata[tindices[i][1]][0]);
    glColor3f(0.0, 0.6, 1.0);
    glVertex3fv(&vdata[tindices[i][2]][0]);
    glEnd();
}

In this code, does glvertex3fv need to take 3 arguments? In my opinion, it only takes one argument, am I wrong? What kind of difference do they have(i.e. glvertex3f and glvertex3fv)?

Answers


You are right! It only takes one argument which is a pointer. In your example you pass the pointer to an vertex3f (by using &) by declaring the position of the first of three floating point variables (by using [0]) in vdata. tindices[i][j] specificies which vertex3f you want from vdata. :) With glVertex3f you pass 3 floating point variables with glVertex3fv a pointer to three floating point variables (like GLfloat).


The number represents how many numbers make up each logical point and the letter after the number is the variable type.

2f = two floating point numbers for each coordinate 3f = three floating point numbers for each coordinate 3fv =

3 - Expect three variables for each coordinate f - These coordinates are in "float" format (they always are). v - Vertex will be passed in as an array.

Otherwise we would have to pass the X, Y and Z coordinates separately.


Need Your Help

Difference between REMOTE_HOST and REMOTE_ADDR

apache server-variables

What is the difference between these two variables?

How to get cookies using FCGI

perl nginx fastcgi

I have the following Perl FastCGI script: