• Advertisement

Archived

This topic is now archived and is closed to further replies.

Question about tut # 9...

This topic is 5989 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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 ]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites

  • Advertisement