Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Open GL Animation


Published on

Published in: Education
  • Be the first to comment

Open GL Animation

  1. 1. Presented By: Kiran Munir 08-SE-59
  2. 2. <ul><li>Animation is the rapid display of a sequence of images of 2-D or 3-D artwork or model positions in order to create an illusion of movement. </li></ul><ul><li>&quot;Animation&quot; would be the technique of giving &quot;soul&quot; to objects and drawings </li></ul>
  3. 3. <ul><li>For animation </li></ul><ul><ul><li>We can explicitly force the display callback to be invoked by issuing the command glutPostRedisplay() . </li></ul></ul>
  4. 4. <ul><li>For automated simulation </li></ul><ul><ul><li>We need a mechanism for the window to be continually updated automatically. </li></ul></ul><ul><ul><li>Idle Callback ( glutIdleFunc() ) </li></ul></ul><ul><ul><li>Timer Callback ( glutTimerFunc() ). </li></ul></ul>
  5. 5. <ul><li>The Idle Callback specifies a function that is invoked whenever the system is not handling any other callbacks or events. </li></ul><ul><li>Timer Callback specifies a function that is invoked after a specified time period. </li></ul>
  6. 6. A Simple Animation
  7. 8. <ul><li>float X=0.0; </li></ul><ul><li>float deltaX=0.01; </li></ul>
  8. 9. <ul><li>Void draw(void) </li></ul><ul><li>{ </li></ul><ul><li>glClear (GL_COLOR_BUFFER_BIT); </li></ul><ul><li>glBegin (GL_LINES); </li></ul><ul><li>glVertex3f ( X, 0.25,0.0); </li></ul><ul><li>glVertex3f ( 1.0-X , 0.75,0.0); </li></ul><ul><li>glEnd ( ); </li></ul><ul><li>glFlush (); </li></ul><ul><li>X+=deltaX; </li></ul><ul><li>if(X>=1.0 || X<=0.0){ </li></ul><ul><li>deltaX=-deltaX; </li></ul><ul><li>} </li></ul><ul><li>glutPostRedisplay(); } </li></ul>
  9. 11. <ul><ul><li>Single Buffer Rendering </li></ul></ul><ul><ul><li>Hardware Dependence </li></ul></ul><ul><ul><ul><li>Inconsistent speed </li></ul></ul></ul>
  10. 12. A Smooth Animation
  11. 19. <ul><li>Now to compile and execute we see a smooth animated line segment </li></ul><ul><li>Double buffering is insignificant In this case, but is important in drawing complex scenes. </li></ul>
  12. 20. <ul><ul><li>No real solution </li></ul></ul><ul><ul><li>Make faster computers slow </li></ul></ul><ul><ul><li>Important for consistency </li></ul></ul>
  13. 21. <ul><li>Animation Delay </li></ul><ul><ul><li>Select the minimal hardware configuration </li></ul></ul><ul><ul><li>Set a time delay for animation </li></ul></ul>
  14. 22. <ul><li>Glut Timed Callback </li></ul><ul><ul><li>GlutTimerFunc(); </li></ul></ul>
  15. 23. <ul><li>glutTimerFunc(time,function,arg) </li></ul><ul><ul><li>This causes function() to be called after time milliseconds with arg as an argument to function() </li></ul></ul>
  16. 24. <ul><li>void Timer(int unused) </li></ul><ul><li>{ </li></ul><ul><li>glutPostRedisplay(); </li></ul><ul><li>glutTimerFunc(30,Timer,0); </li></ul><ul><li>} </li></ul>
  17. 26. <ul><li>At the end of 30 milliseconds the function timer is called again and dispatches the redisplay and timer messages. </li></ul><ul><li>To compile and execute the program we see a much smoother animation. </li></ul><ul><li>Simultaneously running applications can slow down your animation. </li></ul>
  18. 28. <ul><li> </li></ul><ul><li> </li></ul>