PDA

View Full Version : vertex arrays

03-31-2005, 07:40 PM
hi
i'm having trouble imlementing vertex arrays. I want to use vertex arrays to draw whole polygons at once (triangle).
this is the structure i use for vertices:

class sfVector
{
public:

float x,y,z;

normal3d normal;
tex texture;

//constructors
sfVector(){}
sfVector(float a, float b, float c)
{
x = a;
y = b;
z = c;
}

~sfVector(){

}

// Dot product function : overloaded multiplication operator
float operator* (const sfVector &vec)
{
return (x * vec.x + y * vec.y + z * vec.z);
}

// Cross Product funtion : overloaded remainder operator
sfVector operator% (const sfVector &vec) const
{
return (sfVector(y * vec.z - z * vec.y, z * vec.x - x * vec.z, x * vec.y - y * vec.x));
}

sfVector operator+ (const sfVector &vec) const
{
return (sfVector(x + vec.x, y + vec.y, z + vec.y));
}

sfVector operator- (const sfVector &vec) const
{
return(sfVector(x - vec.x, y - vec.y, z - vec.z));
}

/* sfVector& normalize()
{
return (*this /= sqrt(x * x + y * y + z * z));
}*/

//Modulus/ vector length function
float mod()
{
return float(sqrt((pow(x,2)) + (pow(y,2)) + (pow(z,y)) ));
}
};

and then i use std::vector <sfVector> CVectorArray
Is it possible to use vertex arrays with this type of structure? all my attempts have failed. help is very much welcome.

uruk
03-31-2005, 09:08 PM
a-ha...
May I suggest this book (http://www.opengl.org/documentation/red_book_1.0/) ?
And also these tutorials (http://nehe.gamedev.net/default.asp) .