From f35878cbe3e5e7e04e43561fcb0b218cc83e761f Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 20 Nov 2018 20:39:18 +0100 Subject: Correct BufferStrategy rendering --- src/subconscious/graphics/Scene.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/subconscious/graphics/Scene.java b/src/subconscious/graphics/Scene.java index 1c5002d..bbc98eb 100644 --- a/src/subconscious/graphics/Scene.java +++ b/src/subconscious/graphics/Scene.java @@ -121,11 +121,16 @@ public abstract class Scene extends JPanel } } - Graphics2D g = (Graphics2D) this.buffer.getDrawGraphics(); + do { + do { + Graphics2D g = (Graphics2D) this.buffer.getDrawGraphics(); + this.render(g); + g.dispose(); + // repeat if the rendering buffer contents were restored + } while (this.buffer.contentsRestored()); + // repeat if the drawing buffer contents were lost + } while (this.buffer.contentsLost()); - this.render(g); - - g.dispose(); this.buffer.show(); lastUpdateTime = currentUpdateTime; -- cgit v1.2.1