View Single Post
Old 09-22-2009, 06:37 AM   #1
cristisor
Knows Where the Search Button Is
 
Join Date: Jul 2009
Model: 8800
PIN: N/A
Carrier: Vodafone
Posts: 15
Default How to implement double buffering?

Please Login to Remove!

Hi,
I'm porting a game from MIDP to the BB API but the Screen classes' double buffering doesn't work like in GameCanvas. I can't do all the painting in the paint(g) method so I created an auxiliary buffer and in paint I draw the buffer, but I still get the flickerings:

Code:
theBuffer = new Bitmap(screenWidth, screenHeight);
theGraphics = Graphics.create(theBuffer);

protected void paint(Graphics graphics) {
    super.paint(graphics);
    graphics.pushContext(new XYRect(0, 0, screenWidth, screenHeight), 0, 0);
    graphics.drawBitmap(0, 0, theBuffer.getWidth(), theBuffer.getHeight(), theBuffer, 0, 0);
    graphics.popContext();
}
I draw everything in "theGraphics".
Offline   Reply With Quote