Practica Numero Dos Final

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

PRACTICA NUMERO 2

INTEGRANTES:

Erick Jeampierre salinas cadillo


Cdigo: 2015024764
Luiggi Vargas Sacsahuillca
Cdigo: 2015024675
Diego Armando Jacho Zuiga
Cdigo: 2015024577

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();

int main(int argc, char *argv[])


{
glutInit(&argc, argv);
glutInitWindowSize(700,600);
glutInitWindowPosition(50,50);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

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

using namespace std;


float radio=0.3,calx,caly,calz;

void display();
void specialKeys();

double rotate_y=0;
double rotate_x=0;

void display(){

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glRotatef( rotate_x, 1.0, 0.0, 0.0 );


glRotatef( rotate_y, 0.0, 1.0, 0.0 );
glRotated(60,1,5,0);

glColor3f( 0.0 , 0.749 , 1.0 );


glBegin(GL_POINTS);
calz=0;

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();

void specialKeys( int key, int x, int y ) {

if (key == GLUT_KEY_RIGHT)
rotate_y += 5;

else if (key == GLUT_KEY_LEFT)


rotate_y -= 5;

else if (key == GLUT_KEY_UP)


rotate_x += 5;

else if (key == GLUT_KEY_DOWN)


rotate_x -= 5;

glutPostRedisplay();

int main(int argc, char* argv[]){

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;

void cuadro(int x1 ,int x2 , int y1){


glBegin(GL_POLYGON);
glVertex2f(x1+2,0+1);
glVertex2f(x1+2,y1+1);
glVertex2f(x2+2,y1+1);
glVertex2f(x2+2,0+1);
glEnd();
}

void minicuadrado(int posx , int posy ){


glBegin(GL_POLYGON);
glVertex2f(posx-1,posy+0.2);
glVertex2f(posx+1,posy+0.2);
glVertex2f(posx+1,posy-0.2);
glVertex2f(posx-1,posy-0.2);
glEnd();
}
void inline drawString (char *s)
{
unsigned int i;
for (i=0; i<strlen(s); i++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, s[i]);
}

void linea(int y){


glBegin(GL_LINES);
glVertex2f(2,y+1); glVertex2f(56,y+1);
}
void display(){

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();
}

int main(int argc, char *argv[])


{
do{

cout<<"HISTOGRAMA DE EDADES ENTRE 13 Y 66 a\xA4os \xA\xA Digite


cuantas personas tienen de 13 a 21 a\xA4os (Numero maximo 12
personas ,Luego presione ENTER)"<<endl;
cin>>num1;
cout<<"Digite cuantas personas tienen de 22 a 30 a\xA4os (Numero
maximo 12 personas ,Luego presione ENTER)"<<endl;
cin>>num2;
cout<<"Digite cuantas personas tienen de 31 a 39 a\xA4os (Numero
maximo 12 personas ,Luego presione ENTER)"<<endl;
cin>>num3;
cout<<"Digite cuantas personas tienen de 40 a 48 a\xA4os (Numero
maximo 12 personas ,luego presione ENTER)"<<endl;
cin>>num4;
cout<<"Digite cuantas personas tienen de 49 a 57 a\xA4os (Numero
maximo 12 personas ,Luego presione ENTER)"<<endl;
cin>>num5;
cout<<"Digite cuantas personas tienen de 58 a 66 a\xA4os (Numero
maximo 12 personas ,Luego presione ENTER)"<<endl;
cin>>num6;

}while(!(num1<=12 && num2<=12 && num3<=12 && num4<=12 &&


num5<=12 && num6<=12));
glutInit(&argc, argv);
glutInitWindowSize(600,600);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

glutCreateWindow("HISTOGRAMA DE EDADES");

glutDisplayFunc(display);
glutMainLoop();

return EXIT_SUCCESS;
}

You might also like