summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-07-31 20:10:16 +0200
committerSven Gothel <[email protected]>2011-07-31 20:10:16 +0200
commit03ca640b6842c6070bcc3fb76e1c3464ea5c44a1 (patch)
treea3daba6fcc0f57adce72126a6212a93f2e39e20c /src/jogl
parent43ca6eea35ed06b462f609bd5704d9499c678927 (diff)
EGL: Query EGL_RENDERABLE_TYPE, store it in EGLGLCapabilities and test w/ GLProfile compatibility
EGLConfig's EGL_RENDERABLE_TYPE determines ES1, ES2 or VG usage (bitfield). We have to store and compare it's value w/ the desired GLProfile to choose a valid one, or just store it.
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java79
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java23
2 files changed, 93 insertions, 9 deletions
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index cead0358d..6c4901de8 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -34,8 +34,9 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
public class EGLGLCapabilities extends GLCapabilities {
- long eglcfg;
- int eglcfgid;
+ final long eglcfg;
+ final int eglcfgid;
+ final int renderableType;
/** Comparing EGLConfig ID only */
public static class EglCfgIDComparator implements Comparator {
@@ -65,10 +66,24 @@ public class EGLGLCapabilities extends GLCapabilities {
}
}
- public EGLGLCapabilities(long eglcfg, int eglcfgid, GLProfile glp) {
- super(glp);
+ /**
+ *
+ * @param eglcfg
+ * @param eglcfgid
+ * @param glp desired GLProfile, or null if determined by renderableType
+ * @param renderableType actual EGL renderableType
+ *
+ * May throw GLException if given GLProfile is not compatible w/ renderableType
+ */
+ public EGLGLCapabilities(long eglcfg, int eglcfgid, GLProfile glp, int renderableType) {
+ super( ( null != glp ) ? glp : getCompatible(renderableType) );
this.eglcfg = eglcfg;
this.eglcfgid = eglcfgid;
+ if(!isCompatible(glp, renderableType)) {
+ throw new GLException("Incompatible "+glp+
+ " with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]");
+ }
+ this.renderableType = renderableType;
}
public Object cloneMutable() {
@@ -85,12 +100,66 @@ public class EGLGLCapabilities extends GLCapabilities {
final public long getEGLConfig() { return eglcfg; }
final public int getEGLConfigID() { return eglcfgid; }
+ final public int getRenderableType() { return renderableType; }
+
+ public static boolean isCompatible(GLProfile glp, int renderableType) {
+ if(null == glp) {
+ return true;
+ }
+ if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && glp.usesNativeGLES1()) {
+ return true;
+ }
+ if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT) && glp.usesNativeGLES2()) {
+ return true;
+ }
+ if(0 != (renderableType & EGL.EGL_OPENGL_BIT) && !glp.usesNativeGLES()) {
+ return true;
+ }
+ return false;
+ }
+
+ public static GLProfile getCompatible(int renderableType) {
+ if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT) && GLProfile.isAvailable(GLProfile.GLES2)) {
+ return GLProfile.get(GLProfile.GLES2);
+ }
+ if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && GLProfile.isAvailable(GLProfile.GLES1)) {
+ return GLProfile.get(GLProfile.GLES1);
+ }
+ if(0 != (renderableType & EGL.EGL_OPENGL_BIT)) {
+ return GLProfile.getDefault();
+ }
+ return null;
+ }
+
+ public static StringBuffer renderableTypeToString(StringBuffer sink, int renderableType) {
+ if(null == sink) {
+ sink = new StringBuffer();
+ }
+ boolean first=true;
+ if(0 != (renderableType & EGL.EGL_OPENGL_BIT)) {
+ sink.append("GL"); first=false;
+ }
+ if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT)) {
+ if(!first) sink.append(", "); sink.append("GLES1"); first=false;
+ }
+ if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT)) {
+ if(!first) sink.append(", "); sink.append("GLES2"); first=false;
+ }
+ if(0 != (renderableType & EGL.EGL_OPENVG_API)) {
+ if(!first) sink.append(", "); sink.append("VG"); first=false;
+ }
+ return sink;
+ }
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
+ sink.append("0x").append(Long.toHexString(eglcfg)).append(", ");
sink.append("0x").append(Long.toHexString(eglcfgid)).append(": ");
- return super.toString(sink);
+ super.toString(sink);
+ sink.append(", [");
+ renderableTypeToString(sink, renderableType);
+ return sink.append("]");
}
} \ No newline at end of file
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index 4d8f2ac3e..2fad75b74 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -134,7 +134,7 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
}
public static EGLGLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, long config,
- boolean relaxed, boolean onscreen, boolean usePBuffer) {
+ boolean relaxed, boolean onscreen, boolean usePBuffer) {
ArrayList bucket = new ArrayList();
final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer);
if( EGLConfig2Capabilities(bucket, glp, display, config, winattrmask) ) {
@@ -165,9 +165,24 @@ public class EGLGraphicsConfiguration extends DefaultGraphicsConfiguration imple
}
return false;
}
- GLCapabilities caps = new EGLGLCapabilities(config, val[0], glp);
-
- // Read the actual configuration into the choosen caps
+
+ if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_RENDERABLE_TYPE, val, 0)) {
+ if(DEBUG) {
+ System.err.println("EGL couldn't retrieve EGL_RENDERABLE_TYPE for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError()));
+ }
+ return false;
+ }
+ EGLGLCapabilities caps = null;
+ try {
+ caps = new EGLGLCapabilities(config, val[0], glp, val[0]);
+ } catch (GLException gle) {
+ if(DEBUG) {
+ System.err.println("config "+toHexString(config)+": "+gle);
+ }
+ return false;
+ }
+
+ // Read the actual configuration into the chosen caps
if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_RED_SIZE, val, 0)) {
caps.setRedBits(val[0]);
}