Professional Documents
Culture Documents
------*/
/* Transformacin de las primitivas, I. Remolar
*/
/* -------------------------------------------------------------------
------*/
#include <GL/glut.h>
#include <stdio.h>
int p = 1;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
}
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
gluLookAt (0,0,0, -3,-3,-3, 0,1,0);
switch (p)
{
case 1:
glutSolidCone (9.0, 20.0, 16, 16);
glTranslatef(22,0.0,0.0);
glutSolidTorus(3.0,7.0, 16,16);
break;
case 2:
glRotatef (-90.0, 1.0, 0.0, 0.0);
glutSolidCone (9.0, 20.0, 16, 16);
glTranslatef(22,0.0,0.0);
glutSolidTorus(3.0,7.0, 16,16);
break;
case 3:
glPushMatrix();
glRotatef (-90.0, 1.0, 0.0, 0.0);
glutSolidCone (9.0, 20.0, 16, 16);
glPopMatrix();
glTranslatef(22,0.0,0.0);
glutSolidTorus(3.0,7.0, 16,16);
break;
default:
break;
}
glutSwapBuffers();
}
switch (tecla) {
case 27: exit (0); break;
case 'z': p =2; Dibuja(); break;
case 'x': p =3; Dibuja(); break;
case 'c': p =1; Dibuja(); break;
}
}
printf( " z - Dibuja las primitivas con una rotacion para el toroide
sin usar las pilas de matrices\n");
printf( " x - Realiza la rotacion del toroide usando las
matrices\n");
printf( " c - Vuelve al dibujado inicial\n");
}
glutReshapeFunc (eventoVentana);
glutKeyboardFunc (eventoTeclado);
}