You are on page 1of 3

#include <windows.

h>
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
#define M_PI 3.141516
void Circunferencia( float *XY, float R, float *rgb, int M, float T){
glColor3fv(rgb);
switch (M) {
case 2: {
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
glPointSize(T); break;
}
case 3:{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(T);
break;
}
default:{glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
}
//glColor3f(0,0,1);
glBegin(GL_POLYGON);
for (float i = 0; i <= 2*M_PI ; i = i + 0.05){
glVertex2f(R*cos(i) + XY[0], R*sin(i) + XY[1]);

}
glEnd();
}

void Circunferencia2( float *XY, float R, float *rgb, int M, float T){
glColor3fv(rgb);
switch (M) {
case 2: {
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
glPointSize(T); break;
}
case 3:{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(T);
break;
}
default:{glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
}
glColor3f(1,1,1);
glBegin(GL_POLYGON);
for (float i = M_PI/2; i <= 3*M_PI/2 ; i = i + 0.05)
glVertex2f(R*cos(i) + XY[0], R*sin(i) + XY[1]);
glEnd();
}

void Circunferencia3( float *XY, float R, float *rgb, int M, float T){
glColor3fv(rgb);
switch (M) {
case 2: {
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
glPointSize(T); break;
}
case 3:{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(T);
break;
}
default:{glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
}
glColor3f(0,0,0);
glBegin(GL_POLYGON);
for (float i = M_PI/2; i <= 3*M_PI/2 ; i = i + 0.05)
glVertex2f(R*cos(i) + XY[0], R*sin(i) + XY[1]);
glEnd();
}

void Circunferencia4( float *XY, float R, float *rgb, int M, float T){
glColor3fv(rgb);
switch (M) {
case 2: {
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
glPointSize(T); break;
}
case 3:{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(T);
break;
}
default:{glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
}
glColor3f(1,1,1);
glBegin(GL_POLYGON);
for (float i = 0; i <= 2*M_PI ; i = i + 0.05){
glVertex2f(R*cos(i) + XY[0], R*sin(i) + XY[1]);

}
glEnd();
}

void Display(void)
{

glClearColor(0,1,1,0);//color el cual se limpia la ventana


glClear(GL_COLOR_BUFFER_BIT);
float black[]={0,0,0};
float C[]={0.0,0.0};
Circunferencia(C,0.6, black, 4, 1);
float C1[]={0,0};
float white[]={0,0,0};
Circunferencia2(C1,0.6,white,4,1);
float C2[]={0,-0.3};
float white1[]={0,0,0};
Circunferencia3(C2,0.3,white1,4,1);
float C3[]={0,0.3};
Circunferencia4(C3,0.3,white1,4,1);

float C4[]={0,-0.3};
Circunferencia4(C4,0.1,white1,4,1);
float C5[]={0,0.3};
Circunferencia(C5,0.1,white1,4,1);

glFlush();
}

int main(int argc, char *argv[])


{
glutInit(&argc, argv);
glutInitWindowSize(900,900);
glutInitWindowPosition(10,10);
glutCreateWindow("Homero");

glutDisplayFunc(Display);
glClearColor(1,1,1,1);
//funcion glut para el manejo de eventos
glutMainLoop();

return EXIT_SUCCESS;
}

You might also like