diff options
author | Kenneth Russel <[email protected]> | 2005-05-26 23:39:38 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-05-26 23:39:38 +0000 |
commit | 39cf72646ad34c140d4400bc0949b9bc18f036af (patch) | |
tree | 08f14e87429f3da87e06098563d23f8895f5c1f9 /src/net/java | |
parent | 7d270daf56094c68502e1c45283c79b896291dc2 (diff) |
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
Diffstat (limited to 'src/net/java')
-rw-r--r-- | src/net/java/games/jogl/GLJPanel.java | 18 |
1 files changed, 12 insertions, 6 deletions
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(); } |