Sajib_Ahmed

Untitled

Dec 14th, 2021
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <windows.h>
  2. #include <GL/glut.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5.  
  6. void init()
  7. {
  8.     glClearColor(0.0f,128.0f,0.0f,0.0f);
  9.     glOrtho(-15,15,-15,15,-15,5);
  10. }
  11.  
  12. void circle(GLfloat rx,GLfloat ry,GLfloat cx,GLfloat cy)
  13. {
  14.  
  15.  glBegin(GL_TRIANGLE_FAN);
  16.  glVertex2f(cx,cy);
  17.  
  18.  for(int i=0;i<=100;i++)
  19.  {
  20.     float angle= 2.0f *3.1416f*i/100;
  21.     float x = rx *cosf(angle);
  22.     float y = ry * sinf(angle);
  23.     glVertex2f((x+cx),(y+cy));
  24.  
  25.  }
  26.  glEnd();
  27. }
  28.  
  29. void myDisplay()
  30. {
  31.  
  32.     glClear(GL_COLOR_BUFFER_BIT);
  33.     glColor3f(255.0f,0.0f,0.0f);
  34.     circle(3,3,0,0);
  35.     glFlush();
  36.  
  37. }
  38. int main()
  39. {
  40.  
  41.    glutInitDisplayMode(GLUT_SINGLE | GLUT_RED) ;
  42.    glutInitWindowSize(600,600);
  43.    glutInitWindowPosition(200,200);
  44.    glutCreateWindow("Lab Task Circle");
  45.    init();
  46.    glutDisplayFunc(myDisplay);
  47.    glutMainLoop();
  48.    return 0;
  49.  
  50.  
  51.  
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment