Hi, this is a problem which has been plaguing me for quite some time now… Hope someone can help me?
I have a code that draws 2 objects based on condition ‘a’.If ‘a’ is 1, it draws the first object, if ‘a’ is 2, it draws the second object. ‘a’ toggles every now and then from 1 to 2.
These are 4 observations I made.
1)If object 1 is drawn alone, there is no problem.
2)If object 2 is drawn alone, the color of object 2 is different from what I expected. (it seems more brown than orange)
3)If object 1 is drawn first, followed by object 2, there is no problem.
4)If object 2 is drawn first followed by object 1, the color of object 2 is the same as condition (2), meaning it is more brown than orange.
Below is my code in this area, pls help!!
/////////////////////////////////////////////
static GLfloat color[8][3]=
{ //red,orange,yellow,green,blue,indigo,
//light blue, black
{1.0f,0.0f,0.0f},{1.0f,0.5f,0.0f},{1.0f,1.0f,0.0f},{0.0f,1.0f,0.0f},{0.0f,0.0f,1.0f},{0.97f,0.61f,0.96f}, {0.65f,0.8f,0.95f},{0.0f,0.0f,0.0f}
};
…
void DrawObject(void)
{
glColor3fv(color[colorloop]);
glCallList(object);
}
…
////in my renderscene function/////
…
if (a==1)
{
glPushMatrix();
glTranslatef(x1,0.0f,z1};
glRotatef(rot,0.0f,1.0f,0.0f);
colorloop=0;
DrawObject();
glPushMatrix();
}
…
…
if (a==2)
{
glPushMatrix();
glTranslatef(x2,0.0f,z2};
glRotatef(rot,0.0f,1.0f,0.0f);
colorloop=1;
DrawObject();
glPushMatrix();
}
///////////////////////////////////////////////
Pls help me if you know anything. Thanks!