Jump to content

  • Log In with Google      Sign In   
  • Create Account

[java] Double buffering in java applet...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Mazen   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 November 2000 - 07:56 PM

I need help with my double buffering update procedure... I use this: Image offScreenBuffer; public void update(Graphics g) { Graphics gr; offScreenBuffer = null; if (offScreenBuffer==null || (! (offScreenBuffer.getWidth(this) == this.size().width && offScreenBuffer.getHeight(this) == this.size().height))) { offScreenBuffer = this.createImage(size().width, size().height); } gr = offScreenBuffer.getGraphics(); paint(gr); g.drawImage(offScreenBuffer, 0, 0, this); } But the gfx is doesn''t run smooth at all, and some CPUs even hang up when using this code... if anyone know a solution to my little prob (or even better: know a better way to use double buffering), please reply. Help my out here guys! "We paint the sky with blood tonight, setting free the damned to fight"

Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 November 2000 - 09:06 PM

Try something like this.

Image offScreenImage;
Graphics offScreenBuffer;

offScreenImage = createImage( somewidth, someheight );
offScreenBuffer = offScreenImage.getGraphics();

// Put your stuff here
public void dostuff() {
offScreenBuffer.drawLine
offScreenBuffer.drawOval
repaint();
}

public void update( Graphics g ) {
paint(g);
}

public void paint( Graphics g ) {
g.drawImage( offScreenImage, 0, 0 );
}

I wanrned you! Didn''t I warn you?! That colored chalk was forged by Lucifer himself!

Opere Citato

#3 ernestw   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 November 2000 - 09:15 PM

Looks like everytime update() is called, a new double buffer is being created -- you''re setting offScreenBuffer to null right before you check if it''s null or not . . .




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS