Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


[java] Double buffering in java applet...

This topic is 6590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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"

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Try something like this.

Image offScreenImage;
Graphics offScreenBuffer;

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

// Put your stuff here
public void dostuff() {

public void update( Graphics 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

Share this post

Link to post
Share on other sites
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 . . .

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!