View Full Version : Animation within one call to the Display function?
02-01-2010, 03:27 PM
Is there a way to display more than a single frame within a callback to the Display function? I'd like to show some motion on a part of the screen before returning to the main loop but I'm only seeing the last frame.
(New to GLUT... sorry if this is obvious.)
02-01-2010, 08:18 PM
No. the display function happens under a fraction of a second and only sends one image to the screen. What's probably happening is your rendering every frame over the top of each other and you're only getting the last one.
You need to have a separate thread to keep the display function being called at a constant rate or have whatever windowing system you're using like GLUT to run the display function during idle time.
Then in your display function you see how much time has passed and you choose which frame you want to display that time. So, basically you're only drawing one of those images per display call.
If you have a 3 frame animation and you want it to cycle every second, you get the time (from the system or a timer) and if it's in the first third of the time, draw the first image, if it's in the second third, draw the 2nd, etc. Make sense?
02-02-2010, 07:19 AM
Thanks, yes that makes sense, and explains why I couldn't find a way to do it...
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.