Bizzare glColor3f() problem

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?

Since you’re using the float version of glColor, you should provide it with values in the range 0…1

Whoah, thanks. That works like a charm.

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 ? :wink: