PDA

View Full Version : Color not properly set



iris_raj
09-30-2003, 02:30 AM
Dear All,

I am rendering a 3D house with differen faces, I am assiging different colors to different faces.What is happening at some faces, the two colors are displayed. I have drawn several houses in a scene. While moving around the scene, at some corners of houses,triangle type thing are generated .Triangle creates a transparency and able to see the other face of the house.

I am giving the code below. Kindly tell where lies the problem

glColor3f(0.0f,1.0f,0.0f);
glTranslatef(0.0,-1.75,0.0);
glBindTexture(GL_TEXTURE_2D,texName[2]);
glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.95);
glVertex3f(0.0,0.0,0.0);
glVertex3f(2.0,0.0,0.0);
glVertex3f(2.0,1.0,0.0);
glVertex3f(1.0,1.5,0.0);
glVertex3f(0.0,1.0,0.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(0.0,0.0,1.0);
glVertex3f(2.0,0.0,1.0);
glVertex3f(2.0,1.0,1.0);
glVertex3f(1.0,1.5,1.0);
glVertex3f(0.0,1.0,1.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(2.0,1.0,1.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,1.0);
glVertex3f(0.0,1.0,0.0);
glVertex3f(0.0,1.0,1.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0,1.0,1.0);
glVertex3f(2.0,0.0,0.0);
glVertex3f(2.0,0.0,1.0);
glVertex3f(2.0,1.0,1.0);
glVertex3f(2.0,1.0,0.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0.0,0.0,0.0);
glVertex3f(0.0,1.0,0.0);
glVertex3f(0.0,1.0,1.0);
glVertex3f(1.0,1.5,1.0);
glVertex3f(1.0,1.5,0.0);
glEnd();
glBegin(GL_POLYGON);
glColor4f(0.0,0.0,0.0,0.0);
glVertex3f(2.0,1.0,0.0);
glVertex3f(2.0,1.0,1.0);
glVertex3f(1.0,1.5,0.0);
glVertex3f(1.0,1.5,1.0);
glEnd();


Thanks

09-30-2003, 10:29 AM
Some of your polygons are self-intersecting. Make sure that you're defining vertices the in proper order.

What you have:


1----2
\ /
\/
/\
/ \
4----3

What you want:


1----2
| |
| |
| |
| |
4----3

iris_raj
09-30-2003, 07:13 PM
Dear sir,

I could not make out anything from your reply. My logical sense is very poor.

Please explain little elaborately

Tenson
10-01-2003, 04:03 AM
The thing he's trying to say is that you should position vertexes in right order to get quad...
Try and draw coordinate system on paper similar to one OpenGL uses. Then draw vertexes and try to find out the coordinates of vertexes.
Finally you should calculate normals...