TAREA 3: PRIMITIVAS 2D
POR: Juan Angel Ortiz Contreras
YIN-YANG
/*JUAN ANGEL ORTIZ CONTRERAS*/#include <windows.h>
#include <C:\GLUT\include\GL\glut.h>
#include <stdlib.h>
#include <math.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
int y=0;
int x=0;
glPointSize(5);
glColor3f(0.0,0.0,0.0);
//CIRCULO PRINCIPAL
glBegin(GL_POINTS);
for(int i=0; i < 360; i =i + 1)
{
x = 400*cos(i);
y = 400*sin(i);
glVertex2i(x,y);
}
glEnd();
double radio = 200;
//CIRCULO NEGRO
glBegin(GL_POINTS);
while(radio >= 80)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)-10;
y = radio*sin(i) - 200;
glVertex2i(x,y);
}
radio = radio-10;
}
glEnd();
radio = 200;
glBegin(GL_POINTS);
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)+75;
y = radio*sin(i) - 184;
glVertex2i(x,y);
}
radio = radio-10;
}
glEnd();
radio = 200;
glBegin(GL_POINTS);
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)+160;
y = radio*sin(i) - 128;
glVertex2i(x,y);
}
radio = radio-10;
}
glEnd();
radio = 200;
glBegin(GL_POINTS);
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)+ 200;
y = radio*sin(i) - 27;
glVertex2i(x,y);
}
radio = radio-10;
}
glEnd();
radio = 200;
glBegin(GL_POINTS);
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)+ 190;
y = radio*sin(i) + 60;
glVertex2i(x,y);
}
radio = radio-10;
}
glEnd();
radio = 200;
glBegin(GL_POINTS);
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)+ 160;
y = radio*sin(i) + 120;
glVertex2i(x,y);
}
radio = radio-10;
}
glEnd();
radio = 200;
glBegin(GL_POINTS);
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)+ 100;
y = radio*sin(i) + 175;
glVertex2i(x,y);
}
radio = radio-10;
}
glEnd();
//CIRCULO BLANCO
glPointSize(2);
glColor3f(255.0,255.0,255.0);
glBegin(GL_POINTS);
radio = 200;
while(radio >= 80)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)+10;
y = radio*sin(i) + 198;
glVertex2i(x,y);
}
radio = radio-1;
}
glEnd();
//CIRCULITO BLANCO
glPointSize(5);
glColor3f(255.0,255.0,255.0);
glBegin(GL_POINTS);
radio = 0;
while(radio <= 80)
{
for(int i=0; i < 360; i =i + 1)
{
x = radio*cos(i)-10;
y = radio*sin(i) - 200;
glVertex2i(x,y);
}
radio = radio+ 10;
}
glEnd();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
//glutInitDisplayMode(GLUTH_SINGLE|GLUT_RGB);
glutInitWindowSize(700,700);
glutInitWindowPosition(10,50);
glutCreateWindow("YIN-YANG");
glClearColor(255.0,255.0,255.0,0);
gluOrtho2D(-700,700,-700,700); // medida de la pantalla en X va de -640,640 y Y 0 a 480
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
DOMINOS
/*JUAN ANGEL ORTIZ CONTRERAS */
#include <windows.h>
#include <C:\GLUT\include\GL\glut.h>
#include <stdlib.h>
#include <math.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
int x,y;
glPointSize(10);
glColor3f(0.0,0.0,255.0);
//azul
glBegin(GL_TRIANGLE_STRIP);
x =1;
y = 150;
glVertex2i(x,y);
x =150;
y = 1;
glVertex2i(x,y);
x =300;
y =150;
glVertex2i(x,y);
x =150;
y =300;
glVertex2i(x,y);
x =1;
y = 150;
glVertex2i(x,y);
glEnd();
//CIRCULO AZUL
int a=0;
int b=0;
glPointSize(5);
glColor3f(255.0,255.0,255.0);
glBegin(GL_POINTS);
double radio = 35;
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
a = radio*cos(i)+80;
b = radio*sin(i)+150;
glVertex2i(a,b);
}
radio = radio - 1;
}
glBegin(GL_POINTS);
radio = 35;
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
a = radio*cos(i)+ 220;
b = radio*sin(i)+150;
glVertex2i(a,b);
}
radio = radio - 1;
}
glEnd();
//RECTANGULO ROJO
glPointSize(10);
glColor3f(210.0,0.0,0.0);
glBegin(GL_TRIANGLE_STRIP);
x =325;
y =175;
glVertex2i(x,y);
x =474;
y =324;
glVertex2i(x,y);
x =324;
y =474;
glVertex2i(x,y);
x =175;
y =325;
glVertex2i(x,y);
x =325;
y =175;
glVertex2i(x,y);
glEnd();
//CIRCULO ROJO
a=0;
b=0;
glPointSize(5);
glColor3f(255.0,255.0,255.0);
glBegin(GL_POINTS);
radio = 35;
while(radio >= 0)
{
for(int i=0; i < 360; i =i + 1)
{
a = radio*cos(i)+ 324;
b = radio*sin(i)+ 324;
glVertex2i(a,b);
}
radio = radio - 1;
}
glEnd();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
//glutInitDisplayMode(GLUTH_SINGLE|GLUT_RGB);
glutInitWindowSize(700,700);
glutInitWindowPosition(10,50);
glutCreateWindow("Dominos");
glClearColor(255.0,255.0,255.0,0);
gluOrtho2D(0,700,0,700); // medida de la pantalla en X va de -640,640 y Y 0 a 480
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
MITSUBISHI
/* JUAN ANGEL ORTIZ CONTRERAS */
#include <windows.h>
#include <C:\GLUT\include\GL\glut.h>
#include <stdlib.h>
#include <math.h>
float pi = 3.14159265;
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
int y=0;
int x=0;
glPointSize(5);
glColor3f(210.0,0.0,0.0);
glBegin(GL_TRIANGLE_STRIP);
x =1;
y = 1;
glVertex2i(x,y);
x =5;
y = 1;
glVertex2i(x,y);
x =7;
y = 4;
glVertex2i(x,y);
x =3;
y = 4;
glVertex2i(x,y);
x =1;
y = 1;
glVertex2i(x,y);
glEnd();
glBegin(GL_TRIANGLE_STRIP);
x =9;
y = 1;
glVertex2i(x,y);
x =13;
y = 1;
glVertex2i(x,y);
x =11;
y = 4;
glVertex2i(x,y);
x =7;
y = 4;
glVertex2i(x,y);
x =9;
y = 1;
glVertex2i(x,y);
glEnd();
glBegin(GL_TRIANGLE_STRIP);
x =7;
y = 4;
glVertex2i(x,y);
x =9;
y = 7;
glVertex2i(x,y);
x =7;
y = 10;
glVertex2i(x,y);
x =5;
y = 7;
glVertex2i(x,y);
x =7;
y = 4;
glVertex2i(x,y);
glEnd();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
//glutInitDisplayMode(GLUTH_SINGLE|GLUT_RGB);
glutInitWindowSize(600,600);
glutInitWindowPosition(10,50);
glutCreateWindow("Mi primera venatana");
glClearColor(255.0,255.0,255.0,0);
gluOrtho2D(0,14,0,14); // medida de la pantalla en X va de -640,640 y Y 0 a 480
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
No hay comentarios:
Publicar un comentario