Open GL Animation
-
Upload
kiran-munir -
Category
Education
-
view
4.394 -
download
1
description
Transcript of Open GL Animation
![Page 1: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/1.jpg)
Presented By:Kiran Munir08-SE-59
![Page 2: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/2.jpg)
• 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.
• "Animation" would be the technique of giving "soul" to objects and drawings
![Page 3: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/3.jpg)
• For animation • We can explicitly force the display
callback to be invoked by issuing the command glutPostRedisplay().
![Page 4: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/4.jpg)
• For automated simulation• We need a mechanism for the window to
be continually updated automatically. • Idle Callback (glutIdleFunc()) • Timer Callback (glutTimerFunc()).
![Page 5: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/5.jpg)
• The Idle Callback specifies a function that is invoked whenever the system is not handling any other callbacks or events.
• Timer Callback specifies a function that is invoked after a specified time period.
![Page 6: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/6.jpg)
A Simple Animation
![Page 7: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/7.jpg)
![Page 8: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/8.jpg)
• float X=0.0;• float deltaX=0.01;
![Page 9: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/9.jpg)
Void draw(void){ glClear (GL_COLOR_BUFFER_BIT); glBegin (GL_LINES); glVertex3f (X, 0.25,0.0); glVertex3f (1.0-X, 0.75,0.0); glEnd ( ); glFlush ();
X+=deltaX;if(X>=1.0 || X<=0.0){
deltaX=-deltaX;}glutPostRedisplay(); }
![Page 10: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/10.jpg)
![Page 11: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/11.jpg)
• Single Buffer Rendering• Hardware Dependence• Inconsistent speed
![Page 12: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/12.jpg)
A Smooth Animation
![Page 13: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/13.jpg)
![Page 14: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/14.jpg)
![Page 15: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/15.jpg)
![Page 16: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/16.jpg)
![Page 17: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/17.jpg)
![Page 18: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/18.jpg)
![Page 19: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/19.jpg)
• Now to compile and execute we see a smooth animated line segment
• Double buffering is insignificant In this case, but is important in drawing complex scenes.
![Page 20: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/20.jpg)
• No real solution• Make faster computers slow• Important for consistency
![Page 21: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/21.jpg)
• Animation Delay• Select the minimal hardware
configuration• Set a time delay for animation
![Page 22: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/22.jpg)
• Glut Timed Callback• GlutTimerFunc();
![Page 23: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/23.jpg)
• glutTimerFunc(time,function,arg)• This causes function() to be called
after time milliseconds with arg as an argument to function()
![Page 24: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/24.jpg)
void Timer(int unused){
glutPostRedisplay();glutTimerFunc(30,Timer,0);
}
![Page 25: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/25.jpg)
![Page 26: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/26.jpg)
• At the end of 30 milliseconds the function timer is called again and dispatches the redisplay and timer messages.
• To compile and execute the program we see a much smoother animation.
• Simultaneously running applications can slow down your animation.
![Page 27: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/27.jpg)
![Page 28: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/28.jpg)
http://xoax.net/http://nehe.gamedev.net
![Page 29: Open GL Animation](https://reader033.fdocuments.net/reader033/viewer/2022061217/54b4da274a79593d368b4738/html5/thumbnails/29.jpg)