Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <windows.h>
- // moon and colud
- #include <GL/glut.h>
- #include <stdlib.h>
- #include <math.h>
- void init()
- {
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glOrtho(-30, 30, -30, 30, -30, 30);
- }
- void circle(GLfloat rx, GLfloat ry, GLfloat cx, GLfloat cy) // radius_x,radius_y,certre_position_x,centre_position_y
- {
- glBegin(GL_TRIANGLE_FAN);
- glVertex2f(cx, cy);
- for (int i = 0; i <= 100; i++)
- {
- float angle = 2.0f * 3.1416f * i / 100;
- float x = rx * cosf(angle);
- float y = ry * sinf(angle);
- glVertex2f(x + cx, y + cy);
- }
- glEnd();
- }
- void myDisplay()
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1.0f, 1.0f, 1.0f);
- circle(3, 3, 25, 10);
- glColor3f(1.0f, 1.0f, 1.0f);
- circle(3, 3, 23, 10);
- glColor3f(1.0f, 1.0f, 1.0f);
- circle(3, 3, 27, 10);
- glColor3f(1.0f, 1.0f, 1.0f);
- circle(3, 3, 24, 13);
- glColor3f(1.0f, 1.0f, 1.0f);
- circle(3, 3, 25, 14);
- glColor3f(1.0f, 1.0f, 1.0f);
- circle(3, 3, 26, 13);
- glColor3f(1.0f, 1.0f, 0.0f);
- circle(4, 4, 10, 7);
- glFlush();
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(400, 400);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("Circle Application");
- init();
- glutDisplayFunc(myDisplay);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment