diff options
author | Sven Gothel <[email protected]> | 2012-02-13 07:00:01 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-02-13 07:00:01 +0100 |
commit | 4011e70eed8c88aee0fcd051a50ab3f15bb94f68 (patch) | |
tree | e7fb1c33d4c0e75fc52dc3ec2d927f76c51de216 /src/jogl/classes/jogamp/opengl | |
parent | ddd375375025fb83aba90c80b9a089876dad5434 (diff) |
OpenGL ES/EGL Overhaul
- GLProfile properly detects native EGL/ES1/ES2 on the 'desktop' device factory.
This allows usage of Mesa's EGL/ES or Imageon's PVR emulation, etc.
- GLProfile drops getDefaultDesktopDevice() and getDefaultEGLDevice()
since both are aligned by getDefaultDevice().
- Fix GL_ARB_ES2_compatibility detection and utilize
resulting isGLES2Compatible() where possible.
This allows ES2 compatible desktop profiles to use core ES2 functionality
(glShaderBinary() .. etc) even with a GL2ES2 desktop implementation.
- EGLDrawable: If createSurface(..) fails (BAD_NATIVE_WINDOW) w/ surfaceHandle
it uses windowHandle if available and differs.
This allows the ANGLE impl. to work.
- Properly order of EGL/ES library lookup:
ES2: libGLESv2.so.2, libGLESv2.so, GLES20, GLESv2_CM
EGL: libEGL.so.1, libEGL.so, EGL
- *DynamicLookupHelper reference will be null if it's library is not complete
(all tool libs, all glue libs and a ProcAddressFunc lookup function - if named).
- Enhance GL version string (incl. ES2 compatible, hw/sw, ..)
- GLBase: Fix docs and remove redundancies
- Prepared (disabled) DesktopES2DynamicLibraryBundleInfo
to be used for a real EGL/ES2 implementation within the desktop GL lib (AMD).
Sadly it currenly crashed within eglGetDisplay(EGL_DEFAULT_DISPLAY),
hence it's disabled.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
12 files changed, 269 insertions, 76 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index a7710e5bc..02ac2428f 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -653,11 +653,12 @@ public abstract class GLContextImpl extends GLContext { private final void mapGLVersions(AbstractGraphicsDevice device) { synchronized (GLContext.deviceVersionAvailable) { + // Following GLProfile.GL_PROFILE_LIST_ALL order of profile detection { GL4bc, GL3bc, GL2, GL4, GL3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 } createContextARBMapVersionsAvailable(4, true /* compat */); // GL4bc - createContextARBMapVersionsAvailable(4, false /* core */); // GL4 createContextARBMapVersionsAvailable(3, true /* compat */); // GL3bc + createContextARBMapVersionsAvailable(2, true /* compat */); // GL2 + createContextARBMapVersionsAvailable(4, false /* core */); // GL4 createContextARBMapVersionsAvailable(3, false /* core */); // GL3 - createContextARBMapVersionsAvailable(2, true /* compat */); // GL2 GLContext.setAvailableGLVersionsSet(device); resetStates(); } @@ -717,14 +718,21 @@ public abstract class GLContextImpl extends GLContext { } if(0!=_context) { AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); - if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) { - ctp |= CTX_PROFILE_ES2_COMPAT; - } - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, major[0], minor[0], ctp); + // ctxMajorVersion, ctxMinorVersion, ctxOptions is being set by + // createContextARBVersions(..) -> setGLFunctionAvailbility(..) -> setContextVersion(..) + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxMajorVersion, ctxMinorVersion, ctxOptions); + /** + * TODO: GLES2_TRUE_DESKTOP (see: GLContextImpl, GLProfile) + * Hack to enable GLES2 for desktop profiles w/ ES2 compatibility, + * however .. a consequent implementation would need to have all GL2ES2 + * implementing profile to also implement GLES2! + * Let's rely on GL2ES2 and let the user/impl. query isGLES2Compatible() + if( isGLES2Compatible() && null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES) ) { + GLContext.mapAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES, ctxMajorVersion, ctxMinorVersion, ctxOptions); + }*/ destroyContextARBImpl(_context); if (DEBUG) { - System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable HAVE: "+ - GLContext.getAvailableGLVersionAsString(device, reqMajor, reqProfile)); + System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable HAVE: " + getGLVersion()); } } else if (DEBUG) { System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable NOPE: "+reqMajor+"."+reqProfile); @@ -929,24 +937,24 @@ public abstract class GLContextImpl extends GLContext { * @see #setContextVersion * @see javax.media.opengl.GLContext#CTX_OPTION_ANY * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT + * @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT */ protected final void setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits) { if(null!=this.gl && null!=glProcAddressTable && !force) { return; // already done and not forced } - + if(null==this.gl || !verifyInstance(gl.getGLProfile(), "Impl", this.gl)) { setGL(createGL(getGLDrawable().getGLProfile())); } - updateGLXProcAddressTable(); AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; - contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits); + ctxProfileBits |= drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; + contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": !!! Context FQN: "+contextFQN); + System.err.println(getThreadName() + ": !!! Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } // @@ -956,8 +964,8 @@ public abstract class GLContextImpl extends GLContext { synchronized(mappedContextTypeObjectLock) { table = mappedGLProcAddress.get( contextFQN ); if(null != table && !verifyInstance(gl.getGLProfile(), "ProcAddressTable", table)) { - throw new InternalError("GLContext GL ProcAddressTable mapped key("+contextFQN+") -> "+ - table.getClass().getName()+" not matching "+gl.getGLProfile().getGLImplBaseClassName()); + throw new InternalError("GLContext GL ProcAddressTable mapped key("+contextFQN+" - " + GLContext.getGLVersion(major, minor, ctxProfileBits, null)+ + ") -> "+ table.getClass().getName()+" not matching "+gl.getGLProfile().getGLImplBaseClassName()); } } if(null != table) { @@ -981,11 +989,6 @@ public abstract class GLContextImpl extends GLContext { } // - // Set GL Version - // - setContextVersion(major, minor, ctxProfileBits); - - // // Update ExtensionAvailabilityCache // ExtensionAvailabilityCache eCache; @@ -1008,16 +1011,24 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+extensionAvailability.hashCode()); } } + } + if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) { + ctxProfileBits |= CTX_IMPL_ES2_COMPAT; } + + // + // Set GL Version + // + setContextVersion(major, minor, ctxProfileBits); } protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) { AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; - contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits); + ctxProfileBits |= drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT; + contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": !!! RM Context FQN: "+contextFQN); + System.err.println(getThreadName() + ": !!! RM Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } synchronized(mappedContextTypeObjectLock) { @@ -1129,8 +1140,9 @@ public abstract class GLContextImpl extends GLContext { return false; } - protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits, int ctxImplBits) { - return device.getUniqueID() + "-" + toHexString(compose8bit(major, minor, ctxProfileBits, ctxImplBits)); + protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { + ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT ; // remove non-key value + return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } protected String getContextFQN() { diff --git a/src/jogl/classes/jogamp/opengl/awt/Java2D.java b/src/jogl/classes/jogamp/opengl/awt/Java2D.java index 3e4a6a147..b5530fc2f 100644 --- a/src/jogl/classes/jogamp/opengl/awt/Java2D.java +++ b/src/jogl/classes/jogamp/opengl/awt/Java2D.java @@ -567,7 +567,7 @@ public class Java2D { } invokeWithOGLSharedContextCurrent(device.getDefaultConfiguration(), new Runnable() { public void run() { - j2dFBOShareContext = GLDrawableFactory.getFactory(GLProfile.getDefault(GLProfile.getDefaultDesktopDevice())).createExternalGLContext(); + j2dFBOShareContext = GLDrawableFactory.getFactory(GLProfile.getDefault(GLProfile.getDefaultDevice())).createExternalGLContext(); } }); if (DEBUG) { diff --git a/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java new file mode 100644 index 000000000..cddd142e9 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java @@ -0,0 +1,106 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.egl; + +import java.util.*; + +import jogamp.opengl.*; + +/** + * Implementation of the DynamicLookupHelper for Desktop ES2 (AMD, ..) + * where EGL and ES2 functions reside within the desktop OpenGL library. + */ +public class DesktopES2DynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo { + static List<String> glueLibNames; + static { + glueLibNames = new ArrayList<String>(); + glueLibNames.add("jogl_mobile"); + } + + protected DesktopES2DynamicLibraryBundleInfo() { + super(); + } + + /** + * Might be a desktop GL library, and might need to allow symbol access to subsequent libs. + * + * This respects old DRI requirements:<br> + * <pre> + * http://dri.sourceforge.net/doc/DRIuserguide.html + * </pre> + */ + public boolean shallLinkGlobal() { return true; } + + public final List<String> getToolGetProcAddressFuncNameList() { + List<String> res = new ArrayList<String>(); + res.add("eglGetProcAddress"); + return res; + } + + public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) { + return EGL.eglGetProcAddress(toolGetProcAddressHandle, funcName); + } + + public final boolean useToolGetProcAdressFirst(String funcName) { + return true; + } + + public List<List<String>> getToolLibNames() { + final List<List<String>> libsList = new ArrayList<List<String>>(); + final List<String> libsGL = new ArrayList<String>(); + + // Be aware that on DRI systems, eg ATI fglrx, etc, + // you have to set LIBGL_DRIVERS_PATH env variable. + // Eg on Ubuntu 64bit systems this is: + // export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri + // + + // X11: this is the default lib name, according to the spec + libsGL.add("libGL.so.1"); + + // X11: try this one as well, if spec fails + libsGL.add("libGL.so"); + + // Windows default + libsGL.add("OpenGL32"); + + // OSX (guess ES2 on OSX will never happen) + libsGL.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"); + + // last but not least .. the generic one + libsGL.add("GL"); + + libsList.add(libsGL); + return libsList; + } + + public final List<String> getGlueLibNames() { + return glueLibNames; + } +} diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 62ee20f92..1dc4a81aa 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -108,7 +108,7 @@ public abstract class EGLContext extends GLContextImpl { drawableRead.getHandle(), contextHandle)) { throw new GLException("Error making context 0x" + - Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError()); + Long.toHexString(contextHandle) + " current: error code 0x" + Integer.toHexString(EGL.eglGetError())); } } } @@ -119,14 +119,17 @@ public abstract class EGLContext extends GLContextImpl { EGL.EGL_NO_SURFACE, EGL.EGL_NO_CONTEXT)) { throw new GLException("Error freeing OpenGL context 0x" + - Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError()); + Long.toHexString(contextHandle) + ": error code 0x" + Integer.toHexString(EGL.eglGetError())); } } protected void destroyImpl() throws GLException { if (!EGL.eglDestroyContext(((EGLDrawable)drawable).getDisplay(), contextHandle)) { - throw new GLException("Error destroying OpenGL context 0x" + - Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError()); + final int eglError = EGL.eglGetError(); + if(EGL.EGL_SUCCESS != eglError) { /* oops, Mesa EGL impl. may return false, but has no EGL error */ + throw new GLException("Error destroying OpenGL context 0x" + + Long.toHexString(contextHandle) + ": error code 0x" + Integer.toHexString(eglError)); + } } } @@ -204,7 +207,7 @@ public abstract class EGLContext extends GLContextImpl { int ctp = CTX_PROFILE_ES|CTX_OPTION_ANY; int major; if(glProfile.usesNativeGLES2()) { - ctp |= CTX_PROFILE_ES2_COMPAT; + ctp |= CTX_IMPL_ES2_COMPAT; major = 2; } else { major = 1; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index 14a0a40cd..db1efc194 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -89,7 +89,23 @@ public abstract class EGLDrawable extends GLDrawableImpl { eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), surface.getSurfaceHandle()); if (EGL.EGL_NO_SURFACE==eglSurface) { - throw new GLException("Creation of window surface failed: "+eglConfig+", error "+toHexString(EGL.eglGetError())); + final int eglError0 = EGL.eglGetError(); + if(EGL.EGL_BAD_NATIVE_WINDOW == eglError0) { + // Try window handle if available and differs (Windows HDC / HWND). + // ANGLE impl. required HWND on Windows. + if(surface instanceof NativeWindow) { + final NativeWindow nw = (NativeWindow) surface; + if(nw.getWindowHandle() != nw.getSurfaceHandle()) { + if(DEBUG) { + System.err.println("Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle"); + } + eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), nw.getWindowHandle()); + } + } + } + } + if (EGL.EGL_NO_SURFACE==eglSurface) { + throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(EGL.eglGetError())); } if(DEBUG) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index cd6d61a22..56d14fc8f 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -47,7 +47,9 @@ import com.jogamp.common.util.*; import jogamp.opengl.*; import jogamp.nativewindow.WrappedSurface; +import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.List; public class EGLDrawableFactory extends GLDrawableFactoryImpl { @@ -73,7 +75,32 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // for each ES profile with their own ProcAddressTable. synchronized(EGLDrawableFactory.class) { - if(null==eglES1DynamicLookupHelper) { + /** + * Currently AMD's EGL impl. crashes at eglGetDisplay(EGL_DEFAULT_DISPLAY) + * + // Check Desktop ES2 Availability first (AMD, ..) + if(null==eglES2DynamicLookupHelper) { + GLDynamicLookupHelper tmp=null; + try { + tmp = new GLDynamicLookupHelper(new DesktopES2DynamicLibraryBundleInfo()); + } catch (GLException gle) { + if(DEBUG) { + gle.printStackTrace(); + } + } + if(null!=tmp && tmp.isLibComplete()) { + eglES2DynamicLookupHelper = tmp; + EGL.resetProcAddressTable(eglES2DynamicLookupHelper); + if (GLProfile.DEBUG) { + System.err.println("Info: EGLDrawableFactory: Desktop ES2 - OK"); + } + } else if (GLProfile.DEBUG) { + System.err.println("Info: EGLDrawableFactory: Desktop ES2 - NOPE"); + } + } */ + final boolean hasDesktopES2 = null != eglES2DynamicLookupHelper; + + if(!hasDesktopES2 && null==eglES1DynamicLookupHelper) { GLDynamicLookupHelper tmp=null; try { tmp = new GLDynamicLookupHelper(new EGLES1DynamicLibraryBundleInfo()); @@ -81,16 +108,18 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(DEBUG) { gle.printStackTrace(); } - } - eglES1DynamicLookupHelper = tmp; - if(null!=eglES1DynamicLookupHelper && eglES1DynamicLookupHelper.isLibComplete()) { + } + if(null!=tmp && tmp.isLibComplete()) { + eglES1DynamicLookupHelper = tmp; EGL.resetProcAddressTable(eglES1DynamicLookupHelper); - } + if (GLProfile.DEBUG) { + System.err.println("Info: EGLDrawableFactory: EGL ES1 - OK"); + } + } else if (GLProfile.DEBUG) { + System.err.println("Info: EGLDrawableFactory: EGL ES1 - NOPE"); + } } - } - - synchronized(EGLDrawableFactory.class) { - if(null==eglES2DynamicLookupHelper) { + if(!hasDesktopES2 && null==eglES2DynamicLookupHelper) { GLDynamicLookupHelper tmp=null; try { tmp = new GLDynamicLookupHelper(new EGLES2DynamicLibraryBundleInfo()); @@ -98,21 +127,33 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(DEBUG) { gle.printStackTrace(); } - } - eglES2DynamicLookupHelper = tmp; - if(null!=eglES2DynamicLookupHelper && eglES2DynamicLookupHelper.isLibComplete()) { + } + if(null!=tmp && tmp.isLibComplete()) { + eglES2DynamicLookupHelper = tmp; EGL.resetProcAddressTable(eglES2DynamicLookupHelper); - } + if (GLProfile.DEBUG) { + System.err.println("Info: EGLDrawableFactory: EGL ES2 - OK"); + } + } else if (GLProfile.DEBUG) { + System.err.println("Info: EGLDrawableFactory: EGL ES2 - NOPE"); + } } } if(null != eglES1DynamicLookupHelper || null != eglES2DynamicLookupHelper) { defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - sharedMap = new HashMap(); } } protected final void destroy(ShutdownType shutdownType) { if(null != sharedMap) { + Collection<SharedResource> srl = sharedMap.values(); + for(Iterator<SharedResource> sri = srl.iterator(); sri.hasNext(); ) { + SharedResource sr = sri.next(); + if(DEBUG) { + System.err.println("EGLDrawableFactory.destroy("+shutdownType+"): "+sr.device.toString()); + } + EGL.eglTerminate(sr.device.getHandle()); + } sharedMap.clear(); sharedMap = null; } @@ -132,7 +173,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } */ } - private HashMap/*<connection, SharedResource>*/ sharedMap; + private HashMap<String /*connection*/, SharedResource> sharedMap = new HashMap<String /*connection*/, SharedResource>(); private EGLGraphicsDevice defaultDevice; static class SharedResource { @@ -199,12 +240,15 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } */ /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) { + if(null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper) { + return null; + } String connection = adevice.getConnection(); SharedResource sr; synchronized(sharedMap) { sr = (SharedResource) sharedMap.get(connection); } - if(null==sr) { + if(null==sr) { long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY); if (eglDisplay == EGL.EGL_NO_DISPLAY) { throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError())); @@ -265,14 +309,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { public GLDynamicLookupHelper getGLDynamicLookupHelper(int esProfile) { if (2==esProfile) { - if(null==eglES2DynamicLookupHelper) { - throw new GLException("GLDynamicLookupHelper for ES2 not available"); - } return eglES2DynamicLookupHelper; } else if (1==esProfile) { - if(null==eglES1DynamicLookupHelper) { - throw new GLException("GLDynamicLookupHelper for ES1 not available"); - } return eglES1DynamicLookupHelper; } else { throw new GLException("Unsupported: ES"+esProfile); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java index 50c4950a0..841d50f5f 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java @@ -51,7 +51,14 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle super(); } - /** Might be a desktop GL library, and might need to allow symbol access to subsequent libs */ + /** + * Might be a desktop GL library, and might need to allow symbol access to subsequent libs. + * + * This respects old DRI requirements:<br> + * <pre> + * http://dri.sourceforge.net/doc/DRIuserguide.html + * </pre> + */ public boolean shallLinkGlobal() { return true; } public boolean shallLookupGlobal() { @@ -74,19 +81,27 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle } public final boolean useToolGetProcAdressFirst(String funcName) { - return false; // JAU / FIXME funcName.startsWith("egl"); + if ( AndroidVersion.isAvailable ) { + // Android requires global dlsym lookup + return false; + } else { + return true; + } } protected List<String> getEGLLibNamesList() { List<String> eglLibNames = new ArrayList<String>(); - // try default generic names first - eglLibNames.add("EGL"); + // this is the default EGL lib name, according to the spec + eglLibNames.add("libEGL.so.1"); + + // try these as well, if spec fails + eglLibNames.add("libEGL.so"); + eglLibNames.add("EGL"); + // for windows distributions using the 'unlike' lib prefix, // where our tool does not add it. eglLibNames.add("libEGL"); - // this is the default EGL lib name, according to the spec - eglLibNames.add("libEGL.so.1"); return eglLibNames; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java index 63109f445..0a373eb7f 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java @@ -40,11 +40,12 @@ public class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo { final List<String> libsGL = new ArrayList<String>(); - // GLESv2 - libsGL.add("GLESv1_CM"); - libsGL.add("libGLESv1_CM.so"); // this is the default lib name, according to the spec libsGL.add("libGLESv1_CM.so.2"); + + // try these as well, if spec fails + libsGL.add("libGLESv1_CM.so"); + libsGL.add("GLESv1_CM"); // alternative names libsGL.add("GLES_CM"); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java index b0748ad10..d4ee852b1 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java @@ -40,11 +40,12 @@ public class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo { final List<String> libsGL = new ArrayList<String>(); - // GLESv2 - libsGL.add("GLESv2"); - libsGL.add("libGLESv2.so"); // this is the default lib name, according to the spec libsGL.add("libGLESv2.so.2"); + + // try these as well, if spec fails + libsGL.add("libGLESv2.so"); + libsGL.add("GLESv2"); // alternative names libsGL.add("GLES20"); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 5c6486799..ee28b7bcb 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -88,11 +88,12 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { gle.printStackTrace(); } } - macOSXCGLDynamicLookupHelper = tmp; - /** FIXME ?? - if(null!=macOSXCGLDynamicLookupHelper) { + if(null!=tmp && tmp.isLibComplete()) { + macOSXCGLDynamicLookupHelper = tmp; + /** FIXME ?? CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper); - } */ + */ + } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 43c16240d..f40a5f0bf 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -95,9 +95,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if(DEBUG) { gle.printStackTrace(); } - } - windowsWGLDynamicLookupHelper = tmp; - if(null!=windowsWGLDynamicLookupHelper) { + } + if(null!=tmp && tmp.isLibComplete()) { + windowsWGLDynamicLookupHelper = tmp; WGL.getWGLProcAddressTable().reset(windowsWGLDynamicLookupHelper); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index acced638f..4e8a35fa5 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -93,9 +93,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if(DEBUG) { gle.printStackTrace(); } - } - x11GLXDynamicLookupHelper = tmp; - if(null!=x11GLXDynamicLookupHelper) { + } + if(null!=tmp && tmp.isLibComplete()) { + x11GLXDynamicLookupHelper = tmp; GLX.getGLXProcAddressTable().reset(x11GLXDynamicLookupHelper); } } |