void init_scene()
{
GLfloat mat_diffuse[] = {0.57, 0.49, 0.33, 1.0};
//Assign values to light parameters
GLfloat light1_ambient[] = {0.5, 0.5, 0.5, 1.0};
GLfloat light1_diffuse[] = {0.7, 0.7, 0.5, 1.0};
GLfloat light1_specular[] = {0.1, 0.1, 0.1, 1.0};
GLfloat light1_position[] = {1.0, -1.0, -1.0, 0.0};
//Assign the parameters to Light 1
glLightfv( GL_LIGHT1, GL_AMBIENT, light1_ambient);
glLightfv( GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
glLightfv( GL_LIGHT1, GL_SPECULAR, light1_specular);
glLightfv( GL_LIGHT1, GL_POSITION, light1_position);
//Enable lighting and light 1
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT1);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glShadeModel(GL_SMOOTH);
}
polygon drawing code:
glBegin(GL_TRIANGLES);
for(i = 0; i< Scene.Objects[0].num_polygons; i++)
{
glNormal3fv(Scene.Objects[0].Polygons[i].Vertices[A]->Vertex_normal.c);
glVertex3fv(Scene.Objects[0].Polygons[i].Vertices[A]->coordinates.c);
glNormal3fv(Scene.Objects[0].Polygons[i].Vertices[A]->Vertex_normal.c);
glVertex3fv(Scene.Objects[0].Polygons[i].Vertices[B]->coordinates.c);
glNormal3fv(Scene.Objects[0].Polygons[i].Vertices[A]->Vertex_normal.c);
glVertex3fv(Scene.Objects[0].Polygons[i].Vertices[C]->coordinates.c);
}
glEnd();
[edited by - Paul7 on April 15, 2004 1:46:04 PM]
[edited by - Paul7 on April 18, 2004 3:45:40 AM]
Smooth shading problem
Anyone have any idea why this isnt smooth shading properly? the green lines are the vertex normals and all seem to be correct!
Initiation code:
You''re using the same normal for different vertices, therefore, polygons aren''t smooth. You should use different.
probably an error in the drawing loop. u forgot to change A''s to B and C.
probably an error in the drawing loop. u forgot to change A''s to B and C.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement