#include<GL/glut.h>
#include<math.h>
#define PI 3.1415926535898
GLint circle_points=100;
float rd=0.2;
float m,n,k=0.5;
int i;
void display(){
glClear(GL_COLOR_BUFFER_BIT);
for(i=0;i<8;i++){
glPushMatrix();
glTranslatef(-0.5,n,0);
glColor3f(0,1.0,0.0);
glBegin(GL_LINE_LOOP);
int i;
float angle;
glColor3f(1.0,0.0,0.0);
for(i=0;i<circle_points;i++)
{
angle=2*PI*i/circle_points;
glVertex2f((cos(angle)*rd),(sin(angle)*rd));
}
glEnd();
glFlush();
glPopMatrix();
n=n+0.02;
glPushMatrix();
glTranslatef(k,m,0);
glBegin(GL_LINE_LOOP);
glVertex2f(-0.2,0.2);
glVertex2f(0.2,0.2);
glVertex2f(0.2,-0.2);
glVertex2f(-0.2,-0.2);
glEnd();
glFlush();
glPopMatrix();
m=m+0.02;
k=k+0.01;
}
}
void initGL()
{
glClearColor(1,1,1,1);
glColor3f(1,0,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1,1,-1,1,-1,1);
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(50, 50);
glutCreateWindow("circle");
glutDisplayFunc(display);
initGL();
glutMainLoop();
return 0;
}
#include<math.h>
#define PI 3.1415926535898
GLint circle_points=100;
float rd=0.2;
float m,n,k=0.5;
int i;
void display(){
glClear(GL_COLOR_BUFFER_BIT);
for(i=0;i<8;i++){
glPushMatrix();
glTranslatef(-0.5,n,0);
glColor3f(0,1.0,0.0);
glBegin(GL_LINE_LOOP);
int i;
float angle;
glColor3f(1.0,0.0,0.0);
for(i=0;i<circle_points;i++)
{
angle=2*PI*i/circle_points;
glVertex2f((cos(angle)*rd),(sin(angle)*rd));
}
glEnd();
glFlush();
glPopMatrix();
n=n+0.02;
glPushMatrix();
glTranslatef(k,m,0);
glBegin(GL_LINE_LOOP);
glVertex2f(-0.2,0.2);
glVertex2f(0.2,0.2);
glVertex2f(0.2,-0.2);
glVertex2f(-0.2,-0.2);
glEnd();
glFlush();
glPopMatrix();
m=m+0.02;
k=k+0.01;
}
}
void initGL()
{
glClearColor(1,1,1,1);
glColor3f(1,0,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1,1,-1,1,-1,1);
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(50, 50);
glutCreateWindow("circle");
glutDisplayFunc(display);
initGL();
glutMainLoop();
return 0;
}
No comments:
Post a Comment