Shishu

fan rotate in visual basic

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