Вы находитесь на странице: 1из 11

UNIVERSIDAD TECNOLÓGICA DE PANAMÁ

FACULTAD DE INGENIERÍA DE SISTEMAS COMPUTACIONALES


DEPARTAMENTO DE COMPUTACIÓN Y SIMULACIÓN DE SISTEMAS
HERRAMIENTAS DE COMPUTACIÓN GRÁFICA
GRUPO: 1IL-132

TALLER #4
Manejo de elementos gráficos en entornos digitales.

Profesor: Samuel Jimenez

Realizado por:
Requena, Tomas 20-70-3735
Solanilla, Fabio 8-954-2298
Uribe, Daniel 20-14-3774
Vasquez, Andres 20-70-4081
Anel Vasquez

PANAMÁ, 2019
INTRODUCCIÓN

En este trabajo estamos plasmando los conocimientos que hemos adquirido durante
el curso de ‘Herramientas de computación gráfica’, curso en el cual hemos tenido la
oportunidad utilizar la herramienta OpenGl para crear figuras primitivas con las cuales
hemos compuesto gráficos más complejos, siendo en este caso una pista de
aterrizaje - Tomas Requena

La principal idea de este taller es mostrar el potencial que tienen este tipo de
herramientas, que con el uso de figuras geometricas se pueden crear dibujos
completos - Daniel Uribe

OpenGL es una herramienta espectacular para el dibujo digital, en esta nueva tarea
realizaremos una pista de aterrizaje basandonos en una vista superior de un avion -
Fabio Solanilla

A traves del uso de las diferentes figuras basicas con las cuales podemos dibujar en
OpenGL - GLUT, trataremos de representar una foto de una pista de aterrizaje en la
cual se mostrara la vista de forma superior - Andres Vasquez

Lograr que una combinación de figuras basicas como triangules, rombos, rectangulos
y poligonos de diferentes lados puedan redibujar una foto es un reto interesante, a
continuación con OpenGL y GLUT trataremos de lograr el objetivo del taller - Anel
Vasquez
CODIGO

#include <iostream>
#include <GL/glut.h>

double getRGB(int value) {


return (value > 255 && value < 0) ? 0.0 : value- / 255.0;
}

GLint getCoord(double coord) {


GLint newCoord = coord;
return newCoord;
}

