Professional Documents
Culture Documents
YINGYANG
YINGYANG
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)
{
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();
}
glutDisplayFunc(Display);
glClearColor(1,1,1,1);
//funcion glut para el manejo de eventos
glutMainLoop();
return EXIT_SUCCESS;
}