Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #define GLUT_DISABLE_ATEXIT_HACK
  2. #include <windows.h>
  3. #include <gl/glut.h>
  4. #include <math.h>
  5. #define PI 3.14159
  6. #define circlePoints 64
  7. int i;
  8. void display()
  9. {
  10.     GLfloat angleStep=2*PI/(float)circlePoints;
  11.     //Gluint pointPerQuarter=circlePoints/4;
  12.     GLfloat x[circlePoints];
  13.     GLfloat y[circlePoints];
  14.     GLfloat radius=10;
  15.     glClearColor(0,0,0,0);
  16.     glClear(GL_COLOR_BUFFER_BIT);
  17.     glColor3f(1,1,1);
  18.     glLineWidth(10);
  19.     for(i=0;i<circlePoints;i++)
  20.     {
  21.         //Define points in first quadrant
  22.         x[i]=5+radius*cos(i*angleStep);
  23.         y[i]=-5+radius*sin(i*angleStep);
  24.     }
  25.     glBegin(GL_LINE_LOOP);
  26.     for (i=0;i<circlePoints;i++)
  27.     {
  28.         glVertex2f(x[i],y[i]);
  29.     }
  30.     glEnd();
  31.     glFlush();
  32. }
  33.  
  34. int main(int argc, char** argv)
  35. {
  36.     glutInit(&argc,argv);
  37.     glutInitWindowPosition(50,50);
  38.     glutInitWindowSize(640,480);
  39.     glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
  40.     glutCreateWindow("Circle Drawing");
  41.     glMatrixMode(GL_PROJECTION);
  42.     gluOrtho2D(-32,32,-24,24);
  43.     glutDisplayFunc(display);
  44.     glutMainLoop();
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement