Guest User

Untitled

a guest
Jun 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <GL/gl.h>
  2. #include <GL/glut.h>
  3. int r, p, i,decision,x, y, Dx, Dy;
  4.  
  5.  
  6.  
  7. void display(void)
  8. {
  9.  
  10. x=0, y=r;
  11. decision= (5/4)-r;
  12.  
  13.  
  14. while (y > x)
  15. {
  16. glColor3f(1.0,1.0,0.0);
  17. glBegin(GL_POINTS);
  18. if (decision < 0)
  19. {
  20. x++;
  21. decision += 2*x+1;
  22. }
  23. else
  24. {
  25. y--;
  26. x++;
  27. decision += 2*(x-y)+1;
  28. }
  29.  
  30. glVertex2d(x, y);
  31. glVertex2d(x, -y);
  32. glVertex2d(-x, y);
  33. glVertex2d(-x, -y);
  34. glVertex2d(y, x);
  35. glVertex2d(-y, x);
  36. glVertex2d(y, -x);
  37. glVertex2d(-y, -x);
  38.  
  39. }
  40. glEnd();
  41. glFlush();
  42. }
  43.  
  44.  
  45.  
  46.  
  47. void init (void)
  48. {
  49.  
  50. glClearColor (0.0, 0.0, 0.0, 0.0);
  51. glMatrixMode(GL_PROJECTION);
  52. glLoadIdentity();
  53. gluOrtho2D(-500, 500, -500, 600);
  54. }
  55.  
  56. int main(int argc, char** argv)
  57. {
  58.  
  59. printf("Enter redius \n");
  60. scanf("%d", &r);
  61. glutInit(&argc, argv);
  62. glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  63. glutInitWindowSize (500, 500);
  64. glutInitWindowPosition (100, 100);
  65. glutCreateWindow ("Sumon's Circle Drawing");
  66. init ();
  67. glutDisplayFunc(display);
  68. glutMainLoop();
  69. return 0; /* ISO C requires main to return int. */
  70. }
Add Comment
Please, Sign In to add comment