Jump to content
• Advertisement

#### Archived

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

# Question about tut # 9...

This topic is 6261 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

##### 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

##### 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

##### 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

##### Share on other sites
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

##### Share on other sites
Thanks guys, I think I''ve got it.

HardSniper

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 12
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
633346
• Total Posts
3011449
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!