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.
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.
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]
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 BufferglLoadIdentity(); // Reset The Current Modelview MatrixglTranslatef( -5.0f, 3.75f, -9.03f ); // Move Left 1.5 Units And Into The Screen 6.0float red = 0;float blue = 0;float green = 255;glBegin(GL_POINTS); // Drawing Using Pointsfor (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]
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
It''s beatiful now. Thank you
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement