hi there,
I got problem changing from line to smooth filling using glPolygonMode(…)…
here is my code
if(choice == 0) {
objList = glGenLists(1);
glNewList(objList, GL_COMPILE);
defGeo.drawSphere(radius, surfaces, surfaces);
glEndList();
}else if(choice == 1) {
objList = glGenLists(2);
glNewList(objList, GL_COMPILE);
defGeo.drawTorus(radius, surfaces, surfaces, 20, 20);
glEndList();
}else if(choice == 3) {
objList = glGenLists(3);
glNewList(objList, GL_COMPILE);
defGeo.drawWeirdParabolic(radius, surfaces, surfaces);
glEndList();
}
glClearColor(0, 0, 0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(
-tw/2.0, tw/2.0,
-th/2.0, th/2.0,
-300.0, 300.0
);
/*glFrustum(
-tw/2.0, tw/2.0,
-th/2.0, th/2.0,
-300.0, 300.0
);*/
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
if(lighting0) {
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_intensity);
//glLightfv(GL_LIGHT0, GL_AMBIENT, light1_amb);
glLightfv(GL_LIGHT0, GL_POSITION, light0_dir);
}else {
glDisable(GL_LIGHT0);
}
if(lightingMove) {
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_intensity);
//glLightfv(GL_LIGHT1, GL_AMBIENT, light1_amb);
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 2.0);
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 1.0);
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.5);
glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 45.0);
glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, light1_dir);
}else {
glDisable(GL_LIGHT1);
}
glTranslatef( 0.0, 0.0, -2.6f );
glTranslatef( objTranslation[0], objTranslation[1], -objTranslation[2] );
glMultMatrixf( objRotation );
glPushMatrix();
//glTranslatef( -.5, 0.0, 0.0 );
glColor3f(1.0, 1.0, 1.0);
if(wireframe == 1) {
//DisplayFunc();
//printf("Wireframe");
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);
glCallList(objList);
glPopMatrix();
glutSwapBuffers();
glutPostRedisplay();
} else if(wireframe == 0) {
//DisplayFunc();
//glPolygonMode( GL_FRONT_AND_BACK, GL_SMOOTH);
//printf("Not Wireframe");
glShadeModel(GL_SMOOTH);
glCallList(objList);
glPopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
}
wireframe var is conroller by the glui checkbox so whenever i checked and uncheck it it should change from wireframe mode and filling mode but it didnt work… please help me thanks you in advance