From 6dee7dbf2dcf03af7366efa6f7b2626483eddacc Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Wed, 15 Nov 2006 07:44:40 +0000 Subject: 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 --- src/classes/javax/media/opengl/GLJPanel.java | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/classes/javax/media') 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)); -- cgit v1.2.3