void configMatrix() {
glClearColor(getRGB(128), getRGB(229), getRGB(222), 0.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(-100, 100, -100, 100); /* left, right, bottom, top */
glEnable(GL_DEPTH_TEST);
}

void drawPlane() {
glBegin(GL_QUADS);
glColor3f(0, 0, getRGB(135));
glVertex3f(-20.0, 0.0, 0.0f);
glVertex3f(-10.0, 50.0, 0.0f);
glVertex3f(10.0, 50.0, 1.0f);
glVertex3f(20.0, 0.0, 1.0f);
glEnd();
glFlush();

glBegin(GL_QUADS);
glColor3f(getRGB(135), 0, 0);
glVertex3f(-50.0, 20.0, 0.0f);
glVertex3f(-50.0, -20.0, 0.0.f);
glVertex3f(50.0, -20.0, 1.0f);
glVertex3f(50.0, 20.0, 1.0f);
glEnd();
glFlush();

glBegin(GL_POLYGON);
glColor3f(getRGB(135), 0, 0);
glVertex3f(-50.0, 20.0, 1.0f);
glVertex3f(-65.0, 20.0, 0.0f);
glVertex3f(-85.0, -2.0, 0.0f);
glVertex3f(-85.0, -20.0, 0.0f);
glVertex3f(-50.0, -20.0, 1.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(255), getRGB(240), getRGB(230));

glVertex3f(-80.0, -2.0f, 0.0f);


glVertex3f(-65.0f, -2.0f, 0.0.f);
glVertex3f(-65.0f, 15.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_QUADS);
glColor3f(0, 0, getRGB(135/));
glVertex3f(-20.0, -10.0, 0.0f);
glVertex3f(-10.0, -50.0, 0.0f);
glVertex3f(10.0, -50.0, 1.0f);
glVertex3f(20.0, -10.0, 1.0f);
glEnd();
glFlush();

glBegin(GL_POLYGON);
glColor3f(getRGB(135), 0, 0);
glVertex3f(50.0, -20.0, 1.0f);
glVertex3f(80.0, -20.0, 0.0f);
glVertex3f(80.0, 50.0, 0.0f);
glVertex3f(65.0, 50.0, 0.0f);
glVertex3f(50.0, 20.0, 1.0f);
glEnd();
glFlush();

glBegin(GL_QUADS);
glColor3f(0, 0, getRGB(135));
glVertex3f(60.0, -12.5, 0.0f);
glVertex3f(70.0, -35.0, 0.0f);
glVertex3f(80.0, -40.0, 1.0f);
glVertex3f(80.0, -12.5, 1.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(255), getRGB(240), getRGB(230));

glVertex3f(-40.0, 0.0f, 0.0f);


glVertex3f(-35.0f, 10.0f, 0.0f);
glVertex3f(-30.0f, 0.0, 0./0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(255), getRGB(240), getRGB(230));

glVertex3f(-20.0, 0.0f, 0.0f);


glVertex3f(-15.0f, 10.0f, 0.0f);
glVertex3f(-10.0f, 0.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(255), getRGB(240), getRGB(230));

glVertex3f(0.0, 0.0f, 0.0f);


glVertex3f(5.0f, 10.0f, 0.0f);
glVertex3f(10.0f, 0.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(255), getRGB(240), getRGB(230));

glVertex3f(20.0, 0.0f, 0.0f);


glVertex3f(25.0f, 10.0f, 0.0f);
glVertex3f(30.0f, 0.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(255), getRGB(240), getRGB(230));

glVertex3f(40.0, 0.0f, 0.0f);


glVertex3f(45.0f, 10.0f, 0.0f);
glVertex3f(50.0f, 0.0, 0.0f);
glEnd();
glFlush();

void makeLand() {
glBegin(GL_POLYGON);
glColor3f(getRGB(44), getRGB(50), getRGB(19));
glVertex3f(-100.0, 10.0, 0.0f);
glColor3f(getRGB(44), getRGB(50), getRGB(19));

glVertex3f(-100.0, -40.0, 0.0f);


glColor3f(getRGB(94), getRGB(59), getRGB(22));

glVertex3f(-10.0, -20.0, 0.0f);


glColor3f(getRGB(94), getRGB(59), getRGB(22));

glVertex3f(100.0, -55.0, 0.0f);


glColor3f(getRGB(60), getRGB(50), getRGB(39));

glVertex3f(100.0, 10.0, 0.0f);


glColor3f(getRGB(44), getRGB(50), getRGB(19));

glEnd();
glFlush();
}

void makeMountains() {
//Big Mountains
glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-100.0, 10.0f, 0.0f);
glColor3f(getRGB(219), getRGB(219), getRGB(219));

glVertex3f(-60.0f, 80.0f, 0.0f);


glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-20.0f, 10.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-20.0, 10.0f, 0.0f);
glColor3f(getRGB(219), getRGB(219), getRGB(219));
glVertex3f(20.0, 80.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(60.0, 10.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(60.0, 10.0f, 0.0f);
glColor3f(getRGB(219), getRGB(219), getRGB(219));
glVertex3f(100.0, 80.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(140.0, 10.0, 0.0f);
glEnd();
glFlush();

//Normal Mountains
glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-110.0, 10.0f, 0.0f);
glColor3f(getRGB(189), getRGB(191), getRGB(114));
glVertex3f(-85.0f, 50.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-60.0f, 10.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-60.0, 10.0f, 0.0f);
glColor3f(getRGB(189), getRGB(191), getRGB(114));
glVertex3f(-35.0f, 50.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-10.0f, 10.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));

glVertex3f(-10.0, 10.0f, 0.0f);


glColor3f(getRGB(189), getRGB(191), getRGB(114));
glVertex3f(15.0f, 50.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(40.0f, 10.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(40.0, 10.0f, 0.0f);
glColor3f(getRGB(189), getRGB(191), getRGB(114));
glVertex3f(65.0f, 50.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(90.0f, 10.0, 0.0f);
glEnd();
glFlush();

//Small Mountains
glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-100.0, 10.0f, 0.0f);
glColor3f(getRGB(22), getRGB(130), getRGB(40));
glVertex3f(-65.0f, 30.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(-20.0f, 10.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));

glVertex3f(-20.0, 10.0f, 0.0f);


glColor3f(getRGB(22), getRGB(130), getRGB(40));
glVertex3f(0.0f, 30.0f, 0.0f);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(30.0f, 10.0, 0.0f);
glEnd();
glFlush();

glBegin(GL_TRIANGLES);
glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(30.0, 10.0f, 0.0f);
glColor3f(getRGB(22), getRGB(130), getRGB(40));

glVertex3f(75.0f, 30.0f, 0.0f);


glColor3f(getRGB(71), getRGB(40), getRGB(7));
glVertex3f(120.0f, 10.0, 0.0f);
glEnd();
glFlush();
}

void draw(void) {
glClear(GL_COLOR_BUFFER_BIT);
drawPlane();
}

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


glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("Plane");
configMatrix();
glutDisplayFunc(draw);
glutMainLoop();
return 0;
}
DESARROLLO
CONCLUSIÓN

Con este taller hemos tenido la oportunidad de llevar a cabo una imagen de una pista
de aterrizaje en 2D, el cual se ha tenido el desafíoio de lograr que por medio de figuras
geométricas se le dé forma al dibujo.

Podemos concluir que OpenGl es una herramienta poderosa que tiene mucho
potencial, pero Glut la librería que se utilizó al ser bastante antigua se encuentran
algunos inconvenientes y tiene un uso bastante más rudimentario que otras
herramientas actuales.

Вам также может понравиться