Advertisement

converting function

Started by June 30, 2003 06:54 PM
3 comments, last by penetrator 21 years, 8 months ago
How can i convert glVertex3fv((pos + (right + up) * -size).v); to glVertex3f ?
quote:
Original post by penetrator
How can i convert glVertex3fv((pos + (right + up) * -size).v);
to glVertex3f ?




Umm...

I''m presuming
(pos + (right + up) * -size).v
returns an array of three floats while pos, right, up and are all, for instance, of the form float[3] (or
TVector
-kind-of structures with overloaded addition and subtraction operators that allow you to operate on them) and size is a simple float.

float* vec = (pos + (right + up) * -size).v;

glVertex3f(vec[0], vec[1], vec[2]);

This is just a dry hack - the code is not tested and I didn''t really understand your problem... Please provide some more information on what you''ve got and what form it is in.
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
What is wrong with using glVertex3fv? The results are the same as glVertex3f in this example.

Oh, and on a side note, it looks like somebody is doing billboading
Yes, infact i''m setting up a billboarded particle engine. I wanted to convert the function in order to be able to randomize a little bit the x,y,z components: with Crispy solution i will be able to do it, otherwise i wouldn''t know how to affect, for example, the x component in a glVertex3fv((pos + (right + up) * -size).v);


I guess its from the OpenGL Game Programming Book.
The vectors there have overloaded [] operators:
// vector index
scalar_t &operator[](const long idx)
{
return *((&x)+idx);
}

glVertex3f takes a pointer to 3 float components. glVertex3 takes them as 3 parameters.
PM Times change... Excuse my poor english!

This topic is closed to new replies.

Advertisement