diff options
author | Sven Gothel <[email protected]> | 2009-10-05 17:54:51 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-10-05 17:54:51 -0700 |
commit | e8fbf3c0738c39005036c50e74dd20e4956f372f (patch) | |
tree | 4f2fa0c44aaec088b5263c31878c0834e4f55c9d /src/jogl/classes/com/sun | |
parent | 62fb860ffc454fc00ed73f9b6da54bba34a6d64f (diff) |
EGL more query config trials; Avoid NPE if no config is chosen
Diffstat (limited to 'src/jogl/classes/com/sun')
5 files changed, 48 insertions, 18 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java index 02aed9788..00973de89 100755 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLDynamicLookupHelper.java @@ -149,9 +149,22 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { return null; } + private boolean loadEGLLibrary(ClassLoader loader, List/*<String>*/ eglLibNames) { + NativeLibrary lib = null; + if(null!=eglLibNames && eglLibNames.size()>0) { + // EGL libraries .. + lib = loadFirstAvailable(eglLibNames, loader); + if ( null != lib ) { + glesLibraries.add(lib); + } + } + return null!=lib; + } + private void loadGLESLibrary(int esProfile) { List/*<String>*/ glesLibNames = getGLESLibNames(); List/*<String>*/ eglLibNames = getEGLLibNames(); + boolean eglLoaded = false; ClassLoader loader = getClass().getClassLoader(); NativeLibrary lib = null; @@ -160,18 +173,22 @@ public abstract class EGLDynamicLookupHelper implements DynamicLookupHelper { // ES libraries .. lib = loadFirstAvailable(glesLibNames, loader); - if (lib == null) { + if ( null == lib ) { + /*** FIXME: Have to think about this .. + // try again with EGL loaded first .. + if ( !eglLoaded && loadEGLLibrary(loader, eglLibNames) ) { + eglLoaded = true ; + lib = loadFirstAvailable(glesLibNames, loader); + } + if ( null == lib ) { + throw new GLException("Unable to dynamically load OpenGL ES library for profile ES" + esProfile); + } */ throw new GLException("Unable to dynamically load OpenGL ES library for profile ES" + esProfile); } glesLibraries.add(lib); - if(null!=eglLibNames && eglLibNames.size()>0) { - // EGL libraries .. - lib = loadFirstAvailable(eglLibNames, loader); - if (lib == null) { - throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile); - } - glesLibraries.add(lib); + if ( !eglLoaded && !loadEGLLibrary(loader, eglLibNames) ) { + throw new GLException("Unable to dynamically load EGL library for profile ES" + esProfile); } if (esProfile==2) { diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java index bd439eacb..5ab3c3ed5 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfiguration.java @@ -187,10 +187,17 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple caps.setOnscreen( 0 != (val[0] & EGL.EGL_WINDOW_BIT) ); caps.setPBuffer ( 0 != (val[0] & EGL.EGL_PBUFFER_BIT) ); } else { - return null; + throw new GLException("EGL_SURFACE_TYPE does not match !!!"); } } else { - throw new GLException("Could not determine EGL_SURFACE_TYPE"); + if(relaxed) { + if(DEBUG) { + System.err.println("Could not determine EGL_SURFACE_TYPE !!!"); + } + return null; + } else { + throw new GLException("Could not determine EGL_SURFACE_TYPE !!!"); + } } return caps; diff --git a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java index 19515d4d6..3997850c0 100644 --- a/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/sun/opengl/impl/egl/EGLGraphicsConfigurationFactory.java @@ -227,17 +227,23 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGL couldn't retrieve ConfigID for already chosen eglConfig "+capsChosen0+", error 0x"+Integer.toHexString(EGL.eglGetError())); } - val[0]=0; + return null; } GLCapabilities capsChosen1 = EGLGraphicsConfiguration.EGLConfig2Capabilities(glp, eglDisplay, configs[0], - false, capsChosen0.isOnscreen(), capsChosen0.isPBuffer()); + true, capsChosen0.isOnscreen(), capsChosen0.isPBuffer()); + if(null!=capsChosen1) { + if(DEBUG) { + System.err.println("eglChooseConfig found: eglDisplay 0x"+Long.toHexString(eglDisplay)+ + ", eglConfig ID 0x"+Integer.toHexString(val[0])+ + ", "+capsChosen0+" -> "+capsChosen1); + } + return new EGLGraphicsConfiguration(absScreen, capsChosen1, capsRequested, chooser, configs[0], val[0]); + } if(DEBUG) { - System.err.println("eglChooseConfig found: eglDisplay 0x"+Long.toHexString(eglDisplay)+ + System.err.println("eglChooseConfig couldn't verify: eglDisplay 0x"+Long.toHexString(eglDisplay)+ ", eglConfig ID 0x"+Integer.toHexString(val[0])+ - ", "+capsChosen0+" -> "+capsChosen1); + ", for "+capsChosen0); } - - return new EGLGraphicsConfiguration(absScreen, capsChosen1, capsRequested, chooser, configs[0], val[0]); } else { if(DEBUG) { System.err.println("EGL Choose Configs: None using eglDisplay 0x"+Long.toHexString(eglDisplay)+ diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 844e72841..6baedcc66 100644 --- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -435,7 +435,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio res.setOnscreen( 0 != (drawableTypeBits & WINDOW_BIT) ); res.setPBuffer ( 0 != (drawableTypeBits & PBUFFER_BIT) ); } else { - return null; + throw new GLException("WGL DrawableType does not match !!!"); } for (int i = 0; i < niattribs; i++) { diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java index dbf69e865..348664cdd 100644 --- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXGraphicsConfiguration.java @@ -251,7 +251,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setOnscreen( 0 != (val & GLX.GLX_WINDOW_BIT) ); res.setPBuffer ( 0 != (val & GLX.GLX_PBUFFER_BIT) ); } else { - return null; + throw new GLException("GLX_DRAWABLE_TYPE does not match !!!"); } res.setDoubleBuffered(glXGetFBConfig(display, fbcfg, GLX.GLX_DOUBLEBUFFER, tmp, 0) != 0); res.setStereo (glXGetFBConfig(display, fbcfg, GLX.GLX_STEREO, tmp, 0) != 0); |