Advertisement
Tusohian

FAN

Apr 5th, 2019
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #include <GL/glut.h>
  2.  
  3. float x = 0;
  4. int c = 0;
  5. int m,n,p;
  6. float angle = 0;
  7.  
  8.  
  9. void single_blade(void)
  10.  
  11. {
  12.  
  13.  
  14. glColor3f(1,1,1);
  15. glBegin(GL_LINE_LOOP);
  16. glVertex3f(0,0,0);
  17. glVertex3f(.1,.05,0);
  18. glVertex3f(.1,.1,0);
  19. glVertex3f(.2,.2,0);
  20. glVertex3f(.2,.25,0);
  21. glVertex3f(.1,.25,0);
  22. glVertex3f(.25,.35,0);
  23. glVertex3f(.2,.35,0);
  24. glVertex3f(.3,.45,0);
  25. glVertex3f(.25,.45,0);
  26. glVertex3f(.4,.55,0);
  27. glVertex3f(.3,.55,0);
  28. glVertex3f(-.3,.55,0);
  29. glVertex3f(-.4,.55,0);
  30. glVertex3f(-.25,.45,0);
  31. glVertex3f(-.3,.45,0);
  32. glVertex3f(-.2,.35,0);
  33. glVertex3f(-.25,.35,0);
  34. glVertex3f(-.1,.25,0);
  35. glVertex3f(-.2,.25,0);
  36. glVertex3f(-.2,.2,0);
  37. glVertex3f(-.1,.1,0);
  38. glVertex3f(-.1,.05,0);
  39. glVertex3f(0,0,0);
  40. glEnd();
  41.  
  42. }
  43.  
  44. void full_fan(void)
  45. {
  46. single_blade();
  47.  
  48. glRotatef(90,0,0,1);
  49. single_blade();
  50.  
  51. glRotatef(180,0,0,1);
  52. single_blade();
  53.  
  54. glRotatef(270,0,0,1);
  55. single_blade();
  56.  
  57. }
  58.  
  59.  
  60. void all_fan(void)
  61. {
  62. full_fan();
  63.  
  64. glPushMatrix();
  65. glTranslatef(-0.7,-0.7, 0);
  66. glScalef(.3 , .3 , 1);
  67. full_fan();
  68. glPopMatrix();
  69.  
  70. glPushMatrix();
  71. glTranslatef(0.7,0.7,0);
  72. glScalef(.3 , .3 , 1);
  73. full_fan();
  74. glPopMatrix();
  75.  
  76. glPushMatrix();
  77. glTranslatef(-0.7,0.7,0);
  78. glScalef(.3 , .3 , 1);
  79. full_fan();
  80. glPopMatrix();
  81.  
  82. glPushMatrix();
  83. glTranslatef(0.7,-0.7,0);
  84. glScalef(.3 , .3 , 1);
  85. full_fan();
  86. glPopMatrix();
  87.  
  88. }
  89.  
  90.  
  91. void display(void)
  92.  
  93. {
  94.  
  95. glClearColor(0.0, 0.0, 0.0, 1.0);
  96. glClear(GL_COLOR_BUFFER_BIT);
  97. glLoadIdentity();
  98. gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  99.  
  100.  
  101.  
  102. glRotatef(angle+=0.5,0,0,1);
  103. all_fan();
  104.  
  105. glFlush();
  106.  
  107.  
  108. //find a way to make 4 projections of the complete fan in four different corner of the screen.
  109.  
  110.  
  111. }
  112.  
  113. void reshape(int w, int h) {
  114.  
  115. glViewport(0, 0, (GLsizei)w, (GLsizei)h);
  116. glMatrixMode(GL_PROJECTION);
  117. glLoadIdentity();
  118. gluPerspective(30, 1, 1.0, 100.0);
  119. glMatrixMode(GL_MODELVIEW);
  120. }
  121.  
  122. int main(int argc, char **argv) {
  123. glutInit(&argc, argv);
  124. glutInitDisplayMode(GLUT_SINGLE); // single buffering.. (double buffering for animation)
  125. // full screen is 1000,1000
  126. // this 0,0 or 1000,1000 are world co ordinates
  127. glutInitWindowSize(700, 700);
  128. glutInitWindowPosition(100, 100);
  129. glutCreateWindow("A basic OpenGL Window");
  130. // registering callback functions
  131. glutDisplayFunc(display);
  132. glutReshapeFunc(reshape);
  133. glutIdleFunc(display);
  134. glutMainLoop();
  135. return 0;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement