I've written a program that generates images in real time, which if
viewed in sequence would form an animation.  These images are built one
at a time in a 800x600 offscreen VolatileImage buffer (I'm doing my own
double buffereing).  I then call repaint() and blit this buffer to a
JComponent that I've subclassed to display my animation.  Painting code
is in the paintComponent() method.  I'm repainting anywhere from 10 to
30 frames per second.  This is handled in a second thread that sleeps
for the appropriate number of milliseconds, then wakes up, causes the
next image to be generated, and calls repaint() on my component's JFrame
ancestor.

Even though my machine is fast enough to generate and blit in the time
provided, the animation still apprears jagged.  There is occasional
horizontal shearing, presumably from the blitted image being only
partially rendered when the screen refresh occurs.  The image also
appears to shake, giving me the impression that Swing is somehow caching
previous copies of frames rendered and mixing them into the curent
frames rendered.  The whole thing reminds me of the old days when you
had to override update() to stop AWT from clearing the screen.

I've tried this both single buffered and double buffered JRootPanes
(since I'm doing my own double buffereing, I figure I don't need to use
Swing's).

Any ideas what's going wrong?  Is my second thread causing the trouble?
What's the recommend way to get smooth animation?

Mark McKay
--
http://www.kitfox.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to