GLShadeMode

Iv been trying this:

if(key == 'p' || key == 'P')
	{
		wireframe = 1-wireframe;
		if (wireframe) 
		{
			glShadeModel(GL_SMOOTH);
		}
		else
		{	
			glShadeModel(GL_FLAT);
		}
		glutPostRedisplay();
	}

But nothing seems to happens, what do i do?

[wireframe = 1]

glShadeModel controls how polygons are shaded. That is, whether they are shaded with a solid color or a different colors. For instance, if you specify a triangle with GL_FLAT, and one vertes is red, one green, and the last blue, the entire triangle will be blue. With GL_SMOOTH, the of a point on the triangle is blended between the threee based on its position.

I think you’re looking for glPolygonMode; see the man page.

Well am looking to with the press of a button switch between:
rendering in flat shaded polygonization
or
rendering in smooth shaded polygonization

I dont know if glPolygonMode can do that?

If you want to swap the shading, then glShadeModel is what you want. I had thought that since you used the variable wireframe, you might want to display a wireframe instead of a solid.

Are you using lighting? The spec (2.1) says that “A primitive may be flatshaded, meaning that all vertices of the primitive are assigned the same color index or the same primary and secondary colors.”(section 2.14.7) It would seem that this does not stop lighting calculations from happening, so the resulting triangle could be smoothly shaded…