Advertisement

Question about tut # 9...

Started by September 25, 2001 01:36 PM
4 comments, last by HardSniper 23 years, 5 months ago
I understand how this assigns values star[loop].r=rand()%256; but, I don''t understand how the following line of code assigns values... glColor4ub(star[(num-loop)-1].r,star[(num-loop)-1].g,star[(num-loop)-1].b,255); Any clarification would be greatly appreciated... HardSniper
HardSniper
Hi!!


Are you sure that the last line should asign any values?
It don''t look like that to me!

It uses the values set in the first line to set color to something! No values are bein set! (At least not the way i see it)!!

If it does set values......i''d like to know how to!

Take Care!

- -- ---[XaOs]--- -- -

[ project fy ]
- -- ---[XaOs]--- -- -[ Project fy ||| CyberTux ]
Advertisement
here is the surrounding code, copied straight from the tutorial...

"
if (twinkle) // Twinkling Stars Enabled
{
// Assign A Color Using Bytes
glColor4ub(star[(num-loop)-1].r,star[(num-loop)-1].g,star[(num-loop)-1].b,255);
glBegin(GL_QUADS); // Begin Drawing Textured Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);
glEnd(); // Done Drawing The Textured Quad
}



HardSniper
HardSniper
I think that is assigning random(not random, but a pattern: star one, light pink, two darker pink, three darkest pink, etc..) red, green, or blue values to each different star drawn while twinkling is enabled.. but I am not sure.

"I've sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do'Urden

Edited by - Drizzt DoUrden on September 25, 2001 9:01:23 PM
------------------------------Put THAT in your smoke and pipe it
quote:
Original post by HardSniper
here is the surrounding code, copied straight from the tutorial...
// Assign A Color Using Bytes
HardSniper


I don''t think he means he''s doing variable assigning here. This is simply a way of specifying the colour for the block. Essentially he''s saying ''Make the following object colour x'' and because its in a loop each star is given a different colour.

star[(num-loop)-1].r -- There is no assignation there, it simply returns the ''r'' component of the object.

Hope this helps a bit...

MrChris
Thanks guys, I think I''ve got it.

HardSniper
HardSniper

This topic is closed to new replies.

Advertisement