You are on page 1of 7

///MARIPOSA PINTADA

//CASTILLO CANTERA MARIA

#include<windows.h>
#include<math.h>
#include <GL/glut.h>
#define PI 3.1415926535898

//float a,b;

void init2D(float r, float g, float b)


{

glClearColor(r,g,b,0.0);

glMatrixMode(GL_PROJECTION);
gluOrtho2D (-8.0,8.0,-8.0,8.0);
}

void Display(void){
glClearColor(1,1,1,0);
glClear(GL_COLOR_BUFFER_BIT);
float x,y,r;
//ALA DERECHA SUPERIOR
//SOMBREADO
glBegin(GL_POLYGON);
glColor3f(0.9,0.2,0.2);

for(float i=0; i<5.5*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();
//BORDE

glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);

for(float i=0; i<5.5*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();
//ALA IZQUIERDA SUPERIOR
//SOMBREADO
glBegin(GL_POLYGON);
glColor3f(0.9,0.2,0.2);

for(float i=17*M_PI/12; i<2*M_PI;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();
//BORDE
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);

for(float i=17*M_PI/12; i<2*M_PI;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();

//ALA DERECHA INFERIOR


//sombreado
glBegin(GL_POLYGON);
glColor3f(1,0.8,0.8);

for(float i=7.2*M_PI/12; i<10.7*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();

//borde
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);
glLineWidth(200.5);

for(float i=7.2*M_PI/12; i<10.7*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();
//ALA IZQUIERDA INFERIOR
//SOMBREADO
glBegin(GL_POLYGON);
glColor3f(1,0.8,0.8);
glLineWidth(200.5);

for(float i=6.67*M_PI/6; i<4.22*M_PI/3;i=i+0.001 ){ //INICIO DE ALA


INFERIOR IZQUIERDA

r=2.011*(exp(cos(i))-(2.011*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();
//BORDE
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);
glLineWidth(200.5);

for(float i=6.67*M_PI/6; i<4.22*M_PI/3;i=i+0.001 ){ //INICIO DE ALA


INFERIOR IZQUIERDA

r=2.011*(exp(cos(i))-(2.011*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

//BRAZITO DERECHO
//SOMBREADO
glBegin(GL_POLYGON);
glColor3f(1,1,0);
glLineWidth(200.5);

for(float i=4.22*M_PI/3; i<19*M_PI/12;i=i+0.001 ){

r=2.011*(exp(cos(i))-(2.011*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();
//BORDE
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);

for(float i=4.22*M_PI/3; i<19*M_PI/12;i=i+0.001 ){


r=2.011*(exp(cos(i))-(2.011*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

//BRAZITO IZQUIERDO

//SOMBREADO
glBegin(GL_POLYGON);
glColor3f(1,1,0);

for(float i=5.15*M_PI/12; i<7.1*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();
//BORDE
glBegin(GL_POINTS);
glColor3f(0,0,0);
glLineWidth(25);

for(float i=5.15*M_PI/12; i<7.1*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

//CABEZA
//SOMBREADO
glBegin(GL_POLYGON);
glColor3f(0.5,0.5,1);
glLineWidth(200.5);

for(float i=10.7*M_PI/12; i<6.67*M_PI/6;i=i+0.001 ){ //INICIO DE ALA


INFERIOR IZQUIERDA

r=2*(exp(cos(i))-(2*cos(4*i)));
x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}
glEnd();
//BORDE
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);
glLineWidth(5);

for(float i=10.7*M_PI/12; i<6.67*M_PI/6;i=i+0.001 ){ //INICIO DE ALA


INFERIOR IZQUIERDA

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

//CABECITA
//SOMBREADO
glBegin(GL_POLYGON);
glColor3f(0.7,0.7,0.7);

for(float i=23.295*M_PI/12; i<2*M_PI;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

for(float i=0; i<0.71*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

//BORDE
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);

for(float i=23.295*M_PI/12; i<2*M_PI;i=i+0.001 ){


r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

for(float i=0; i<0.71*M_PI/12;i=i+0.001 ){

r=2*(exp(cos(i))-(2*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

glBegin(GL_POLYGON);
glColor3f(0.7,0.7,0.7);
glLineWidth(200.5);

for(float i=11.35*M_PI/12; i<6.33*M_PI/6;i=i+0.001 ){ //INICIO DE ALA


INFERIOR IZQUIERDA

r=2.011*(exp(cos(i))-(2.011*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);
glLineWidth(89.5);

for(float i=11.35*M_PI/12; i<6.33*M_PI/6;i=i+0.001 ){ //INICIO DE ALA


INFERIOR IZQUIERDA

r=2.011*(exp(cos(i))-(2.011*cos(4*i)));

x=sin(i)*r;
y=r*cos(i);

glVertex2f(x,y);
}

glEnd();

glFlush();
}
int main (int argc,char** argv)
{
//funcion glut para la inicializacion de la ventana
glutInit(&argc,argv);//inializamos
glutInitDisplayMode(GLUT_SINGLE |GLUT_RGB);
glutInitWindowSize(600,600);// tamanio de la ventana
glutInitWindowPosition(100,100);//posicionde la ventana
glutCreateWindow("Mariposa");// crea la venta con nombre

//funcion glut para el manejo de eventos


glutDisplayFunc(&Display);// evento de renderizado
init2D(1.0,1.0,1.0);
// inicializacion del bucle indefinido de eventos
glutMainLoop();

return EXIT_SUCCESS;
}

You might also like