diff options
author | Sven Gothel <[email protected]> | 2012-05-01 03:26:01 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-05-01 03:26:01 +0200 |
commit | 227b197b651aa57e02664a873bbe14044d1a63da (patch) | |
tree | ad84058c484c6b1f4365e624679dd6854c4877cf /src/jogl/classes/jogamp | |
parent | cc93cf413a59532bb31a4768c9d268234b859858 (diff) |
GLProfile/EGLDrawableFactory: Detect ANGLE (Windows D3D ES2 Emulation) and disable support per default.
We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome.
When run in the mentioned browsers, the eglInitialize(..) implementation crashes.
This behavior can be overridden by explicitly enabling ANGLE on Windows by setting the property
'jogl.enable.ANGLE'.
EGLDrawableFactory:
- destroy(): clear references and unregister factory, maybe triggered by GLProfile (ANGLE case)
- getAvailableCapabilitiesImpl(): return empty list in case EGL/ES is n/a (ANGLE case)
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 1ef1dc93d..4b77bfa87 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -41,12 +41,14 @@ import javax.media.opengl.*; import javax.media.opengl.GLProfile.ShutdownType; import com.jogamp.common.JogampRuntimeException; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.*; import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import jogamp.opengl.*; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -55,6 +57,18 @@ import java.util.List; public class EGLDrawableFactory extends GLDrawableFactoryImpl { private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null; + private static boolean isANGLE = false; + + private static final boolean isANGLE(GLDynamicLookupHelper dl) { + if(Platform.OSType.WINDOWS == Platform.OS_TYPE) { + final boolean r = 0 != dl.dynamicLookupFunction("eglQuerySurfacePointerANGLE") || + 0 != dl.dynamicLookupFunction("glBlitFramebufferANGLE") || + 0 != dl.dynamicLookupFunction("glRenderbufferStorageMultisampleANGLE"); + return r; + } else { + return false; + } + } public EGLDrawableFactory() { super(); @@ -114,8 +128,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(null!=tmp && tmp.isLibComplete()) { eglES1DynamicLookupHelper = tmp; EGL.resetProcAddressTable(eglES1DynamicLookupHelper); + final boolean isANGLEES1 = isANGLE(eglES1DynamicLookupHelper); + isANGLE |= isANGLEES1; if (GLProfile.DEBUG) { - System.err.println("Info: EGLDrawableFactory: EGL ES1 - OK"); + System.err.println("Info: EGLDrawableFactory: EGL ES1 - OK, isANGLE: "+isANGLEES1); } } else if (GLProfile.DEBUG) { System.err.println("Info: EGLDrawableFactory: EGL ES1 - NOPE"); @@ -133,8 +149,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(null!=tmp && tmp.isLibComplete()) { eglES2DynamicLookupHelper = tmp; EGL.resetProcAddressTable(eglES2DynamicLookupHelper); + final boolean isANGLEES2 = isANGLE(eglES2DynamicLookupHelper); + isANGLE |= isANGLEES2; if (GLProfile.DEBUG) { - System.err.println("Info: EGLDrawableFactory: EGL ES2 - OK"); + System.err.println("Info: EGLDrawableFactory: EGL ES2 - OK, isANGLE: "+isANGLEES2); } } else if (GLProfile.DEBUG) { System.err.println("Info: EGLDrawableFactory: EGL ES2 - NOPE"); @@ -162,36 +180,37 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { defaultDevice = null; /** * Pulling away the native library may cause havoc .. - * + */ if(ShutdownType.COMPLETE == shutdownType) { if(null != eglES1DynamicLookupHelper) { - eglES1DynamicLookupHelper.destroy(); + // eglES1DynamicLookupHelper.destroy(); eglES1DynamicLookupHelper = null; } if(null != eglES2DynamicLookupHelper) { - eglES2DynamicLookupHelper.destroy(); + // eglES2DynamicLookupHelper.destroy(); eglES2DynamicLookupHelper = null; } - } */ + } + EGLGraphicsConfigurationFactory.unregisterFactory(); } private HashMap<String /*connection*/, SharedResource> sharedMap = new HashMap<String /*connection*/, SharedResource>(); private EGLGraphicsDevice defaultDevice; static class SharedResource { - private EGLGraphicsDevice device; - // private EGLDrawable drawable; - // private EGLContext contextES1; - // private EGLContext contextES2; - private boolean wasES1ContextCreated; - private boolean wasES2ContextCreated; + private final EGLGraphicsDevice device; + // private final EGLDrawable drawable; + // private final EGLContext contextES1; + // private final EGLContext contextES2; + private final boolean wasES1ContextCreated; + private final boolean wasES2ContextCreated; SharedResource(EGLGraphicsDevice dev, boolean wasContextES1Created, boolean wasContextES2Created /*EGLDrawable draw, EGLContext ctxES1, EGLContext ctxES2 */) { - device = dev; - // drawable = draw; - // contextES1 = ctxES1; - // contextES2 = ctxES2; + this.device = dev; + // this.drawable = draw; + // this.contextES1 = ctxES1; + // this.contextES2 = ctxES2; this.wasES1ContextCreated = wasContextES1Created; this.wasES2ContextCreated = wasContextES2Created; } @@ -310,6 +329,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return null; } + public boolean isANGLE() { + return isANGLE; + } + public GLDynamicLookupHelper getGLDynamicLookupHelper(int esProfile) { if (2==esProfile) { return eglES2DynamicLookupHelper; @@ -321,6 +344,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } protected List<GLCapabilitiesImmutable> getAvailableCapabilitiesImpl(AbstractGraphicsDevice device) { + if(null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper) { + return new ArrayList<GLCapabilitiesImmutable>(); // null + } return EGLGraphicsConfigurationFactory.getAvailableCapabilities(this, device); } |