imtiazaasif

MoonAndCloud using glut

Jun 9th, 2022
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. //#include <windows.h>
  2. // moon and colud
  3.  
  4. #include <GL/glut.h>
  5. #include <stdlib.h>
  6. #include <math.h>
  7.  
  8. void init()
  9. {
  10.     glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  11.     glOrtho(-30, 30, -30, 30, -30, 30);
  12. }
  13. void circle(GLfloat rx, GLfloat ry, GLfloat cx, GLfloat cy) // radius_x,radius_y,certre_position_x,centre_position_y
  14. {
  15.  
  16.     glBegin(GL_TRIANGLE_FAN);
  17.     glVertex2f(cx, cy);
  18.  
  19.     for (int i = 0; i <= 100; i++)
  20.  
  21.     {
  22.         float angle = 2.0f * 3.1416f * i / 100;
  23.  
  24.         float x = rx * cosf(angle);
  25.         float y = ry * sinf(angle);
  26.  
  27.         glVertex2f(x + cx, y + cy);
  28.     }
  29.     glEnd();
  30. }
  31.  
  32. void myDisplay()
  33. {
  34.     glClear(GL_COLOR_BUFFER_BIT);
  35.  
  36.     glColor3f(1.0f, 1.0f, 1.0f);
  37.     circle(3, 3, 25, 10);
  38.  
  39.     glColor3f(1.0f, 1.0f, 1.0f);
  40.     circle(3, 3, 23, 10);
  41.  
  42.     glColor3f(1.0f, 1.0f, 1.0f);
  43.     circle(3, 3, 27, 10);
  44.  
  45.     glColor3f(1.0f, 1.0f, 1.0f);
  46.     circle(3, 3, 24, 13);
  47.  
  48.     glColor3f(1.0f, 1.0f, 1.0f);
  49.     circle(3, 3, 25, 14);
  50.  
  51.     glColor3f(1.0f, 1.0f, 1.0f);
  52.     circle(3, 3, 26, 13);
  53.  
  54.     glColor3f(1.0f, 1.0f, 0.0f);
  55.     circle(4, 4, 10, 7);
  56.  
  57.     glFlush();
  58. }
  59. int main(int argc, char **argv)
  60. {
  61.     glutInit(&argc, argv);
  62.     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  63.     glutInitWindowSize(400, 400);
  64.     glutInitWindowPosition(100, 100);
  65.     glutCreateWindow("Circle Application");
  66.     init();
  67.     glutDisplayFunc(myDisplay);
  68.     glutMainLoop();
  69.     return 0;
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment