Void Int Int: "Toroide" "Esfera" "Cono" "Cubo" "Puntos" "Lineas" "Relleno"
Void Int Int: "Toroide" "Esfera" "Cono" "Cubo" "Puntos" "Lineas" "Relleno"
Void Int Int: "Toroide" "Esfera" "Cono" "Cubo" "Puntos" "Lineas" "Relleno"
c 11/6/2020 11:21
1
2 void redimensionado(int anchop, int altop) {
3 glViewport(0,0,anchop,altop);
4 glMatrixMode(GL_PROJECTION);
5 glLoadIdentity();
6 gluPerspective(60.0f,(GLfloat)ancho/(GLfloat)alto,0.1,profund
7 gluLookAt(0,0,profundidad/1.2,0,0,0,0,1,0);
8 glMatrixMode(GL_MODELVIEW);
9 glLoadIdentity();
10 }
11
12
13 void luces() {
14 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_ambient)
15 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_diffuse)
16 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_specula
17 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50.0f);
18 glLightfv(GL_LIGHT0, GL_AMBIENT, luz_ambient);
19 glLightfv(GL_LIGHT0, GL_DIFFUSE, luz_diffuse);
20 glLightfv(GL_LIGHT0, GL_SPECULAR, luz_specular);
21 glLightfv(GL_LIGHT0, GL_POSITION, luz_position);
22 glEnable(GL_DEPTH_TEST);
23 glEnable(GL_LIGHT0);
24 }
25
26 void crear_menu() {
27 int submenupoligono, submenutipo;
28 submenupoligono = glutCreateMenu(menupoligono);
29 glutAddMenuEntry("Toroide", 0);
30 glutAddMenuEntry("Esfera", 1);
31 glutAddMenuEntry("Cono", 2);
32 glutAddMenuEntry("Cubo", 3);
33 submenutipo = glutCreateMenu(menutipo);
34 glutAddMenuEntry("Puntos", 0);
35 glutAddMenuEntry("Lineas", 1);
36 glutAddMenuEntry("Relleno", 2);
37 glutCreateMenu(menu);
Page 1 of 6
siete.c 11/6/2020 11:21
38 glutAddSubMenu("Poligono", submenupoligono);
39 glutAddSubMenu("Tipo", submenutipo);
40 glutAddMenuEntry("Alternar Movimiento", 1);
41 glutAddMenuEntry("Alternar Pantalla", 2);
42 glutAddMenuEntry("------------------", 999);
43 glutAddMenuEntry("Salir", 3);
44 glutAttachMenu(GLUT_RIGHT_BUTTON);
45 }
46
47 void menu(int opcion) {
48 switch (opcion) {
49 case 1: alterna_movimiento();break;
50 case 2: alterna_pantalla();break;
51 case 3: exit(0);break;
52 default: break;
53 }
54 }
55
56 void menupoligono(int opcion) {
57 switch (opcion) {
58 case 0 : figura=1;break;
59 case 1 : figura=2;break;
60 case 2 : figura=3;break;
61 case 3 : figura=4;break;
62 default: break;
63 }
64 }
65
66
67 void mouse(int bouton,int estado,int x,int y);
68 void movimiento_mouse(int x,int y);
69 void texto_terminal(char *cmd);
70
71 int posx=0, posy=0;
72 float angulo=0;
73 float esc=1;
74 unsigned int figura=1;
Page 2 of 6
siete.c 11/6/2020 11:21
Page 3 of 6
siete.c 11/6/2020 11:21
Page 4 of 6
siete.c 11/6/2020 11:21
Page 5 of 6
siete.c 11/6/2020 11:21
186 glPopMatrix();
187 glutSwapBuffers();
188 }
189
190 void ejes() {
191 glColor3f(0.9, 0.9, 0.9);
192 glBegin(GL_LINES);
193 glVertex3f(-ancho/2, 0, 0);
194 glVertex3f(ancho/2, 0, 0);
195 glVertex3f(0, alto/2, 0);
196 glVertex3f(0, -alto/2, 0);
197 glEnd();
198 }
199
200 void tecladoNormal(unsigned char tecla, int x, int y) {
201 switch(tecla) {
202 case 27: exit(0);break;
203 }
204 }
205
Page 6 of 6