From 39cf72646ad34c140d4400bc0949b9bc18f036af Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Thu, 26 May 2005 23:39:38 +0000 Subject: Enabled resizing of pbuffer during shrinking of GLJPanel as well git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@284 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/net/java/games/jogl/GLJPanel.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/net/java/games') diff --git a/src/net/java/games/jogl/GLJPanel.java b/src/net/java/games/jogl/GLJPanel.java index 761843d75..61b1016af 100644 --- a/src/net/java/games/jogl/GLJPanel.java +++ b/src/net/java/games/jogl/GLJPanel.java @@ -239,7 +239,14 @@ public final class GLJPanel extends JPanel implements GLDrawable { neededOffscreenImageHeight = 0; if (!hardwareAccelerationDisabled) { - if (fwidth > pbufferWidth || fheight > pbufferHeight) { + // Use factor larger than 2 during shrinks for some hysteresis + float shrinkFactor = 2.5f; + if ((fwidth > pbufferWidth ) || (fheight > pbufferHeight) || + (fwidth < (pbufferWidth / shrinkFactor)) || (fheight < (pbufferWidth / shrinkFactor))) { + if (DEBUG) { + System.err.println("Resizing pbuffer from (" + pbufferWidth + ", " + pbufferHeight + ") " + + " to fit (" + fwidth + ", " + fheight + ")"); + } // Must destroy and recreate pbuffer to fit if (pbuffer != null) { pbuffer.destroy(); @@ -248,11 +255,10 @@ public final class GLJPanel extends JPanel implements GLDrawable { toplevel.dispose(); } isInitialized = false; - if (fwidth > pbufferWidth) { - pbufferWidth = getNextPowerOf2(fwidth); - } - if (fheight > pbufferHeight) { - pbufferHeight = getNextPowerOf2(fheight); + pbufferWidth = getNextPowerOf2(fwidth); + pbufferHeight = getNextPowerOf2(fheight); + if (DEBUG) { + System.err.println("New pbuffer size is (" + pbufferWidth + ", " + pbufferHeight + ")"); } initialize(); } -- cgit v1.2.3