Jump to content
  • Advertisement

Archived

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

LessThanJoe

Color

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

All right...here is the code int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef( -5.0f, 3.75f, -9.03f ); // Move Left 1.5 Units And Into The Screen 6.0 float red = 0; float blue = 0; float green = 255; glBegin(GL_POINTS); // Drawing Using Points for (int counter = 0; counter < trail.numcols(); counter++) { red++; blue++; green--; glColor3f(red,green,blue); glVertex3f(CONV_X float(trail[0][counter]), CONV_Y float(trail[1][counter]), 0.0f); } glEnd(); return TRUE; // Everything Went OK } Why are all of my points white? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
glColor3f() takes intensities between 0..1

Having said that the conversion is simple. All you have to do is divide your intensities (0..255) by 255.

See updated code.


    
DrawGLScene(GLvoid) // Here's Where We Do All The Drawing

{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer

glLoadIdentity(); // Reset The Current Modelview Matrix


glTranslatef( -5.0f, 3.75f, -9.03f ); // Move Left 1.5 Units And Into The Screen 6.0


float red = 0;
float blue = 0;
float green = 255;

glBegin(GL_POINTS); // Drawing Using Points

for (int counter = 0; counter < trail.numcols(); counter++)
{
red++;
blue++;
green--;
glColor3f(red/255,green/255,blue/255);
glVertex3f(CONV_X float(trail[0][counter]), CONV_Y float(trail[1][counter]), 0.0f);
}
glEnd();


return TRUE; // Everything Went OK

}


Additionally, you have to make sure the color wraps around after reaching 255 which has the highest intensity.

In order to do that, instead of using red/255, you use (red%256)/255.

Hope this helps.

[edited by - Gladiator on December 6, 2002 10:04:33 PM]

Share this post


Link to post
Share on other sites
yes, it help immensely. I''m supprised after all of the work I went through to be able to have an 800x600 screen then just convert them to the proper numbers that I''d forgot to do that with colors.

It''s beatiful now. Thank you

Share this post


Link to post
Share on other sites
Or, instead of dividing (which is a bit slow), maybe
you should just use the appropriate function to change
the color =)

There''s a lot different functions to set the color,
and in case you''re used to intensities 0..255, then
you might prefer using glColor3ub(...), which
accepts 3 unsigned bytes (unsigned char).

In case you got access to MSDN, try typing in glColor and
you''ll see that there''s more then 30 diffent functions =D

Share this post


Link to post
Share on other sites

  • Advertisement
×

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!