View Full Version : Animation
I was wondering what would be the best way to do animation with OpenGL. The only thing I can think of is the GlutIdleFunc()...but there seems to be more to it...like how can I set a specefic speed based on time (so that it doesnt vary on diff computers), how do I set the frame rates, get in sync with the screen..???? Any thoughts on that, or what book I could look into.
I also read the posts on the event, and I was wondering what GetNextEvent or GetNextOSEvent do ? And where can I find out...
Thanks a lot.
You have at least 2 types of animation : mesh based and bones based. Mesh animation is easy because you only need to interpolate linearly between different frames you have recorded and you need to link that to your frame rate if you want things to happen in a consistent manner in your application.
GetNextEvent retrieves any type of events from the event queue and returns straight away and I think GetNextOSEvent only retrieves High Level events from the queue.
08-26-2000, 03:55 PM
I am afraid BANE may have gotten over you head with his post.
Using GLUT you are bypassing the MacAPI calls with the GLUT layer. This makes your code portable across platforms, but is limited.
If you scrap GLUT and code straight to the MacOS APIs (Which is harder), you set up the event loop yourself and can specify an amount of time for the OS to wait for an event before giveing control back to you. This will not garuntee a specific amount of time because, if an event occurs before the time is up, your program will recieve that event right away. If the time elapses and no event has occured, then you get a NULL event. Check out the MacOS TickCount function so you can time things on specific intervals better? It still wont be perfect, but easier than setting up your own interrupt.
08-30-2000, 10:02 AM
Still using GLUT, you can simply call a time function when inside your GLUT idle callback. Use this time value to calculate the exact frame (time-wise) you are given control via the GLUT idle callback. I usually calculate to a 60th of a second and then set my animation data to the correct position for that 60th. Note that I've not mentioned which time function... I've not been an active Mac programmer for about 5 years (game consoles) so I don't remember the best time function. But just choose a routine that returns time in something less than seconds. Search around and you'll find discussions about latency and such with various time routines. Read those discussions and make your selection based on that. There is no reason that you need to stop using GLUT simply to get time accurate animation working. If you're careful with your coding, you could create a complete professional app with GLUT and compile it across Mac, Win32, Linux or even PS2.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.