aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/config/jogl/egl-CustomCCode.c26
-rw-r--r--make/config/jogl/egl-CustomJavaCode.java45
-rw-r--r--make/config/jogl/egl.cfg28
-rw-r--r--make/config/jogl/eglext.cfg2
-rwxr-xr-xmake/scripts/java-win.bat3
-rwxr-xr-xmake/scripts/tests-win.bat6
-rw-r--r--make/scripts/tests.sh5
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java129
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java50
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java103
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java4
14 files changed, 276 insertions, 136 deletions
diff --git a/make/config/jogl/egl-CustomCCode.c b/make/config/jogl/egl-CustomCCode.c
new file mode 100644
index 000000000..0163c6742
--- /dev/null
+++ b/make/config/jogl/egl-CustomCCode.c
@@ -0,0 +1,26 @@
+#include <stdio.h> /* android */
+#include <gluegen_stdint.h>
+#include <gluegen_stddef.h>
+#include <EGL/egl.h>
+
+/* Java->C glue code:
+ * Java package: jogamp.opengl.egl.EGL
+ * Java method: void eglGetConfigAttributes(long dpy, long config, IntBuffer attributes, IntBuffer values)
+ */
+Java_jogamp_opengl_egl_EGL_dispatch_1eglGetConfigAttributes(JNIEnv *env, jclass _unused, jlong dpy, jlong config, jint attributeCount, jobject attributes, jint attributes_byte_offset, jobject values, jint values_byte_offset, jlong procAddress) {
+ typedef EGLBoolean (EGLAPIENTRY*_local_PFNEGLGETCONFIGATTRIBPROC)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value);
+ _local_PFNEGLGETCONFIGATTRIBPROC ptr_eglGetConfigAttrib = (_local_PFNEGLGETCONFIGATTRIBPROC) (intptr_t) procAddress;
+ assert(ptr_eglGetConfigAttrib != NULL);
+
+ if ( attributeCount > 0 && NULL != attributes ) {
+ int i;
+ int * attributes_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, attributes)) + attributes_byte_offset);
+ EGLint * values_ptr = (EGLint *) (((char*) (*env)->GetDirectBufferAddress(env, values)) + values_byte_offset);
+ for(i=0; i<attributeCount; i++) {
+ if( 0 == (* ptr_eglGetConfigAttrib) ((EGLDisplay) (intptr_t) dpy, (EGLConfig) (intptr_t) config, (EGLint) attributes_ptr[i], (EGLint *) &values_ptr[i]) ) {
+ attributes_ptr[i] = 0;
+ }
+ }
+ }
+}
+
diff --git a/make/config/jogl/egl-CustomJavaCode.java b/make/config/jogl/egl-CustomJavaCode.java
new file mode 100644
index 000000000..15689b5d8
--- /dev/null
+++ b/make/config/jogl/egl-CustomJavaCode.java
@@ -0,0 +1,45 @@
+
+ private static EGLProcAddressTable _table = new EGLProcAddressTable(new GLProcAddressResolver());
+ public static void resetProcAddressTable(DynamicLookupHelper lookup) {
+ _table.reset(lookup);
+ }
+
+ // There are some #defines in egl.h that GlueGen and PCPP don't currently handle
+ public static final long EGL_DEFAULT_DISPLAY = 0;
+ public static final long EGL_NO_CONTEXT = 0;
+ public static final long EGL_NO_DISPLAY = 0;
+ public static final long EGL_NO_SURFACE = 0;
+ public static final int EGL_DONT_CARE = -1;
+ public static final int EGL_UNKNOWN = -1;
+
+ protected static long eglGetProcAddress(long eglGetProcAddressHandle, java.lang.String procname)
+ {
+ if (eglGetProcAddressHandle == 0) {
+ throw new GLException("Passed null pointer for method \"eglGetProcAddress\"");
+ }
+ return dispatch_eglGetProcAddress0(procname, eglGetProcAddressHandle);
+ }
+
+
+ /**
+ * In case of an error on a particualr attribute, the attribute in the attributes-buffer is set to 0.
+ * <p>
+ * Entry point to C language function: <code> EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value); </code> <br>Part of <code>EGL_VERSION_1_X</code>
+ * </p>
+ */
+ public static void eglGetConfigAttributes(long dpy, long config, IntBuffer attributes, IntBuffer values) {
+ if( attributes == null || values == null ) {
+ throw new RuntimeException("arrays buffers are null");
+ }
+ if( !Buffers.isDirect(attributes) || !Buffers.isDirect(values) ) {
+ throw new RuntimeException("arrays buffers are not direct");
+ }
+ if( attributes.remaining() > values.remaining() ) {
+ throw new RuntimeException("not enough values "+values+" for attributes "+attributes);
+ }
+ final long __addr = _table._addressof_eglGetConfigAttrib;
+ dispatch_eglGetConfigAttributes(dpy, config, attributes.remaining(), attributes, Buffers.getDirectBufferByteOffset(attributes),
+ values, Buffers.getDirectBufferByteOffset(values), __addr);
+ }
+ private static native void dispatch_eglGetConfigAttributes(long dpy, long config, int attributeCount, Object attributes, int attributes_byte_offset, Object values, int valuesOffset, long procAddr);
+
diff --git a/make/config/jogl/egl.cfg b/make/config/jogl/egl.cfg
index b30985076..94b67951d 100644
--- a/make/config/jogl/egl.cfg
+++ b/make/config/jogl/egl.cfg
@@ -25,31 +25,7 @@ GetProcAddressTableExpr _table
ArgumentIsString eglGetProcAddress 0
ReturnsString eglQueryString
-CustomCCode #include <stdio.h> /* android */
-CustomCCode #include <gluegen_stdint.h>
-CustomCCode #include <gluegen_stddef.h>
-CustomCCode #include <EGL/egl.h>
-
-CustomJavaCode EGL private static EGLProcAddressTable _table = new EGLProcAddressTable(new GLProcAddressResolver());
-CustomJavaCode EGL public static void resetProcAddressTable(DynamicLookupHelper lookup) {
-CustomJavaCode EGL _table.reset(lookup);
-CustomJavaCode EGL }
-
-# There are some #defines in egl.h that GlueGen and PCPP don't currently handle
-CustomJavaCode EGL public static final long EGL_DEFAULT_DISPLAY = 0;
-CustomJavaCode EGL public static final long EGL_NO_CONTEXT = 0;
-CustomJavaCode EGL public static final long EGL_NO_DISPLAY = 0;
-CustomJavaCode EGL public static final long EGL_NO_SURFACE = 0;
-CustomJavaCode EGL public static final int EGL_DONT_CARE = -1;
-CustomJavaCode EGL public static final int EGL_UNKNOWN = -1;
-CustomJavaCode EGL
-CustomJavaCode EGL protected static long eglGetProcAddress(long eglGetProcAddressHandle, java.lang.String procname)
-CustomJavaCode EGL {
-CustomJavaCode EGL if (eglGetProcAddressHandle == 0) {
-CustomJavaCode EGL throw new GLException("Passed null pointer for method \"eglGetProcAddress\"");
-CustomJavaCode EGL }
-CustomJavaCode EGL return dispatch_eglGetProcAddress0(procname, eglGetProcAddressHandle);
-CustomJavaCode EGL }
-
+IncludeAs CustomJavaCode EGL egl-CustomJavaCode.java
+IncludeAs CustomCCode egl-CustomCCode.c
Import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver
diff --git a/make/config/jogl/eglext.cfg b/make/config/jogl/eglext.cfg
index a7fb45409..7fccce716 100644
--- a/make/config/jogl/eglext.cfg
+++ b/make/config/jogl/eglext.cfg
@@ -17,6 +17,8 @@ NIODirectOnly __ALL__
ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/jogamp/opengl/egl/EGL.java
+IgnoreExtension EGL_VERSION_1_X
+
HierarchicalNativeOutput false
# Use a ProcAddressTable so we dynamically look up the routines
diff --git a/make/scripts/java-win.bat b/make/scripts/java-win.bat
index 47b8184b2..2b45ae517 100755
--- a/make/scripts/java-win.bat
+++ b/make/scripts/java-win.bat
@@ -1,4 +1,5 @@
-%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win.log 2>&1
+REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win.log 2>&1
+%J2RE_HOME%\bin\java -classpath %CP_ALL% %D_ARGS% %X_ARGS% %* > java-win.log 2>&1
tail java-win.log
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat
index 0632c24b0..8de40e1f4 100755
--- a/make/scripts/tests-win.bat
+++ b/make/scripts/tests-win.bat
@@ -17,7 +17,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedConte
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %*
-scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT %*
@@ -78,12 +78,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %*
-scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %*
+scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %*
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 6fbba6adf..63a3fa8c6 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -304,7 +304,8 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelGridAWT $*
+testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
@@ -385,7 +386,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $*
-testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $*
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index 1a881ee8a..4202c7454 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -354,7 +354,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
final IntBuffer attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(caps);
final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(caps);
if( EGL.eglChooseConfig(eglDisplay.getHandle(), attrs, configs, configs.capacity(), numConfigs) && numConfigs.get(0) > 0) {
- return EGLGraphicsConfigurationFactory.eglConfigs2GLCaps(eglDisplay, caps.getGLProfile(), configs, numConfigs.get(0), winattrmask, false /* forceTransparentFlag */);
+ return EGLGraphicsConfigurationFactory.eglConfigs2GLCaps(eglDisplay, caps.getGLProfile(), configs, numConfigs.get(0), winattrmask, false /* forceTransparentFlag */, false /* onlyFirstValid */);
}
}
return new ArrayList<GLCapabilitiesImmutable>(0);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index f3592c150..dd7bf99cb 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -185,31 +185,53 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
public static EGLGLCapabilities EGLConfig2Capabilities(EGLGraphicsDevice device, GLProfile glp, long config,
int winattrmask, boolean forceTransparentFlag) {
final long display = device.getHandle();
- final IntBuffer val = Buffers.newDirectIntBuffer(1);
final int cfgID;
final int rType;
final int visualID;
+ final int _attributes[] = {
+ EGL.EGL_CONFIG_ID, // 0
+ EGL.EGL_RENDERABLE_TYPE,
+ EGL.EGL_NATIVE_VISUAL_ID,
+ EGL.EGL_CONFIG_CAVEAT,
+ EGL.EGL_RED_SIZE, // 4
+ EGL.EGL_GREEN_SIZE,
+ EGL.EGL_BLUE_SIZE,
+ EGL.EGL_ALPHA_SIZE, // 7
+ EGL.EGL_STENCIL_SIZE, // 8
+ EGL.EGL_DEPTH_SIZE,
+ EGL.EGL_TRANSPARENT_TYPE, // 10
+ EGL.EGL_TRANSPARENT_RED_VALUE,
+ EGL.EGL_TRANSPARENT_GREEN_VALUE,
+ EGL.EGL_TRANSPARENT_BLUE_VALUE,
+ EGL.EGL_SAMPLES, // 14
+ EGLExt.EGL_COVERAGE_BUFFERS_NV, // 15
+ EGLExt.EGL_COVERAGE_SAMPLES_NV
+ };
+ final IntBuffer attributes = Buffers.newDirectIntBuffer(_attributes);
+ final IntBuffer values = Buffers.newDirectIntBuffer(attributes.remaining());
+ EGL.eglGetConfigAttributes(display, config, attributes, values);
+
// get the configID
- if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val)) {
+ if( EGL.EGL_CONFIG_ID != attributes.get(0) ) {
if(DEBUG) {
// FIXME: this happens on a ATI PC Emulation ..
System.err.println("EGL couldn't retrieve ConfigID for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError()));
}
return null;
}
- cfgID = val.get(0);
+ cfgID = values.get(0);
- if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_RENDERABLE_TYPE, val)) {
+ if( EGL.EGL_RENDERABLE_TYPE != attributes.get(1) ) {
if(DEBUG) {
System.err.println("EGL couldn't retrieve EGL_RENDERABLE_TYPE for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError()));
}
return null;
}
- rType = val.get(0);
+ rType = values.get(1);
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_NATIVE_VISUAL_ID, val)) {
- visualID = val.get(0);
+ if( EGL.EGL_NATIVE_VISUAL_ID == attributes.get(2) ) {
+ visualID = values.get(2);
} else {
visualID = VisualIDHolder.VID_UNDEFINED;
}
@@ -234,64 +256,69 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
return null;
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_CAVEAT, val)) {
- if( EGL.EGL_SLOW_CONFIG == val.get(0) ) {
+ if( EGL.EGL_CONFIG_CAVEAT == attributes.get(3) ) {
+ if( EGL.EGL_SLOW_CONFIG == values.get(3) ) {
caps.setHardwareAccelerated(false);
}
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_SAMPLES, val)) {
- caps.setSampleBuffers(val.get(0)>0?true:false);
- caps.setNumSamples(val.get(0));
+ // ALPHA shall be set at last - due to it's auto setting by the above (!opaque / samples)
+ if( EGL.EGL_RED_SIZE == attributes.get(4) ) {
+ caps.setRedBits(values.get(4));
}
- if(!caps.getSampleBuffers()) {
- // try NV_coverage_sample extension
- if(EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_BUFFERS_NV, val)) {
- if(val.get(0)>0 &&
- EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_SAMPLES_NV, val)) {
- caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample);
- caps.setSampleBuffers(true);
- caps.setNumSamples(val.get(0));
- }
- }
+ if( EGL.EGL_GREEN_SIZE == attributes.get(5) ) {
+ caps.setGreenBits(values.get(5));
+ }
+ if( EGL.EGL_BLUE_SIZE == attributes.get(6) ) {
+ caps.setBlueBits(values.get(6));
+ }
+ if( EGL.EGL_ALPHA_SIZE == attributes.get(7) ) {
+ caps.setAlphaBits(values.get(7));
+ }
+ if( EGL.EGL_STENCIL_SIZE == attributes.get(8) ) {
+ caps.setStencilBits(values.get(8));
}
- if(forceTransparentFlag) {
+ if( EGL.EGL_DEPTH_SIZE == attributes.get(9) ) {
+ caps.setDepthBits(values.get(9));
+ }
+ if( forceTransparentFlag ) {
caps.setBackgroundOpaque(false);
- } else if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_TYPE, val)) {
- caps.setBackgroundOpaque(val.get(0) != EGL.EGL_TRANSPARENT_RGB);
+ } else if( EGL.EGL_TRANSPARENT_TYPE == attributes.get(10) ) {
+ caps.setBackgroundOpaque(values.get(10) != EGL.EGL_TRANSPARENT_RGB);
}
if(!caps.isBackgroundOpaque()) {
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_RED_VALUE, val)) {
- caps.setTransparentRedValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
+ if( EGL.EGL_TRANSPARENT_RED_VALUE == attributes.get(11) ) {
+ final int v = values.get(11);
+ caps.setTransparentRedValue(EGL.EGL_DONT_CARE==v?-1:v);
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_GREEN_VALUE, val)) {
- caps.setTransparentGreenValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
+ if( EGL.EGL_TRANSPARENT_GREEN_VALUE == attributes.get(12) ) {
+ final int v = values.get(12);
+ caps.setTransparentGreenValue(EGL.EGL_DONT_CARE==v?-1:v);
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val)) {
- caps.setTransparentBlueValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
+ if( EGL.EGL_TRANSPARENT_BLUE_VALUE == attributes.get(13) ) {
+ final int v = values.get(13);
+ caps.setTransparentBlueValue(EGL.EGL_DONT_CARE==v?-1:v);
}
/** Not defined in EGL
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val)) {
- caps.setTransparentAlphaValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0));
+ if( EGL.EGL_TRANSPARENT_ALPHA_VALUE == attributes.get(??) ) {
+ final int v = values.get(??);
+ caps.setTransparentAlphaValue(EGL.EGL_DONT_CARE==v?-1:v);
} */
}
- // ALPHA shall be set at last - due to it's auto setting by the above (!opaque / samples)
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_RED_SIZE, val)) {
- caps.setRedBits(val.get(0));
- }
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_GREEN_SIZE, val)) {
- caps.setGreenBits(val.get(0));
- }
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_BLUE_SIZE, val)) {
- caps.setBlueBits(val.get(0));
- }
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_ALPHA_SIZE, val)) {
- caps.setAlphaBits(val.get(0));
- }
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_STENCIL_SIZE, val)) {
- caps.setStencilBits(val.get(0));
+ if( EGL.EGL_SAMPLES == attributes.get(14) ) {
+ final int numSamples = values.get(14);
+ caps.setSampleBuffers(numSamples>0?true:false);
+ caps.setNumSamples(numSamples);
}
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_DEPTH_SIZE, val)) {
- caps.setDepthBits(val.get(0));
+ if(!caps.getSampleBuffers()) {
+ // try NV_coverage_sample extension
+ if( EGLExt.EGL_COVERAGE_BUFFERS_NV == attributes.get(15) ) {
+ final boolean enabled = values.get(15) > 0;
+ if( enabled && EGLExt.EGL_COVERAGE_SAMPLES_NV == attributes.get(16) ) {
+ caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(values.get(16));
+ }
+ }
}
// Since the passed GLProfile may be null,
@@ -430,6 +457,6 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
}
- private GLCapabilitiesChooser chooser;
+ private final GLCapabilitiesChooser chooser;
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index 54510b51a..568fede45 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -42,7 +42,6 @@ import javax.media.nativewindow.GraphicsConfigurationFactory;
import javax.media.nativewindow.VisualIDHolder;
import javax.media.nativewindow.VisualIDHolder.VIDType;
import javax.media.nativewindow.NativeWindowFactory;
-
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
@@ -208,7 +207,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
throw new GLException("Graphics configuration get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError()));
}
if (numConfigs.get(0) > 0) {
- availableCaps = eglConfigs2GLCaps(eglDevice, null, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, false);
+ availableCaps = eglConfigs2GLCaps(eglDevice, null, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, false /* forceTransparentFlag */, false /* onlyFirstValid */);
if( null != availableCaps && availableCaps.size() > 1) {
Collections.sort(availableCaps, EglCfgIDComparator);
}
@@ -343,13 +342,14 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
if(0 == numConfigs.get(0)) {
throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: Get maxConfigs (eglGetConfigs) no configs");
}
+ final int numEGLConfigs = numConfigs.get(0);
if (DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig eglDisplay "+toHexString(eglDisplay)+
", nativeVisualID "+toHexString(nativeVisualID)+
", capsChosen "+capsChosen+", winbits "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrmask).toString()+
", fboAvail "+GLContext.isFBOAvailable(device, glp)+
", device "+device+", "+device.getUniqueID()+
- ", numConfigs "+numConfigs.get(0));
+ ", numEGLConfigs "+numEGLConfigs);
}
final IntBuffer attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen);
@@ -358,24 +358,42 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
// 1st choice: get GLCapabilities based on users GLCapabilities
// setting recommendedIndex as preferred choice
// skipped if nativeVisualID is given
- if( VisualIDHolder.VID_UNDEFINED != nativeVisualID || !EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) {
+ final boolean hasEGLChosenCaps;
+ if( VisualIDHolder.VID_UNDEFINED == nativeVisualID ) {
+ if( !EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) {
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: false");
+ }
+ numConfigs.put(0, 0);
+ hasEGLChosenCaps = false;
+ } else {
+ hasEGLChosenCaps = numConfigs.get(0)>0;
+ }
+ } else {
if(DEBUG) {
- System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: false");
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: Skipped due to given visualID: "+toHexString(nativeVisualID));
}
- } else if (numConfigs.get(0) > 0) {
- availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag);
+ hasEGLChosenCaps = false;
+ }
+ final boolean useRecommendedIndex = hasEGLChosenCaps && !forceTransparentFlag && capsChosen.isBackgroundOpaque(); // only use recommended idx if not translucent
+ final boolean skipCapsChooser = null == chooser && useRecommendedIndex; // fast path: skip choosing if using recommended idx and null chooser is used
+ if( hasEGLChosenCaps ) {
+ availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag, skipCapsChooser /* onlyFirsValid */);
if(availableCaps.size() > 0) {
recommendedEGLConfig = configs.get(0);
recommendedIndex = 0;
if (DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: recommended fbcfg " + toHexString(recommendedEGLConfig) + ", idx " + recommendedIndex);
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser);
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 fbcfg caps " + availableCaps.get(recommendedIndex));
}
} else if (DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: no caps for recommended fbcfg " + toHexString(configs.get(0)));
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser);
}
} else if (DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: no configs");
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser);
}
// 2nd choice: get all GLCapabilities available, no preferred recommendedIndex available
@@ -388,7 +406,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: #2 Get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError()));
}
if (numConfigs.get(0) > 0) {
- availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag);
+ availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag, false /* onlyFirsValid */);
}
}
@@ -396,7 +414,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
if(DEBUG) {
// FIXME: this happens on a ATI PC Emulation ..
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #2 Graphics configuration 1st choice and 2nd choice failed - no configs");
- availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag);
+ availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag, false /* onlyFirsValid */);
printCaps("AllCaps", availableCaps, System.err);
}
return null;
@@ -409,7 +427,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
}
- if( VisualIDHolder.VID_UNDEFINED != nativeVisualID ) {
+ if( VisualIDHolder.VID_UNDEFINED != nativeVisualID ) { // implies !hasEGLChosenCaps
List<GLCapabilitiesImmutable> removedCaps = new ArrayList<GLCapabilitiesImmutable>();
for(int i=0; i<availableCaps.size(); ) {
final GLCapabilitiesImmutable aCap = availableCaps.get(i);
@@ -437,7 +455,12 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
}
- final int chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex);
+ final int chosenIndex;
+ if( skipCapsChooser && 0 <= recommendedIndex ) {
+ chosenIndex = recommendedIndex;
+ } else {
+ chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex);
+ }
if ( 0 > chosenIndex ) {
if (DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #2 chooseCapabilities failed");
@@ -452,12 +475,15 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
return res;
}
- static List<GLCapabilitiesImmutable> eglConfigs2GLCaps(EGLGraphicsDevice device, GLProfile glp, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag) {
+ static List<GLCapabilitiesImmutable> eglConfigs2GLCaps(EGLGraphicsDevice device, GLProfile glp, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag, boolean onlyFirstValid) {
List<GLCapabilitiesImmutable> bucket = new ArrayList<GLCapabilitiesImmutable>(num);
for(int i=0; i<num; i++) {
final GLCapabilitiesImmutable caps = EGLGraphicsConfiguration.EGLConfig2Capabilities(device, glp, configs.get(i), winattrmask, forceTransparentFlag);
if(null != caps) {
bucket.add(caps);
+ if(onlyFirstValid) {
+ break;
+ }
}
}
return bucket;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java
index dac058dc7..dac85e753 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java
@@ -157,7 +157,7 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize {
} else {
final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex());
eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
- capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false);
+ capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false /* forceTransparencyFlag */);
if (null == eglConfig) {
throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen);
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 5f2b0c227..5dd9f88b2 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -62,7 +62,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
protected static final int MAX_PFORMATS = 256;
protected static final int MAX_ATTRIBS = 256;
- private GLCapabilitiesChooser chooser;
+ private final GLCapabilitiesChooser chooser;
private boolean isDetermined = false;
private boolean isExternal = false;
@@ -370,7 +370,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
}
static List <GLCapabilitiesImmutable> wglARBPFIDs2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource,
- AbstractGraphicsDevice device, GLProfile glp, long hdc, int[] pfdIDs, int winattrbits) {
+ AbstractGraphicsDevice device, GLProfile glp, long hdc, int[] pfdIDs, int winattrbits, boolean onlyFirstValid) {
if (!sharedResource.hasARBPixelFormat()) {
return null;
}
@@ -392,6 +392,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
final int j = bucket.size() - 1;
System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> "+j+"]: "+caps);
}
+ if( onlyFirstValid ) {
+ break;
+ }
} else if(DEBUG) {
GLCapabilitiesImmutable skipped = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, GLGraphicsConfigurationUtil.ALL_BITS);
System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> skip]: pfdID "+pfdIDs[i]+", "+skipped+", winattr "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString());
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index 961295208..67ead3827 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -112,7 +112,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
final AbstractGraphicsDevice absDevice = absScreen.getDevice();
capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getDesktopFactory(), absDevice);
- return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, (GLCapabilitiesChooser)chooser );
+ return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, chooser );
}
protected static List<GLCapabilitiesImmutable> getAvailableCapabilities(WindowsWGLDrawableFactory factory, AbstractGraphicsDevice device) {
@@ -168,7 +168,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
final int pfdIDCount = WindowsWGLGraphicsConfiguration.wglARBPFDIDCount((WindowsWGLContext)sharedResource.getContext(), hdc);
final int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFDIDs(pfdIDCount);
return WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats,
- GLGraphicsConfigurationUtil.ALL_BITS & ~GLGraphicsConfigurationUtil.BITMAP_BIT); // w/o BITMAP
+ GLGraphicsConfigurationUtil.ALL_BITS & ~GLGraphicsConfigurationUtil.BITMAP_BIT, false); // w/o BITMAP
}
private static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesGDI(AbstractGraphicsDevice device, GLProfile glProfile, long hdc, boolean bitmapOnly) {
@@ -365,7 +365,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque);
} else {
int recommendedIndex = -1; // recommended index
-
if(null == pformats) {
// No given PFD IDs
//
@@ -406,9 +405,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
return false;
}
}
+ final boolean skipCapsChooser = 0 <= recommendedIndex && null == chooser && capsChosen.isBackgroundOpaque(); // fast path: skip choosing if using recommended idx and null chooser is used and if not translucent
- List<GLCapabilitiesImmutable> availableCaps =
- WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, winattrbits);
+ final List<GLCapabilitiesImmutable> availableCaps =
+ WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, winattrbits, skipCapsChooser /* onlyFirstValid */);
if( null == availableCaps || 0 == availableCaps.size() ) {
if (DEBUG) {
@@ -420,14 +420,19 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
if (DEBUG) {
System.err.println("updateGraphicsConfigurationARB: " + pformats.length +
- " pfd ids, " + GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString() + ", " + availableCaps.size() + " glcaps");
+ " pfd ids, skipCapsChooser " + skipCapsChooser + ", " + GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString() + ", " + availableCaps.size() + " glcaps");
if(0 <= recommendedIndex) {
System.err.println("updateGraphicsConfigurationARB: Used wglChoosePixelFormatARB to recommend pixel format " +
pformats[recommendedIndex] + ", idx " + recommendedIndex +", "+availableCaps.get(recommendedIndex));
}
}
- int chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex);
+ final int chosenIndex;
+ if( skipCapsChooser ) {
+ chosenIndex = recommendedIndex;
+ } else {
+ chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex);
+ }
if ( 0 > chosenIndex ) {
if (DEBUG) {
Thread.dumpStack();
@@ -438,12 +443,12 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
if( null == pixelFormatCaps) {
throw new GLException("Null Capabilities with "+
" chosen pfdID: native recommended "+ (recommendedIndex+1) +
- " chosen idx "+chosenIndex);
+ " chosen idx "+chosenIndex+", skipCapsChooser "+skipCapsChooser);
}
pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque);
if (DEBUG) {
System.err.println("chosen pfdID (ARB): native recommended "+ (recommendedIndex+1) +
- " chosen "+pixelFormatCaps);
+ " chosen "+pixelFormatCaps+", skipCapsChooser "+skipCapsChooser);
}
}
@@ -457,7 +462,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
private static boolean updateGraphicsConfigurationGDI(WindowsWGLGraphicsConfiguration config, CapabilitiesChooser chooser, long hdc,
boolean extHDC, int[] pformats) {
- GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+ final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities();
if( !capsChosen.isOnscreen() && capsChosen.isPBuffer() ) {
if (DEBUG) {
System.err.println("updateGraphicsConfigurationGDI: no pbuffer supported on GDI: " + capsChosen);
@@ -473,7 +478,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
System.err.println("updateGraphicsConfigurationGDI: capsChosen "+capsChosen+", "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrmask).toString());
}
- AbstractGraphicsDevice device = config.getScreen().getDevice();
+ final AbstractGraphicsDevice device = config.getScreen().getDevice();
int pfdID; // chosen or preset PFD ID
WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps
boolean pixelFormatSet = false; // indicates a preset PFD ID [caps]
@@ -498,43 +503,67 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
pformats = WindowsWGLGraphicsConfiguration.wglAllGDIPFIDs(hdc);
}
- List<GLCapabilitiesImmutable> availableCaps = new ArrayList<GLCapabilitiesImmutable>();
- for (int i = 0; i < pformats.length; i++) {
- final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], winattrmask);
- if(null != caps) {
- availableCaps.add(caps);
- if(DEBUG) {
- final int j = availableCaps.size() - 1;
- System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> "+j+"]: "+caps);
- }
- } else if(DEBUG) {
- GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, hdc, pformats[i]);
- System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> skip]: pfdID "+pformats[i]+", "+skipped);
- }
- }
-
// 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice
+ final List<GLCapabilitiesImmutable> availableCaps = new ArrayList<GLCapabilitiesImmutable>();
PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor();
pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(capsChosen, pfd);
pfdID = WGLUtil.ChoosePixelFormat(hdc, pfd);
int recommendedIndex = -1 ;
+ final boolean skipCapsChooser;
if( 1 <= pfdID ) {
+ final boolean _skipCapsChooser = null == chooser && capsChosen.isBackgroundOpaque(); // fast path: skip choosing if using recommended idx and null chooser is used and if not translucent
// seek index .. in all formats _or_ in given formats!
- for (recommendedIndex = availableCaps.size() - 1 ;
- 0 <= recommendedIndex && pfdID != ((WGLGLCapabilities) availableCaps.get(recommendedIndex)).getPFDID();
- recommendedIndex--)
- { /* nop */ }
- if(DEBUG && 0 > recommendedIndex) {
- final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, pfd, pfdID);
- final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask);
- System.err.println("Chosen PFDID "+pfdID+", but not found in available caps (use given pfdIDs "+givenPFormats+", reqPFDCaps "+reqPFDCaps+", chosenCaps: "+chosenCaps);
+ int i;
+ for (i = pformats.length - 1 ; 0 <= i && pfdID != pformats[i]; i--) { /* nop */ }
+ if( 0 <= i ) {
+ if( _skipCapsChooser ) {
+ final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask);
+ availableCaps.add(caps);
+ recommendedIndex = 0;
+ skipCapsChooser = true;
+ } else {
+ recommendedIndex = i;
+ skipCapsChooser = false;
+ }
+ } else {
+ if(DEBUG) {
+ final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, pfd, pfdID);
+ final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask);
+ System.err.println("Chosen PFDID "+pfdID+", but not found in available caps (use given pfdIDs "+givenPFormats+", reqPFDCaps "+reqPFDCaps+", chosenCaps: "+chosenCaps);
+ }
+ skipCapsChooser = false;
}
+ } else {
+ skipCapsChooser = false;
}
if (DEBUG) {
- System.err.println("updateGraphicsConfigurationGDI: ChoosePixelFormat(HDC " + toHexString(hdc) + ") = pfdID " + pfdID + ", idx " + recommendedIndex + " (LastError: " + GDI.GetLastError() + ")");
+ System.err.println("updateGraphicsConfigurationGDI: ChoosePixelFormat(HDC " + toHexString(hdc) + ") = pfdID " + pfdID + ", skipCapsChooser "+skipCapsChooser+", idx " + recommendedIndex + " (LastError: " + GDI.GetLastError() + ")");
+ }
+
+ if( !skipCapsChooser ) {
+ for (int i = 0; i < pformats.length; i++) {
+ final int pfdid = pformats[i];
+ final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdid, winattrmask);
+ if(null != caps) {
+ availableCaps.add(caps);
+ if(DEBUG) {
+ final int j = availableCaps.size() - 1;
+ System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> "+j+"]: "+caps);
+ }
+ } else if(DEBUG) {
+ GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, hdc, pformats[i]);
+ System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> skip]: pfdID "+pformats[i]+", "+skipped);
+ }
+ }
}
+
// 2nd choice: if no preferred recommendedIndex available
- int chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex);
+ final int chosenIndex;
+ if( skipCapsChooser ) {
+ chosenIndex = recommendedIndex;
+ } else {
+ chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex);
+ }
if ( 0 > chosenIndex ) {
if (DEBUG) {
System.err.println("updateGraphicsConfigurationGDI: failed, return false");
@@ -544,7 +573,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
pixelFormatCaps = (WGLGLCapabilities) availableCaps.get(chosenIndex);
if (DEBUG) {
- System.err.println("chosen pfdID (GDI): chosenIndex "+ chosenIndex + ", caps " + pixelFormatCaps +
+ System.err.println("chosen pfdID (GDI): chosenIndex "+ chosenIndex + ", skipCapsChooser "+skipCapsChooser+", caps " + pixelFormatCaps +
" (" + WGLGLCapabilities.PFD2String(pixelFormatCaps.getPFD(), pixelFormatCaps.getPFDID()) +")");
}
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 5c84597d5..1f92960bc 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -306,11 +306,13 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
recommendedIndex = useRecommendedIndex ? 0 : -1;
if (DEBUG) {
System.err.println("glXChooseFBConfig recommended fbcfg " + toHexString(fbcfgsL.get(0)) + ", idx " + recommendedIndex);
+ System.err.println("useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser);
System.err.println("user caps " + capsChosen);
- System.err.println("fbcfg caps " + availableCaps.get(0));
+ System.err.println("fbcfg caps " + fbcfgsL.limit()+", availCaps "+availableCaps.get(0));
}
} else if (DEBUG) {
System.err.println("glXChooseFBConfig no caps for recommended fbcfg " + toHexString(fbcfgsL.get(0)));
+ System.err.println("useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser);
System.err.println("user caps " + capsChosen);
}
} else {