Practica Numero Dos Final
Practica Numero Dos Final
Practica Numero Dos Final
INTEGRANTES:
Resolucin - Pregunta 1
#include<windows.h>
#include <math.h>
#ifdef __APPLE__
#else
#include <GL/glut.h>
#endif
void inicio(){
glMatrixMode(GL_PROJECTION);
glOrtho(-20.0,20.0,-20.0,20.0,-20.0,20.0);
glClearColor(0.0,0.0,0.0,0.0);
}
void pantalla(){
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex3i(3,8,0);glVertex3i(13,11,0);
glVertex3i(13,11,0);glVertex3i(15,9,0);
glVertex3i(15,9,0);glVertex3i(5,6,0);
glVertex3i(5,6,0);glVertex3i(3,8,0);
glVertex3i(3,8,0);glVertex3i(3,5,0);
glVertex3i(3,5,0);glVertex3i(5,3,0);
glVertex3i(5,3,0);glVertex3i(5,6,0);
glVertex3i(5,3,0);glVertex3i(15,6,0);
glVertex3i(15,6,0);glVertex3i(15,9,0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex3i(3,5,0);glVertex3i(3,2,0);
glVertex3i(3,2,0);glVertex3i(5,0,0);
glVertex3i(5,0,0);glVertex3i(5,3,0);
glVertex3i(5,0,0);glVertex3i(14,3,0);
glVertex3f(14,3,0);glVertex3f(14,5.6,0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex3f(10,1.7,0);glVertex3i(11,-5,-19);
glVertex3f(12,2.4,0);glVertex3i(13,-3,-18);
glVertex3f(11,-5,-19);glVertex3i(12,-7,0);
glVertex3f(13,-3,-18);glVertex3f(12.5,-7,0);
glVertex3i(12,-7,0);glVertex3f(12.5,-7,0);
glVertex3f(8,1,0);glVertex3f(8.5,-1.5,0);
glVertex3f(8.5,-1.5,0);glVertex3f(10.3,-0.9,0);
glVertex3f(9.5,1.5,0);glVertex3f(9,0,0);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_LINES);
glVertex3f(-2.5,4.8,0);glVertex3f(3.5,6.3,0);
glVertex3f(3.5,6.3,0);glVertex3f(4.5,5.3,0);
glVertex3f(4.5,5.3,0);glVertex3f(-1.5,3.8,0);
glVertex3f(-1.5,3.8,0);glVertex3f(-2.5,4.8,0);
glVertex3f(-2.5,4.8,0);glVertex3f(-2.5,3.3,0);
glVertex3f(-2.5,3.3,0);glVertex3f(-1.5,2.3,0);
glVertex3f(-1.5,2.3,0);glVertex3f(-1.5,3.8,0);
glVertex3f(-1.5,2.3,0);glVertex3f(4.5,3.8,0);
glVertex3f(4.5,3.8,0);glVertex3f(4.5,5.3,0);
glVertex3i(-13,3,0);glVertex3i(-3,6,0);
glVertex3i(-3,6,0);glVertex3i(-1,4,0);
glVertex3i(-1,4,0);glVertex3i(-11,1,0);
glVertex3i(-11,1,0);glVertex3i(-13,3,0);
glVertex3i(-13,3,0);glVertex3i(-13,0,0);
glVertex3i(-13,0,0);glVertex3i(-11,-2,0);
glVertex3i(-11,-2,0);glVertex3i(-11,1,0);
glVertex3i(-11,-2,0);glVertex3i(-1,1,0);
glVertex3i(-1,1,0);glVertex3i(-1,4,0);
glEnd();
glFlush();
glutCreateWindow("Pistola");
inicio();
glutDisplayFunc(pantalla);
glutMainLoop();
return EXIT_SUCCESS;
}
Resolucin - Pregunta 2
#include<windows.h>
#include <math.h>
#ifdef __APPLE__
#else
#include <GL/glut.h>
#endif
void display();
void specialKeys();
double rotate_y=0;
double rotate_x=0;
void display(){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
for(calz=0;calz>-1;calz=calz-0.001){
for(float i=0.0;i<2*3.1415;i=i+0.03){
calx=radio*cos(i);
caly=radio*sin(i);
glVertex3f(calx,caly,calz);
calz=calz-0.0003;
}}
glEnd();
glFlush();
glutSwapBuffers();
if (key == GLUT_KEY_RIGHT)
rotate_y += 5;
glutPostRedisplay();
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(640,640);
glutCreateWindow("UTILIZA LAS TECLAS DE DIRECCION PARA MOVEL EL
TUNEL");
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(display);
glutSpecialFunc(specialKeys);
glutMainLoop();
return 0;
Resolucin - Pregunta 3
#include<windows.h>
#include <GL/glut.h>
#include<iostream>
using namespace std;
int num1,num2,num3,num4,num5,num6;
float x=20,y=10;
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0,80,0,16);
glColor3f(0.27,0.45,0.65);
minicuadrado(60,12);
glRasterPos2f (62,12);
drawString ("13-21");
glEnd();
glColor3f(0.67,0.27,0.27);
minicuadrado(60,11);
glRasterPos2f (62,11);
drawString ("22-30");
glEnd();
glColor3f(0.53,0.64,0.3);
minicuadrado(60,10);
glRasterPos2f (62,10);
drawString ("31-39");
glEnd();
glColor3f(0.44,0.34,0.56);
minicuadrado(60,9);
glRasterPos2f (62,9);
drawString ("40-48");
glEnd();
glColor3f(0.25,0.6,0.67);
minicuadrado(60,8);
glRasterPos2f (62,8);
drawString ("49-57");
glEnd();
glColor3f(0.86,0.52,0.24);
minicuadrado(60,7);
glRasterPos2f (62,7);
drawString ("58-66");
glEnd();
glColor3f(0.0,0.0,0.0);
glRasterPos2f (0.4,13);
drawString ("12");
glRasterPos2f (0.4,12);
drawString ("11");
glRasterPos2f (0.4,11);
drawString ("10");
glRasterPos2f (0.4,10);
drawString ("9");
glRasterPos2f (0.4,9);
drawString ("8");
glRasterPos2f (0.4,8);
drawString ("7");
glRasterPos2f (0.4,7);
drawString ("6");
glRasterPos2f (0.4,6);
drawString ("5");
glRasterPos2f (0.4,5);
drawString ("4");
glRasterPos2f (0.4,4);
drawString ("3");
glRasterPos2f (0.4,3);
drawString ("2");
glRasterPos2f (0.4,2);
drawString ("1");
glRasterPos2f (0.4,1);
drawString ("0");
glEnd();
glColor3f(0.0,0.0,0.0);
glRasterPos2f (4,0.5);
drawString ("13-21");
glRasterPos2f (12,0.5);
drawString ("22-30");
glRasterPos2f (20,0.5);
drawString ("31-39");
glRasterPos2f (28,0.5);
drawString ("40-48");
glRasterPos2f (36,0.5);
drawString ("49-57");
glRasterPos2f (44,0.5);
drawString ("58-66");
glColor3f(0.1,0.1,0.6);
glBegin(GL_LINES);
glVertex2f(2,15); glVertex2f(2,1);
glVertex2f(2,1); glVertex2f(70,1);
glEnd();
glColor3f(0.2,0.2,0.3);
linea(1);
linea(2);
linea(3);
linea(4);
linea(5);
linea(6);
linea(7);
linea(8);
linea(9);
linea(10);
linea(11);
linea(12);
glEnd();
glColor3f(0.27,0.45,0.65);
cuadro(0,8,num1);
glColor3f(0.7,0.27,0.27);
cuadro(8,16,num2);
glColor3f(0.53,0.64,0.3);
cuadro(16,24,num3);
glColor3f(0.44,0.34,0.56);
cuadro(24,32,num4);
glColor3f(0.25,0.6,0.67);
cuadro(32,40,num5);
glColor3f(0.86,0.52,0.24);
cuadro(40,48,num6);
glFlush();
}
glutCreateWindow("HISTOGRAMA DE EDADES");
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
}