#include void display(void) { static GLfloat rojo[] = { 1.0, 0.0, 0.0 }; static GLfloat verde_obscuro[] = { 0.0, 0.5, 0.0 }; static GLfloat carne[] = { 0.8, 0.5, 0.5 }; glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef(0.0,0.0,-4.0); glPushMatrix(); /* cara */ glScalef(0.75,1.0,0.75); glColor3fv(carne); glutSolidSphere(1.0,50,50); glPopMatrix(); glPushMatrix(); /* sombrero */ glTranslatef(0.0,0.5,0.0); glRotatef(-90.0,1.0,0.0,0.0); glColor3fv(verde_obscuro); glutSolidCone(0.75,1.0,10,10); glPopMatrix(); glPointSize(8.0); glColor3f(0.0,0.0,0.0); glBegin (GL_POINTS); /* ojos */ glVertex2f(0.2, 0.1); glVertex2f(-0.2, 0.1); glEnd (); glBegin(GL_TRIANGLES); /* nariz */ glVertex2f(0.0, 0.0); glVertex2f(-0.1, -0.3); glVertex2f(0.1, -0.3); glEnd(); glColor3fv(rojo); glLineWidth(3); glBegin (GL_LINE_STRIP); /* boca */ glVertex2f(-0.3, -0.6); glVertex2f(-0.2, -0.7); glVertex2f(0.2, -0.7); glVertex2f(0.3, -0.6); glEnd (); glPopMatrix(); glFlush(); } void reshape(int width, int height) { glClearColor(1.0,1.0,1.0,1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (float)width/height, 3.0, 7.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int main(int argc, char** argv) { glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE); glutInitWindowPosition(50, 50); glutInitWindowSize(640, 480); glutInit(&argc, argv); glutCreateWindow("Carita"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; }