PRACTICA 2: EJERCICIO 1
//-----------------EJERCICIO 1------------------// //---ÓMEX---//
#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=363,cy=337,radio=75,radio2=45,radio3=60,radior=44.99,dx,dy;
float sc=1,ex=382;
int ancho=610,alto=610;
void dibujarSIMBOLO(void){
glPushMatrix();
glColor3f(0.90,0.75,0.15);
glBegin(GL_QUADS);
glVertex2i(220,255);glVertex2i(510,365);//P4
glVertex2i(375,495);glVertex2i(220,330);//P3
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.95,0.0,0.10);
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();
glPushMatrix();
glColor3f(0.95,0.0,0.25);
glBegin(GL_POLYGON);
for (float i=0; i<2*PI+0.01; i+=0.01)
{
dx=radio3*cos(i)+cx;
dy=radio3*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glBegin(GL_QUADS);
glVertex2i(330,358);glVertex2i(345,435);
glVertex2i(365,445);glVertex2i(385,480);
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<2*PI+0.01; i+=0.01)
{
dx=radio2*cos(i)+cx;
dy=radio2*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.90,0.75,0.20);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radior*cos(i)+cx;
dy=radior*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScalef(sc,sc, 1);
dibujarSIMBOLO();
glFlush();
glPopMatrix();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(ancho,alto);
glutCreateWindow("PRACTICA1");
glClearColor(1.0,1.0,1.0,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=363,cy=337,radio=75,radio2=45,radio3=60,radior=44.99,dx,dy;
float sc=1,ex=382;
int ancho=610,alto=610;
void dibujarSIMBOLO(void){
glPushMatrix();
glColor3f(0.90,0.75,0.15);
glBegin(GL_QUADS);
glVertex2i(220,255);glVertex2i(510,365);//P4
glVertex2i(375,495);glVertex2i(220,330);//P3
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.95,0.0,0.10);
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();
glPushMatrix();
glColor3f(0.95,0.0,0.25);
glBegin(GL_POLYGON);
for (float i=0; i<2*PI+0.01; i+=0.01)
{
dx=radio3*cos(i)+cx;
dy=radio3*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glPushMatrix();
glColor3f(0.0,0.0,0.0);
glBegin(GL_QUADS);
glVertex2i(330,358);glVertex2i(345,435);
glVertex2i(365,445);glVertex2i(385,480);
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
for (float i=0; i<2*PI+0.01; i+=0.01)
{
dx=radio2*cos(i)+cx;
dy=radio2*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
glPushMatrix();
glColor3f(0.90,0.75,0.20);
glBegin(GL_POLYGON);
for (float i=0; i<PI+0.01; i+=0.01)
{
dx=radior*cos(i)+cx;
dy=radior*sin(i)+cy;
glVertex2f(dx, dy);
}
glEnd();
glPopMatrix();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScalef(sc,sc, 1);
dibujarSIMBOLO();
glFlush();
glPopMatrix();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(ancho,alto);
glutCreateWindow("PRACTICA1");
glClearColor(1.0,1.0,1.0,0);
gluOrtho2D(0,ancho,0,alto);
glPointSize(5);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

Comentarios
Publicar un comentario