I am trying to implement an animation in Fullscreen mode (FSEM) where the
background remains static to a large extent and only some small portion of the
display should differ from frame to frame. I can do this by drawing both the
static background image and the animating foreground image to the back buffer
and then display it using BufferStrategy.show():
Suppose the background image is bg (a BufferedImage) and suppose that the small
part that changes during the animation is stored in another image fg. For
simplicity suppose that the screen position where fg is drawn does not change
in successive frames. I can implement this as follows:
public void animate(){
if (getBufferStrategy().contentsLost())
createBufferStrategy(2);
Graphics2D g = (Graphics2D) getBufferStrategy().getDrawGraphics();
g.drawImage(bg,x1,y1,null); // x1,y1,bg never change
g.drawImage(fg,x2,y2,null); // x2,y2 constant, only fg changes
getBufferStrategy().show();
}
But I am a bit concerned with this approach. Because this implementation has to
blit/flip the entire back buffer to front even though most part is actually
never changing. I am wondering if there is a better way of doing this. For
example, is there a way to blit/flip only a portion of the front buffer? Or is
this actually taken care of by the BufferStrategy behind the scene?
[Message sent by forum member 'boyaci' (boyaci)]
http://forums.java.net/jive/thread.jspa?messageID=223663
===========================================================================
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".