Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <GL/glut.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. void display(){
  6. glClearColor(1,1,1,0);
  7. glClear(GL_COLOR_BUFFER_BIT);
  8.  
  9. glColor3f(1,0,0);
  10. glBegin(GL_POINTS);
  11. glPointSize(1);
  12. GLint i;
  13. GLfloat theta,r,x,y,pi;
  14.  
  15. //upright ball
  16. theta=0;
  17. pi=3.141592653589793;
  18. for(r=3;r>0;r=r-0.1){
  19. while(theta<=2*pi){
  20. x=r*cos(theta);
  21. y=r*sin(theta);
  22. glVertex2f(x+62,y+63);
  23. theta=theta+2*pi/1024;
  24. }
  25. theta=0;
  26. }
  27.  
  28. glEnd();
  29.  
  30. glFlush();
  31. }
  32.  
  33.  
  34. int main(int argc, char** argv){
  35. glutInit(&argc,argv);
  36. glutInitWindowPosition(50,50);
  37. glutInitWindowSize(640,640);
  38. glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
  39. glutCreateWindow("Circle");
  40. glMatrixMode(GL_PROJECTION);
  41. gluOrtho2D(0,100,0,100);
  42. glutDisplayFunc(display);
  43. glutMainLoop();
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement