View Full Version : Bizzare glColor3f() problem

07-17-2008, 07:21 PM
Hi, I'm drawing a series of points using the following code:

//draw each pixel between the two points
glColor3f( m_nRed, m_nGreen, m_nBlue );
glBegin( GL_POINTS );
for( float j=fX1; j<=fX2; j++ )
glVertex3i( j, m_fCurrentYvalue, 0 );

I have a weird bug when using the following values:

glColor3f( 150, 50, 250 );

This draws all the points as white. I have to change the '150' value to '0' in order for it to draw anything but white.

Any ideas?

07-17-2008, 07:50 PM
Since you're using the float version of glColor, you should provide it with values in the range 0..1

07-17-2008, 07:57 PM
Whoah, thanks. That works like a charm.

07-18-2008, 01:50 AM
Or if you want to keep integer values, you should use

Remember, the way functions names behave in openGL, it's very practical since a lot of functions gives a lot of informations just in their names.

ie : glVertex3f(); means : glVertex stands for 'I will draw a vertex', '3' stands for 3 arguments , 'f' stands for float ...

See what i mean ? ;)