0% found this document useful (0 votes)
31 views

#Include GLglut.h

The document contains C++ code that defines functions to draw various shapes and scenes using OpenGL for computer graphics. It defines functions to draw the sky, sea, moon, boat and calls these functions to render the full scene. It initializes an OpenGL window of a certain size and specifies the display callback function to render the graphics.

Uploaded by

Paul Jimenez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

#Include GLglut.h

The document contains C++ code that defines functions to draw various shapes and scenes using OpenGL for computer graphics. It defines functions to draw the sky, sea, moon, boat and calls these functions to render the full scene. It initializes an OpenGL window of a certain size and specifies the display callback function to render the graphics.

Uploaded by

Paul Jimenez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <GL/glut.

h>
#include <math.h>
void cielo() {
glBegin(GL_POLYGON);
glColor3ub(253, 40, 6);
glVertex2d(0, 7);
glVertex2d(10, 7);

glColor3ub(248, 202, 155);


glVertex2d(10, 2.2);
glVertex2d(0, 2.2);
glEnd();
}

void mar() {
glBegin(GL_POLYGON);
glColor3ub(242, 40, 6);
glVertex2d(0,2.2);
glVertex2d(10, 2.2);

glColor3ub(5,171,235);
glVertex2d(10, 0);
glVertex2d(0, 0);
glEnd();
}

void luna1() {
float radio = 1.8;
float cx, cy;
glColor3ub(255, 218, 186);
glBegin(GL_POLYGON);
for (double i = 0; i < 3.1416 * 2; i += 0.001) {

cx = radio * cos(i);
cy = radio * sin(i);
glVertex2d(cx + 1.3, cy + 6);

}
glEnd();
}
void luna2() {
float radio = 1.8;
float cx, cy;
glColor3ub(218, 94, 84);
glBegin(GL_POLYGON);
for (double i = 0; i < 3.1416 * 2; i += 0.001) {

cx = radio * cos(i);
cy = radio * sin(i);
glVertex2d(cx + 1.2, cy + 6.1);

}
glEnd();
}

void barco() {
glBegin(GL_POLYGON);
glColor3ub(255, 163, 120);
glVertex2d(4.92,3.08);
glVertex2d(4.43,1.85);
glVertex2d(4.88, 1.53);
glVertex2d(5.46,1.85);

glEnd();

glBegin(GL_POLYGON);
glColor3ub(0, 0, 0);
glVertex2d(3.95,1.54);
glVertex2d(6.84,1.54);
glVertex2d(6.66,1.23);
glVertex2d(4.13,1.23);

glEnd();

glBegin(GL_POLYGON);
glColor3ub(0, 0, 0);
glVertex2d(4.85, 3.22);
glVertex2d(4.91,3.22);
glVertex2d(4.91, 1.54);
glVertex2d(4.85, 1.54);

glEnd();

glBegin(GL_POLYGON);
glColor3ub(0, 0, 0);
glVertex2d(0.16, 2.07);
glVertex2d(3.01, 2.07);
glVertex2d(2.87, 1.77);
glVertex2d(0.32, 1.77);

glEnd();

glBegin(GL_POLYGON);
glColor3ub(255, 185, 0);
glVertex2d(0.68, 2.35);
glVertex2d(1.08, 3.58);
glVertex2d(1.44, 2.83);
glVertex2d(1.06, 2.05);

glEnd();

glBegin(GL_POLYGON);
glColor3ub(0, 0, 0);
glVertex2d(1.02, 3.74);
glVertex2d(1.08, 3.74);
glVertex2d(1.08, 2.0);
glVertex2d(1.02, 2.0);

glEnd();
}

void dibujar() {

glLoadIdentity();
gluOrtho2D(0, 10, 0, 7);
glClear(GL_COLOR_BUFFER_BIT);

cielo();
mar();
luna1();
luna2();
barco();

glEnd();

//Lineas
/*glBegin(GL_LINE_LOOP);
glColor3ub(2323, 255, 6);
glVertex2d(2, 2);
glVertex2d(6, 6);

glVertex2d(8,3);
glVertex2d(9,9);

glVertex2d(9, 1);

glEnd();*/

/*glBegin(GL_POLYGON);
glColor3ub(232, 255, 6);
glVertex2d(2, 7);
glVertex2d(8,7);

glColor3ub(255,6,247);
glVertex2d(8,4.5);
glVertex2d(2, 4.5);

glEnd();

glBegin(GL_POLYGON);
glColor3ub(255, 6, 247);
glVertex2d(2, 4.5);
glVertex2d(8, 4.5);

glColor3ub(255, 0,0);
glVertex2d(8,2);
glVertex2d(2,2);

glEnd();*/

//Generar puntos
/*glPointSize(10);
glBegin(GL_POINTS);
glColor3ub(255, 255, 0);
glVertex2d(5, 5);

glColor3ub(255, 116, 181);


glVertex2d(7, 7);

glColor3ub(255, 163, 3);


glVertex2d(3, 7);

glColor3ub(69, 255, 9);


glVertex2d(3,3);

glColor3ub(9, 199, 255);


glVertex2d(7,3);

glEnd();*/

glFlush();

}
int main(int argc, char* argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(1100, 779);
glutInitWindowPosition(0, 0);
glutCreateWindow("computacion grafica");
glutDisplayFunc(dibujar);

glutMainLoop();

return 0;
}

You might also like