PRACTICA 1: SOL
/*------------JOSUÉ HERNÁNDEZ ATONAL-------*/
#include<windows.h>
#include<C:\GLUT\include\GL\glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.141592653
float cx=375,cy=375,radio=75,radio1=30,dx,dy;
float ax=300,ay=280,bx=355,by=280,ex=400,ey=280;
float fx=320,fy=292,gx=375,gy=292;
float hx=350,hy=303;
float sc=1;
int ancho=720,alto=710;
int px=0,py=0;
void dibujarSOL(void){
///////////////////////////////////////////////////------SOL----------
glPushMatrix();
glPushMatrix();
glColor3f(0.90,0.75,0.0);
glBegin(GL_QUADS);
glVertex2i(300,300);glVertex2i(450,300);
glVertex2i(450,450);glVertex2i(300,450);
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.86,0.75,0.0);
glBegin(GL_QUADS);
glVertex2i(375,269);glVertex2i(481,375);//P4
glVertex2i(375,481);glVertex2i(269,375);//P3
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.90,0.80,0.0);
glBegin(GL_POLYGON);
for (float i=0; i<2*PI+0.01; i+=0.01)
{
dx=radio*cos(i)+cx;
dy=radio*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
/////////////////////////////////////////////////////
////////////////////////////////////-----NUBE----
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+ax;
dy=radio1*sin(i)+ay;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+bx;
dy=radio1*sin(i)+by;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+ex;
dy=radio1*sin(i)+ey;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+fx;
dy=radio1*sin(i)+fy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+gx;
dy=radio1*sin(i)+gy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+hx;
dy=radio1*sin(i)+hy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef(px, py, 0);
glScalef(sc,sc, 1);
dibujarSOL();
glFlush();
glPopMatrix();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(ancho,alto);
glutCreateWindow("TRANSF-MOUSE-TECLADO");
glClearColor(0.10,0.70,0.65,0);
gluOrtho2D(0,ancho,0,alto);
glPointSize(5);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

#include<windows.h>
#include<C:\GLUT\include\GL\glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.141592653
float cx=375,cy=375,radio=75,radio1=30,dx,dy;
float ax=300,ay=280,bx=355,by=280,ex=400,ey=280;
float fx=320,fy=292,gx=375,gy=292;
float hx=350,hy=303;
float sc=1;
int ancho=720,alto=710;
int px=0,py=0;
void dibujarSOL(void){
///////////////////////////////////////////////////------SOL----------
glPushMatrix();
glPushMatrix();
glColor3f(0.90,0.75,0.0);
glBegin(GL_QUADS);
glVertex2i(300,300);glVertex2i(450,300);
glVertex2i(450,450);glVertex2i(300,450);
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.86,0.75,0.0);
glBegin(GL_QUADS);
glVertex2i(375,269);glVertex2i(481,375);//P4
glVertex2i(375,481);glVertex2i(269,375);//P3
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.90,0.80,0.0);
glBegin(GL_POLYGON);
for (float i=0; i<2*PI+0.01; i+=0.01)
{
dx=radio*cos(i)+cx;
dy=radio*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
/////////////////////////////////////////////////////
////////////////////////////////////-----NUBE----
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+ax;
dy=radio1*sin(i)+ay;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+bx;
dy=radio1*sin(i)+by;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+ex;
dy=radio1*sin(i)+ey;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+fx;
dy=radio1*sin(i)+fy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+gx;
dy=radio1*sin(i)+gy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radio1*cos(i)+hx;
dy=radio1*sin(i)+hy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glTranslatef(px, py, 0);
glScalef(sc,sc, 1);
dibujarSOL();
glFlush();
glPopMatrix();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(ancho,alto);
glutCreateWindow("TRANSF-MOUSE-TECLADO");
glClearColor(0.10,0.70,0.65,0);
gluOrtho2D(0,ancho,0,alto);
glPointSize(5);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

Comentarios
Publicar un comentario