Jump to content
  • Advertisement
Sign in to follow this  
aarbron

[java] Double buffer

This topic is 3787 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

In the second example from the sticky FAQ there is Graphics g = backBuffer.getDrawGraphics(); Problem is Image has no such method getDrawGraphics . So I used getGraphics :
	public void paint(Graphics g)
		{
		if (buffer==null) return;
		Graphics gb=buffer.getGraphics();
		gb.drawRect(0, 0, 100, 100);
		g.drawImage(buffer, 0, 0, null);
		}
But it doesn't show anything .

Share this post


Link to post
Share on other sites
Advertisement
Yes you're right; must be a typo. "getDrawGraphics()" is a method from the BufferStrategy class, so in this case getGraphics() is the correct method to use.

Have you checked that buffer is correctly instantiated, not null, correct sizes.

Also are you using active rendering, or repaint(). Maybe your paint method never gets invoked?

Share this post


Link to post
Share on other sites
Hey, I've had the same problem before. Is the paint method painting directly to the screen? Is repaint() called by AWT/Swing or are you working with active rendering? Make sure AWT/Swing is invoking repaint(). Also try invoking the flush() method, so all the graphics will be flushed to the screen. Hope this will help!

I think it's because you don't close the backbuffer's graphics. Call gb.dispose().

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!