From 9eef9af05c78cdad57526c633aa3b31fc74f7aaa Mon Sep 17 00:00:00 2001 From: Chien Yang Date: Thu, 5 Oct 2006 22:14:50 +0000 Subject: Work around to Issue 324 : Lockup Java3D program and throw exception using JOGL renderer git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@711 ba19aa83-45c5-6ac9-afd3-db810772062c --- src/classes/jogl/javax/media/j3d/JoglPipeline.java | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/classes') diff --git a/src/classes/jogl/javax/media/j3d/JoglPipeline.java b/src/classes/jogl/javax/media/j3d/JoglPipeline.java index 568b676..7f7b47b 100644 --- a/src/classes/jogl/javax/media/j3d/JoglPipeline.java +++ b/src/classes/jogl/javax/media/j3d/JoglPipeline.java @@ -6929,9 +6929,28 @@ class JoglPipeline extends Pipeline { // Apparently we are supposed to make the context current at // this point and set up a bunch of properties - if (context.makeCurrent() == GLContext.CONTEXT_NOT_CURRENT) { - throw new IllegalRenderingStateException("Unable to make new context current"); - } + + // Work around for some low end graphics driver bug, such as Intel Chipset. + // Issue 324 : Lockup Java3D program and throw exception using JOGL renderer + boolean failed = false; + int failCount = 0; + int MAX_FAIL_COUNT = 5; + do { + failed = false; + int res = context.makeCurrent(); + if (res == GLContext.CONTEXT_NOT_CURRENT) { + // System.err.println("makeCurrent fail : " + failCount); + failed = true; + ++failCount; + try { + Thread.sleep(100); + } catch (InterruptedException e) { + } + } + } while (failed && (failCount < MAX_FAIL_COUNT)); + if (failCount == MAX_FAIL_COUNT) { + throw new IllegalRenderingStateException("Unable to make new context current after " + failCount + "tries"); + } GL gl = context.getGL(); JoglContext ctx = new JoglContext(context); -- cgit v1.2.3