document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <GL/glut.h>
  4. #include<windows.h>
  5. #include <cmath>
  6. using namespace std;
  7.  
  8. void iniciarPantalla(){
  9.     glClearColor(0.392157,1 /*0.584314*/,0.929412,0.0);//(rojo,verde,azul)
  10.     glMatrixMode(GL_PROJECTION);
  11.     gluOrtho2D(0.0,200.0,0.0,150.0);//proyeccion ortogonal en 2 dimensiones
  12. }
  13.  
  14. void rectangulos(int x0,int y0,int x1,int y1,int x2, int y2,int x3, int y3, float R,float G,float B)
  15. {
  16.     glColor3f(R,G,B);
  17.     glBegin(GL_QUADS);
  18.     glVertex2f(x0, y0);
  19.     glVertex2f(x1,y1);
  20.     glVertex2f(x2,y2);
  21.     glVertex2f(x3,y3);
  22.     glEnd();
  23. }
  24.  
  25. void piso()
  26. {
  27.     rectangulos(0,40,0,0,200,0,200,40,0.07421875,0.94140625,0.35546875); //superficie verde
  28. }
  29.  
  30. void triangulos(int x0,int y0,int x1,int y1,int x2, int y2,float R,float G,float B)
  31. {
  32.     glColor3f(R,G,B);
  33.     glBegin(GL_TRIANGLES);
  34.     glVertex2f(x0, y0);
  35.     glVertex2f(x1,y1);
  36.     glVertex2f(x2,y2);
  37.     glEnd();
  38. }
  39.  
  40. void arbol()
  41. {
  42.     float R, G, B;
  43.     R=0.870588;
  44.     G=0.721569;
  45.     B=0.529412;
  46.     rectangulos(114,60,114,40,116,40,116,60,R,G,B); //tallo
  47.     glBegin(GL_POLYGON); //octagono
  48.     glColor3f(0,1,0);
  49.     glVertex2f(115, 68);
  50.     glVertex2f(112,67);
  51.     glVertex2f(111,64);
  52.     glVertex2f(112, 61);
  53.     glVertex2f(115,60);
  54.     glVertex2f(118,61);
  55.     glVertex2f(119, 64);
  56.     glVertex2f(118,67);
  57.     glEnd();
  58. }
  59. void sol()
  60. {
  61.     glBegin(GL_POLYGON);
  62.     for(int i=0;i<360;i=i+45)
  63.     {
  64.         glColor3f(1,0.843137, 0);
  65.         float degInRad=i*3.14159265/180;
  66.         glVertex2f((cos(degInRad)*12)+180,(sin(degInRad)*12)+130);
  67.     }
  68.     glEnd();
  69.     glBegin(GL_POLYGON);
  70.  for(int i=0;i<360;i++)
  71.  {
  72.      glColor3f(1,1,0);
  73.      float degInRad=i*3.14159265/180;
  74.      glVertex2f((cos(degInRad)*10)+180,(sin(degInRad)*10)+130);
  75.  }
  76.  glEnd();
  77.  
  78.  
  79.  
  80. }
  81. void nubes(){
  82.     glBegin(GL_POLYGON);
  83.     int j=30;
  84.     while(j<=40){
  85.             for(int i=0;i<360;i++)
  86.             {
  87.                 glColor3f(0.941176,0.972549,1);
  88.                 float degInRad=i*3.14159265/180;
  89.                 glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+130);
  90.             }
  91.     j=j+5;
  92.  
  93.         }
  94.     j=30;
  95.     while(j<=40){
  96.         for(int i=0;i<360;i++)
  97.         {
  98.             glColor3f(0.941176,0.972549,1);
  99.             float degInRad=i*3.14159265/180;
  100.             glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+125);
  101.         }
  102.         j=j+5;
  103.  
  104.     }
  105.     glEnd();
  106.     glBegin(GL_POLYGON);
  107.     j=60;
  108.     while(j<=70){
  109.         for(int i=0;i<360;i++)
  110.         {
  111.             glColor3f(0.941176,0.972549,1);
  112.             float degInRad=i*3.14159265/180;
  113.             glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+130);
  114.         }
  115.         j=j+5;
  116.  
  117.     }
  118.     j=60;
  119.     while(j<=70){
  120.         for(int i=0;i<360;i++)
  121.         {
  122.             glColor3f(0.941176,0.972549,1);
  123.             float degInRad=i*3.14159265/180;
  124.             glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+125);
  125.         }
  126.         j=j+5;
  127.  
  128.     }
  129.     glEnd();
  130.     glBegin(GL_POLYGON);
  131.     j=90;
  132.     while(j<=100){
  133.         for(int i=0;i<360;i++)
  134.         {
  135.             glColor3f(0.941176,0.972549,1);
  136.             float degInRad=i*3.14159265/180;
  137.             glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+130);
  138.         }
  139.         j=j+5;
  140.  
  141.     }
  142.     j=90;
  143.     while(j<=100){
  144.         for(int i=0;i<360;i++)
  145.         {
  146.             glColor3f(0.941176,0.972549,1);
  147.             float degInRad=i*3.14159265/180;
  148.             glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+125);
  149.         }
  150.         j=j+5;
  151.  
  152.     }
  153.     glEnd();
  154.     j=120;
  155.     while(j<=130){
  156.         for(int i=0;i<360;i++)
  157.         {
  158.             glColor3f(0.941176,0.972549,1);
  159.             float degInRad=i*3.14159265/180;
  160.             glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+130);
  161.         }
  162.         j=j+5;
  163.  
  164.     }
  165.     j=120;
  166.     while(j<=130){
  167.         for(int i=0;i<360;i++)
  168.         {
  169.             glColor3f(0.941176,0.972549,1);
  170.             float degInRad=i*3.14159265/180;
  171.             glVertex2f((cos(degInRad)*5)+j,(sin(degInRad)*5)+125);
  172.         }
  173.         j=j+5;
  174.  
  175.     }
  176.     glEnd();
  177. }
  178.  
  179. void cerros()
  180. {
  181.     float R, G, B;
  182.     R=0.870588;
  183.     G=0.721569;
  184.     B=0.529412;
  185.     triangulos(30,0,50,80,70,0,R,G,B); //segundo cerro
  186.     triangulos(60,0,80,80,100,0,R,G,B); //tercer cerro
  187.     triangulos(0,0,20,80,40,0,R,G,B); //primercerro
  188.  
  189.     triangulos(15,60,20,80,25,60,1,1,1); //primer
  190.     triangulos(45,60,50,80,55,60,1,1,1); //segund
  191.     triangulos(75,60,80,80,85,60,1,1,1); //tercero
  192. }
  193.  
  194.  
  195. void dibujarlinea(int x0,int y0,int xfin,int yfin,float R,float G,float B){
  196.     glColor3f(R,G,B);
  197.     glBegin(GL_LINES);
  198.     glVertex2i(x0,y0);
  199.     glVertex2i(xfin,yfin);
  200.     glEnd();
  201. }
  202.  
  203. void Casita(){
  204.     rectangulos(140,60,140,40,160,40,160,60,1.0,0.980392,0.803922);
  205.     triangulos(140,60,150,70,160,60,1,1,1);
  206.     triangulos(160,60,150,70,160,70,0.862745,0.0784314,0.235294);
  207.     rectangulos(160,60,160,40,190,40,190,60,1.0,0.980392,0.803922);
  208.     rectangulos(160,70,160,60,180,60,180,70,0.862745,0.0784314,0.235294);
  209.     triangulos(180,60,180,70,190,60,0.862745,0.0784314,0.235294);
  210.     rectangulos(145,50,145,40,155,40,155,50,0.545098,0.270588,0.0745098);
  211.     rectangulos(165,55,165,45,185,45,185,55,0.545098,0.270588,0.0745098);
  212.  
  213. }
  214.  
  215. void camino(){
  216.     rectangulos(145,38,110,0,120,0,155,38,1,0.843137,0);
  217. }
  218.  
  219. void Plantitas(){
  220.     float R,G,B;
  221.     R=0.0;
  222.     G=0.2941176470588235;
  223.     B=0.0;
  224.     int i=0,a=10;
  225.     int b=10;
  226.     int cont=0;
  227.     while(cont<3){
  228.         while(a<200)
  229.         {
  230.             dibujarlinea(a,i-2.5,a,i+2.5,R,G,B);
  231.             dibujarlinea(a,i-1.5,a-2.5,i+1,R,G,B);
  232.             dibujarlinea(a,i-1.5,a+3,i+1,R,G,B);
  233.             dibujarlinea(a,i,a-2.5,i+3,R,G,B);
  234.             dibujarlinea(a,i,a+3,i+3,R,G,B);
  235.             a=a+6;
  236.         }
  237.         a=b;
  238.         i=i+5;
  239.         cont++;
  240.     }
  241. }
  242.  
  243. void FondoDeEscritorio(){
  244.     glClear(GL_COLOR_BUFFER_BIT);//ya pone el color de fondo en la pantalla
  245.     glColor3f(1.0,0.0,0.0);//(rojo,verde,azul)
  246.     piso();
  247.     cerros();
  248.     camino();
  249.     Plantitas();
  250.     Casita();
  251.     arbol();
  252.     sol();
  253.     nubes();
  254.     glFlush();
  255. }
  256.  
  257. int main(int argc, char *argv[])
  258. {
  259.  
  260.     glutInit(&argc,argv);
  261.     glutInitWindowPosition(0,0);
  262.     glutInitWindowSize(600,500);
  263.     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  264.     glutCreateWindow("Nuestro Primer Programa");
  265.     iniciarPantalla();
  266.     glutDisplayFunc(FondoDeEscritorio);
  267.     glutMainLoop();
  268.    }
');