i’m trying to write a function that takes a value from 0 to 1 (0 representing that i want red, 1 that i want violet. you know roygbiv) and sets glColor3f() accordingly to give me those colors. so far, i’ve tried (unsuccessfully):
void PhysimGLView::setCurrentColor(GLfloat r)
{
if ( r < 0.50 )
{
//glColor3f(1.0, 0.0, 0.0);
glColor3f( ( 0.50 - r )/0.50, r/0.50, 0.00 );
}
else
{
if ( r >= 0.50 && r < 0.501 )
{
glColor3f(0.0, 1.0, 0.0);
}
else
{
glColor3f( 0.00, ( 0.50 - (r - 0.50) )/0.50, (r - 0.50) /0.50 );
}
}