diff options
author | Kenneth Russel <[email protected]> | 2006-11-15 07:44:40 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2006-11-15 07:44:40 +0000 |
commit | 6dee7dbf2dcf03af7366efa6f7b2626483eddacc (patch) | |
tree | 40c60551a7b5a790c16fa896526fc47dc0c17cff /src/classes/javax | |
parent | f918cd7c0ebc50b8521a79303e13cb775a7440d7 (diff) |
Fixed Issue 248: GLJPanel crashes
A workaround for the reported issue has been added to the GLJPanel
class and tested by forcing GLPbuffer.destroy() to throw a
GLException. The new fallback path appears to be working correctly.
Please reopen this issue or file a new one if this doesn't appear to
be the case.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@985 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/javax')
-rw-r--r-- | src/classes/javax/media/opengl/GLJPanel.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java index f4c59159f..e69c03c2f 100644 --- a/src/classes/javax/media/opengl/GLJPanel.java +++ b/src/classes/javax/media/opengl/GLJPanel.java @@ -893,13 +893,24 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { } // Must destroy and recreate pbuffer to fit if (pbuffer != null) { - pbuffer.destroy(); + // Watch for errors during pbuffer destruction (due to + // buggy / bad OpenGL drivers, in particular SiS) and fall + // back to software rendering + try { + pbuffer.destroy(); + } catch (GLException e) { + hardwareAccelerationDisabled = true; + if (DEBUG) { + System.err.println("WARNING: falling back to software rendering due to bugs in OpenGL drivers"); + e.printStackTrace(); + } + } } pbuffer = null; isInitialized = false; pbufferWidth = getNextPowerOf2(panelWidth); pbufferHeight = getNextPowerOf2(panelHeight); - if (DEBUG) { + if (DEBUG && !hardwareAccelerationDisabled) { System.err.println("New pbuffer size is (" + pbufferWidth + ", " + pbufferHeight + ")"); } initialize(); @@ -912,8 +923,14 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { // bottleneck. Should probably make the size of the offscreen // image be the exact size of the pbuffer to save some work on // resize operations... - readBackWidthInPixels = pbufferWidth; - readBackHeightInPixels = panelHeight; + if (!hardwareAccelerationDisabled) { + readBackWidthInPixels = pbufferWidth; + readBackHeightInPixels = panelHeight; + } else { + // Just disabled hardware acceleration during this resize operation; do a fixup + readBackWidthInPixels = Math.max(1, panelWidth); + readBackHeightInPixels = Math.max(1, panelHeight); + } } else { offscreenContext.destroy(); offscreenDrawable.setSize(Math.max(1, panelWidth), Math.max(1, panelHeight)); |