gl_rogue

05-06-2004, 06:25 PM

Hey, I've come across a problem that I've no idea how to solve, let alone, where to start. What happens is that I draw a quad as usual, and I assign either the color value 1, 1, 1 or 0, 0, 0 to each vertex. This, obviously, gives the polygon an effect of a nice black to white shade. However, if three verteces are white and one is black or vice-versa, what happens is that the shading of the polygon looks correct until one of the verteces is off the visible screen. Then the shading become horribly off, like the vertex color is clipped/ignored WITH THE VERTEX! Here is the code I've used:

disp_test_object(float x, float y, float z, float gam, int texture_index){

float high_light = 1, low_light = 0;

float base_size = 1;

float half_size = base_size / 2;

float verteces[] = {0 - half_size, 0 - half_size, 0,

0 + half_size, 0 - half_size, 0,

0 + half_size, 0 + half_size, 0,

0 - half_size, 0 + half_size, 0};

glPushMatrix();

glTranslatef(x, y, z);

glRotatef(gam, 0, 1, 0);

glDisable(GL_TEXTURE_2D); //glBindTexture(GL_TEXTURE_2D, texture_index);

glBegin(GL_QUADS);

glTexCoord2f(0, 0); glColor4f(high_light, high_light, high_light, 1);

glVertex3f(verteces[0], verteces[1], verteces[2]); //Down Left

glTexCoord2f(1, 0); glColor4f(high_light, high_light, high_light, 1);

glVertex3f(verteces[3], verteces[4], verteces[5]); //Down Right

glTexCoord2f(1, 1); glColor4f(low_light, low_light, low_light, 1);

glVertex3f(verteces[6], verteces[7], verteces[8]); //Up Right

glTexCoord2f(0, 1); glColor4f(high_light, high_light, high_light, 1);

glVertex3f(verteces[9], verteces[10], verteces[11]); //Up Left

glEnd();

glPopMatrix();

glEnable(GL_TEXTURE_2D);

}//END DISPLAY TEST OBJECT FUNCTION

If anyone knows why this happens, or better yet, how to solve it, I would greatly appreciate an answer.

If there's any more information that could be relavent to this problem, please, feel free to ask me for it. I can also take snapshots of this and post it upon request. Thanks alot.

disp_test_object(float x, float y, float z, float gam, int texture_index){

float high_light = 1, low_light = 0;

float base_size = 1;

float half_size = base_size / 2;

float verteces[] = {0 - half_size, 0 - half_size, 0,

0 + half_size, 0 - half_size, 0,

0 + half_size, 0 + half_size, 0,

0 - half_size, 0 + half_size, 0};

glPushMatrix();

glTranslatef(x, y, z);

glRotatef(gam, 0, 1, 0);

glDisable(GL_TEXTURE_2D); //glBindTexture(GL_TEXTURE_2D, texture_index);

glBegin(GL_QUADS);

glTexCoord2f(0, 0); glColor4f(high_light, high_light, high_light, 1);

glVertex3f(verteces[0], verteces[1], verteces[2]); //Down Left

glTexCoord2f(1, 0); glColor4f(high_light, high_light, high_light, 1);

glVertex3f(verteces[3], verteces[4], verteces[5]); //Down Right

glTexCoord2f(1, 1); glColor4f(low_light, low_light, low_light, 1);

glVertex3f(verteces[6], verteces[7], verteces[8]); //Up Right

glTexCoord2f(0, 1); glColor4f(high_light, high_light, high_light, 1);

glVertex3f(verteces[9], verteces[10], verteces[11]); //Up Left

glEnd();

glPopMatrix();

glEnable(GL_TEXTURE_2D);

}//END DISPLAY TEST OBJECT FUNCTION

If anyone knows why this happens, or better yet, how to solve it, I would greatly appreciate an answer.

If there's any more information that could be relavent to this problem, please, feel free to ask me for it. I can also take snapshots of this and post it upon request. Thanks alot.