BufferedImage Double Buffering?

I have succesfully made the buffered image, but I still get horrible flicking in my game. I also think I'm having a memory leakage, because I haven't properly done this. Everything looks basically like in any examples, but how wrong it is. Flickering is awful.

this is how I set up the BufferedImage, so basically I'm passing it to engine.

GraphicsEnvironment env =GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice device = env.getDefaultScreenDevice();

gameFrame game =new gameFrame();

screenManager gameScreen =new screenManager(device, game);

engineManager engine =new engineManager(game);

engine.start();

KeyListener keyInput =new inputManager();

MouseListener mouseListener =new inputManager();

MouseMotionListener mouseTracker =new inputManager();

game.createBufferStrategy(2);

game.addKeyListener(keyInput);

game.addMouseMotionListener(mouseTracker);

game.addMouseListener(mouseListener);

game.setIgnoreRepaint(true);

then at engineManager

public engineManager(Frame f){

bufferStrategy = f.getBufferStrategy();

g = (Graphics2D)bufferStrategy.getDrawGraphics();

}

and at render

publicvoid render(Graphics2D g){

Rectangle2D.Double rect =new Rectangle2D.Double(352F, 252F, 48F, 48F);

g.setColor(Color.white);

AffineTransform t =new AffineTransform();

//t.rotate(java.lang.Math.PI/180*x);

t.rotate(inputManager.rotateAngle, 376, 276);

g.setTransform(t);

g.clearRect(0,0,800,600);

g.fill(rect);

bufferStrategy.show();

I call the render at engineManager.run()

I thought the engine manager handles the double buffering for you? Do I have to make still make DB? If not what is wrong?

[2330 byte] By [OlliPekka] at [2007-9-27 22:38:40]
# 1

Hmm...what exactly are you making? A BufferedImage, or a BufferStrategy? These are two totally different things, you see.

BufferedImage is literally an image with some pixel-manipulation stuff in it. I've used this kind of image before in my game and it tends to slow down performance a whole lot. If you're gonna do your own double-buffering, then I suggest using VolatileImage instead.

BufferStrategy allows you to do have double buffering, without really doing it yourself. Make sure that render() is in a thread loop of some sort, which I think is what your engineManager does. However, I'm not exactly what those other managers do, so maybe you could clarify?

Just to let you know, I'm not an expert at this. :P

Frumple

Frumple at 2007-7-7 13:27:56 > top of Java-index,Other Topics,Java Game Development...
# 2
The problem isn't the bufferedstrategy. btw I got mixed up at the heading.The problem is the clipping and clearRect(); and I have to work out an alternative for those.
OlliPekka at 2007-7-7 13:27:56 > top of Java-index,Other Topics,Java Game Development...
# 3
I'm not using BufferStrategy to handle the double buffering and everything works good... It is a class only available with Java1.4, isn't it ?Toine
onlytoine at 2007-7-7 13:27:56 > top of Java-index,Other Topics,Java Game Development...
# 4

Upgrade your SDK, early 1.4 implementations had this problem on Windows2k (It's a bug). Pretty much the second buffer will point to an empty portion of video memory always, the solution to this without updating is to fill the entire backbuffer completely, flip it, fill it again, and then flip it again. You should then be able to use it normaly.

-Jason Thomas.

thedracle at 2007-7-7 13:27:56 > top of Java-index,Other Topics,Java Game Development...