aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-02-13 07:00:01 +0100
committerSven Gothel <[email protected]>2012-02-13 07:00:01 +0100
commit4011e70eed8c88aee0fcd051a50ab3f15bb94f68 (patch)
treee7fb1c33d4c0e75fc52dc3ec2d927f76c51de216 /src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
parentddd375375025fb83aba90c80b9a089876dad5434 (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/egl/EGLDrawableFactory.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java82
1 files changed, 60 insertions, 22 deletions
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);