diff options
author | Sven Gothel <[email protected]> | 2010-04-27 19:45:43 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-04-27 19:45:43 +0200 |
commit | 897c7248f9895d828542d524b211b74efcc715d2 (patch) | |
tree | 2b6ddc670320f5372b9d4a1a686d9e453e63ce82 /src/jogl/classes | |
parent | b5fc2499749d9c180d3e5a0e04a939bd78017068 (diff) |
JOGL Error Handling
- Catch invalid drawable for all impl. at GLContextImpl if !created yet
- GLDrawableFactoryImpl (X11/WGL) catch and fwd Throwable properly
- GLProfile catch LinkageError and handle it
In case of nothing is available, a final ExceptionInInitializer will be thrown,
with the produced GLException that no GLProfile is available.
Diffstat (limited to 'src/jogl/classes')
7 files changed, 63 insertions, 48 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java index 826523a5c..fd8c85398 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java @@ -275,6 +275,16 @@ public abstract class GLContextImpl extends GLContext { GLWorkerThread.invokeLater(new Runnable() { public void run() {} }); } + if (!isCreated()) { + // verify if the drawable if valid .. + if (0 == getGLDrawable().getNativeWindow().getSurfaceHandle()) { + throw new GLException("drawable has invalid surface handle: "+getGLDrawable()); + } + if (null == getGLDrawable().getChosenGLCapabilities()) { + throw new GLException("drawable has no chosen GLCapabilities: "+getGLDrawable()); + } + } + lock.lock(); int res = 0; try { diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java index 77cd21730..4e97e37ce 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLContext.java @@ -163,9 +163,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl } protected int makeCurrentImpl() throws GLException { - if (0 == cglContext && drawable.getNativeWindow().getSurfaceHandle() == 0) { - throw new GLException("drawable not properly initialized: "+drawable); - } boolean created = false; if ( 0 == cglContext && 0 == nsContext) { create(); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index 360bddd74..ad38f26c9 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -203,9 +203,6 @@ public class WindowsWGLContext extends GLContextImpl { WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl(); GLCapabilities glCaps = drawable.getChosenGLCapabilities(); - if (drawable.getNativeWindow().getSurfaceHandle() == 0) { - throw new GLException("Internal error: attempted to create OpenGL context without an associated drawable"); - } // Windows can set up sharing of display lists after creation time WindowsWGLContext other = (WindowsWGLContext) GLContextShareSet.getShareContext(this); long share = 0; diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index ee4592adf..70513f82d 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -73,14 +73,18 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl implements loadOpenGL32Library(); - sharedDrawable = new WindowsDummyWGLDrawable(this, null); - WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null); - ctx.makeCurrent(); - canCreateGLPbuffer = ctx.getGL().isExtensionAvailable("GL_ARB_pbuffer"); - ctx.release(); - sharedContext = ctx; + try { + sharedDrawable = new WindowsDummyWGLDrawable(this, null); + WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null); + ctx.makeCurrent(); + canCreateGLPbuffer = ctx.getGL().isExtensionAvailable("GL_ARB_pbuffer"); + ctx.release(); + sharedContext = ctx; + } catch (Throwable t) { + throw new GLException("WindowsWGLDrawableFactory - Could not initialize shared resources", t); + } if(null==sharedContext) { - throw new GLException("Couldn't init shared resources"); + throw new GLException("WindowsWGLDrawableFactory - Shared Context is null"); } if (DEBUG) { System.err.println("!!! SharedContext: "+sharedContext+", pbuffer supported "+canCreateGLPbuffer); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java index 241c956dc..165f89dcc 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXContext.java @@ -367,9 +367,6 @@ public abstract class X11GLXContext extends GLContextImpl { getDrawableImpl().getFactoryImpl().lockToolkit(); try { - if (drawable.getNativeWindow().getSurfaceHandle() == 0) { - throw new GLException("drawable not properly initialized: "+drawable); - } boolean created = false; if (context == 0) { create(); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java index b544404ad..aa1767c48 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java @@ -89,11 +89,13 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl implements Dyna ctx.makeCurrent(); ctx.release(); sharedContext = ctx; + } catch (Throwable t) { + throw new GLException("X11GLXDrawableFactory - Could not initialize shared resources", t); } finally { X11Util.XUnlockDisplay(sharedScreen.getDevice().getHandle()); } if(null==sharedContext) { - throw new GLException("Couldn't init shared context"); + throw new GLException("X11GLXDrawableFactory - Shared Context is null"); } if (DEBUG) { System.err.println("!!! Vendor: "+vendorName+", ATI: "+isVendorATI+", NV: "+isVendorNVIDIA); diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 0e10b32b3..cbf50a94d 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -864,11 +864,9 @@ public class GLProfile implements Cloneable { } catch (RuntimeException re) { t=re; } - if(null!=t) { - if (DEBUG) { - System.err.println("GLProfile.static Desktop GLES12 Library not available"); - t.printStackTrace(); - } + if(DEBUG && null!=t) { + System.err.println("GLProfile.static Desktop GLES12 Library not available"); + t.printStackTrace(); } @@ -890,12 +888,18 @@ public class GLProfile implements Cloneable { // if(hasDesktopGL||hasDesktopGLES12) { + t=null; // if successfull it has a shared dummy drawable and context created try { hasNativeOSFactory = null != GLDrawableFactory.getFactoryImpl(GL2); + } catch (LinkageError le) { + t=le; } catch (RuntimeException re) { + t=re; + } + if(DEBUG && null!=t) { System.err.println("GLProfile.static - Native platform GLDrawable factory not available"); - re.printStackTrace(); + t.printStackTrace(); } } @@ -923,33 +927,26 @@ public class GLProfile implements Cloneable { hasGL2ES12Impl = hasGL2ES12Impl && GLContext.isGL2Available(); } - boolean btest = false; - boolean hasEGLDynLookup = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper"); boolean hasEGLDrawableFactory = false; - t=null; - try { - if(hasEGLDynLookup) { + boolean btest = false; + if(hasEGLDynLookup) { + t=null; + try { hasEGLDrawableFactory = null!=GLDrawableFactory.getFactoryImpl(GLES2); - try { - btest = hasEGLDrawableFactory && - ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es2.GLES2Impl") && - null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2); - } catch (GLException gle) { - // n/a .. - } + btest = hasEGLDrawableFactory && + ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es2.GLES2Impl") && + null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2); + } catch (LinkageError le) { + t=le; + } catch (SecurityException se) { + t=se; + } catch (NullPointerException npe) { + t=npe; + } catch (RuntimeException re) { + t=re; } - } catch (UnsatisfiedLinkError ule) { - t=ule; - } catch (SecurityException se) { - t=se; - } catch (NullPointerException npe) { - t=npe; - } catch (RuntimeException re) { - t=re; - } - if(null!=t) { - if (DEBUG) { + if(DEBUG && null!=t) { System.err.println("GLProfile.static - GL ES2 Factory/Library not available"); t.printStackTrace(); } @@ -961,12 +958,23 @@ public class GLProfile implements Cloneable { btest = false; if(hasEGLDynLookup) { + t=null; try { btest = hasEGLDrawableFactory && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es1.GLES1Impl") && null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1); - } catch (GLException jre) { - /* just not available .. */ + } catch (LinkageError le) { + t=le; + } catch (SecurityException se) { + t=se; + } catch (NullPointerException npe) { + t=npe; + } catch (RuntimeException re) { + t=re; + } + if(DEBUG && null!=t) { + System.err.println("GLProfile.static - GL ES1 Factory/Library not available"); + t.printStackTrace(); } } hasGLES1Impl = btest; |