summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-05 04:34:41 +0100
committerSven Gothel <[email protected]>2012-03-05 04:34:41 +0100
commit90c46b1ef1f199ceb63e85c85e9ebeb919d49c4a (patch)
treeded4b93e80eb39ff33c80638c10a531222c105a3
parent875042340b68137b584907c539b7b7ecc5c5b15c (diff)
Complete LOCK_SURFACE_CHANGED ; Introduce NativeVisualID (Daisy chaining *GraphicsConfiguration) ; ...
NativeVisualID: New interface for Capabilities implementations, allowing retrieval of the native 'visual id'. Impl. by WGL, X11 and EGL. JAWTWindow.lockSurface() - Detect surfaceHandle change an return LOCK_SURFACE_CHANGED (see: LOCK_SURFACE_CHANGED) EGLDrawable: - Impl. updateHandle() (see: LOCK_SURFACE_CHANGED) - use NativeVisualID for EGLGraphicsConfiguration selection to respect a native 'visual id' EGLContext.createContextImpl: Use NIO for attributes EGLDisplayUtil: Enhance eglGetDisplay w/ DEBUG code and NativeSurface / EGL_DEFAULT_DISPLAY variation EGL, XGL, WGL GraphicsConfiguration: - Don't set ALPHA_SIZE and STENCIL_SIZE if not requested in attribute list for context creation. - toString() shows proper identification, eg.: egl, x11, win32 .. EGLGraphicsConfigurationFactory: Daisy chain GraphicsConfigurationFactory for native device type (currently only X11). This allows choosing the EGLGraphicsConfiguration and hence native visual id based on EGL when invoked via the factory model (generic). In case EGLGraphicsConfigurationFactory is not suitable or doesn't produce a native visual id, it falls back the the original one. X11AWTGraphicsConfigurationFactory and X11Window: Use generic NativeVisualID which allows EGLGraphicsConfiguration implicit. *GraphicsConfiguration's DEBUG flag is pushed up to DefaultGraphicsConfiguration LOCK_SURFACE_CHANGED: - commit 006e9fe402a0a47b45fd2c4af51296aef895e8b5 - commit a0177c8a1048683e5d43f4712f8f9e37091d4e85 Impact: - Fixes EGL/GLES (wrapper/native) usage on X11, proper Xvisual selection w/ EGL - Fixes EGL/GLES (wrapper/native) usage on Windows, ANGLE works w/ NEWT and forced ES2
-rwxr-xr-xmake/scripts/java-win32.bat8
-rwxr-xr-xmake/scripts/make.jogl.all.linux-armv7-cross.sh5
-rwxr-xr-xmake/scripts/make.jogl.all.linux-armv7.sh1
-rwxr-xr-xmake/scripts/targetcommand-awt.sh4
-rwxr-xr-xmake/scripts/targetcommand-newt.sh14
-rwxr-xr-xmake/scripts/tests-x32.bat4
-rwxr-xr-xmake/scripts/tests.sh21
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableImpl.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java37
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java28
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java70
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java204
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java17
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java21
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java102
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java26
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java2
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java4
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java78
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java11
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java33
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Window.java11
-rw-r--r--src/newt/native/X11Window.c18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java53
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java44
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java9
37 files changed, 613 insertions, 322 deletions
diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat
index c0467950e..6dc0f3c36 100755
--- a/make/scripts/java-win32.bat
+++ b/make/scripts/java-win32.bat
@@ -4,8 +4,12 @@ set J2RE_HOME=c:\jre1.6.0_30_x32
set JAVA_HOME=c:\jdk1.6.0_30_x32
set ANT_PATH=C:\apache-ant-1.8.2
-set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
-REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\angle\win32;%PATH%
+set PROJECT_ROOT=D:\projects\jogamp\jogl
+set BLD_DIR=..\%BLD_SUB%
+
+REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\angle\win32;%PATH%
+REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH%
set BLD_DIR=..\%BLD_SUB%
REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib
diff --git a/make/scripts/make.jogl.all.linux-armv7-cross.sh b/make/scripts/make.jogl.all.linux-armv7-cross.sh
index e3209d899..958ece19b 100755
--- a/make/scripts/make.jogl.all.linux-armv7-cross.sh
+++ b/make/scripts/make.jogl.all.linux-armv7-cross.sh
@@ -6,6 +6,7 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then
. $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh
fi
+# arm-linux-gnueabi == armel triplet
PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH
export PATH
@@ -28,8 +29,8 @@ export TARGET_IP=panda01
export TARGET_ROOT=/home/jogamp/projects-cross
export TARGET_ANT_HOME=/usr/share/ant
-export TARGET_PLATFORM_LIBS=/opt-linux-armv7-eabi/lib
-export TARGET_JAVA_LIBS=/opt-linux-armv7-eabi/jre/lib/arm
+export TARGET_PLATFORM_LIBS=/opt-linux-armv7-armel/usr/lib
+export TARGET_JAVA_LIBS=/opt-linux-armv7-armel/jre/lib/arm
export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv7.xml"
diff --git a/make/scripts/make.jogl.all.linux-armv7.sh b/make/scripts/make.jogl.all.linux-armv7.sh
index 203faf16c..16048c8af 100755
--- a/make/scripts/make.jogl.all.linux-armv7.sh
+++ b/make/scripts/make.jogl.all.linux-armv7.sh
@@ -1,5 +1,6 @@
#! /bin/sh
+# arm-linux-gnueabi == armel triplet
PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH
export PATH
diff --git a/make/scripts/targetcommand-awt.sh b/make/scripts/targetcommand-awt.sh
index e50e6c8a2..af3b5f775 100755
--- a/make/scripts/targetcommand-awt.sh
+++ b/make/scripts/targetcommand-awt.sh
@@ -2,8 +2,8 @@
THISDIR=`pwd`
-#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Djogl.debug.GLDrawable"
-XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode"
+#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode"
+XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable"
#XTRA_FLAGS="-Dnewt.debug.Screen"
#XTRA_FLAGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow"
#XTRA_FLAGS="-Dnewt.debug.Window -Djogl.debug.EGL -Djogl.debug.GLContext -Djogl.debug.GLDrawable"
diff --git a/make/scripts/targetcommand-newt.sh b/make/scripts/targetcommand-newt.sh
index 5933b6a79..47b7a0b80 100755
--- a/make/scripts/targetcommand-newt.sh
+++ b/make/scripts/targetcommand-newt.sh
@@ -2,7 +2,11 @@
THISDIR=`pwd`
-XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode"
+export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH
+
+XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch "
+#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL"
+#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable"
#XTRA_FLAGS="-Dnewt.debug.Screen"
#XTRA_FLAGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow"
#XTRA_FLAGS="-Dnewt.debug.Window -Djogl.debug.EGL -Djogl.debug.GLContext -Djogl.debug.GLDrawable"
@@ -22,7 +26,7 @@ XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode"
#TSTCLASS=com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 # (Tegra regressions)
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT
-#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT
+TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT
# Some Regressions (Panda, Omap4)
@@ -36,7 +40,7 @@ XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode"
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2
-TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT
+#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT
@@ -80,6 +84,8 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT
jogamp@jogamp02::PROJECTS/JOGL/gluegen jogamp@jogamp02::PROJECTS/JOGL/jogl $THISDIR/projects-cross
cd $THISDIR/projects-cross/jogl/make
+
+ cp -a $THISDIR/pvrtrace.cfg .
function junit_run() {
java \
@@ -113,4 +119,6 @@ function main_run() {
# junit_run 2>&1 | tee $THISDIR/targetcommand.log
main_run $* 2>&1 | tee $THISDIR/targetcommand.log
+
+cp -a trace-*.pvrt $THISDIR/
diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat
index db9336072..6afbfde28 100755
--- a/make/scripts/tests-x32.bat
+++ b/make/scripts/tests-x32.bat
@@ -10,14 +10,14 @@ REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon
REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %*
REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %*
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %*
-scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %*
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %*
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %*
+scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %*
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %*
REM scripts\java-win32.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-win32.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %*
+REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT %*
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %*
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT -time 5000
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index c2905ea2e..903c88623 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -50,6 +50,14 @@ function jrun() {
swton=$1
shift
+ #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch"
+ #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all"
+ #D_ARGS="-Djogl.debug.GLDebugMessageHandler"
+ #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL"
+ #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState"
+ #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL"
+ #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode"
+ #D_ARGS="-Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable"
#D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen"
#D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true"
#D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
@@ -97,14 +105,6 @@ function jrun() {
#D_ARGS="-Djogl.debug.GraphicsConfiguration"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GraphicsConfiguration"
#D_ARGS="-Djogl.debug.GLCanvas"
- #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.GLDebugMessageHandler -Djogl.debug.GLSLCode"
- #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all"
- #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
- #D_ARGS="-Djogl.debug.GLDebugMessageHandler"
- #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL"
- #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState"
- #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL"
- #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL"
#D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock"
#D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL"
#D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState"
@@ -153,6 +153,7 @@ function jrun() {
#LIBGL_DRIVERS_PATH=/usr/lib/mesa:/usr/lib32/mesa \
#LD_LIBRARY_PATH=/usr/lib/mesa:/usr/lib32/mesa:$LD_LIBRARY_PATH \
#LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa:/usr/lib/i386-linux-gnu/mesa:$LD_LIBRARY_PATH \
+ #LD_LIBRARY_PATH=$spath/../lib/PVRVFrame/OGLES-2.0/Linux_x86_64:$LD_LIBRARY_PATH \
#LD_LIBRARY_PATH=$spath/../lib/PVRVFrame/OGLES-2.0/Linux_x86_32:$LD_LIBRARY_PATH \
$javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $*
echo
@@ -205,7 +206,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $*
@@ -214,7 +215,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT
#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $*
-testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
index ba64127d4..36f17e5a1 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
@@ -135,12 +135,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
protected void destroyHandle() {}
/** called with locked surface @ setRealized(true) or @ lockSurface(..) when surface changed */
- protected void updateHandle() {
- if(DEBUG) {
- System.err.println(getThreadName() + ": updateHandle: "+getClass().getSimpleName()+": "+this);
- Thread.dumpStack();
- }
- }
+ protected void updateHandle() {}
public long getHandle() {
return surface.getSurfaceHandle();
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 9028f4377..dcef1cd3d 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -37,6 +37,7 @@
package jogamp.opengl.egl;
import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
import java.util.Map;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
@@ -48,6 +49,7 @@ import javax.media.opengl.GLProfile;
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableImpl;
+import com.jogamp.common.nio.Buffers;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
@@ -160,7 +162,7 @@ public abstract class EGLContext extends GLContextImpl {
try {
// might be unavailable on EGL < 1.2
if(!EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API)) {
- throw new GLException("eglBindAPI to ES failed , error 0x"+Integer.toHexString(EGL.eglGetError()));
+ throw new GLException("Catched: eglBindAPI to ES failed , error 0x"+Integer.toHexString(EGL.eglGetError()));
}
} catch (GLException glex) {
if (DEBUG) {
@@ -175,18 +177,22 @@ public abstract class EGLContext extends GLContextImpl {
}
}
- int[] contextAttrs = new int[] {
- EGL.EGL_CONTEXT_CLIENT_VERSION, -1,
- EGL.EGL_NONE
- };
- if (glProfile.usesNativeGLES2()) {
- contextAttrs[1] = 2;
- } else if (glProfile.usesNativeGLES1()) {
- contextAttrs[1] = 1;
- } else {
- throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile);
+ final IntBuffer contextAttrsNIO;
+ {
+ final int[] contextAttrs = new int[] {
+ EGL.EGL_CONTEXT_CLIENT_VERSION, -1,
+ EGL.EGL_NONE
+ };
+ if (glProfile.usesNativeGLES2()) {
+ contextAttrs[1] = 2;
+ } else if (glProfile.usesNativeGLES1()) {
+ contextAttrs[1] = 1;
+ } else {
+ throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile);
+ }
+ contextAttrsNIO = Buffers.newDirectIntBuffer(contextAttrs);
}
- contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWithHandle, contextAttrs, 0);
+ contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWithHandle, contextAttrsNIO);
if (contextHandle == 0) {
throw new GLException("Error creating OpenGL context: eglDisplay "+toHexString(eglDisplay)+
", eglConfig "+config+", "+glProfile+", shareWith "+toHexString(shareWithHandle)+", error "+toHexString(EGL.eglGetError()));
@@ -277,6 +283,13 @@ public abstract class EGLContext extends GLContextImpl {
public abstract void releasePbufferFromTexture();
+ protected static String toHexString(int hex) {
+ return GLContext.toHexString(hex);
+ }
+ protected static String toHexString(long hex) {
+ return GLContext.toHexString(hex);
+ }
+
//----------------------------------------------------------------------
// Currently unimplemented stuff
//
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
index 207a8e674..e09400c09 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
@@ -30,6 +30,9 @@ package jogamp.opengl.egl;
import java.nio.IntBuffer;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+
import jogamp.opengl.Debug;
import com.jogamp.common.util.LongIntHashMap;
@@ -55,7 +58,30 @@ public class EGLDisplayUtil {
}
public static long eglGetDisplay(long nativeDisplay_id) {
- return EGL.eglGetDisplay(nativeDisplay_id);
+ final long eglDisplay = EGL.eglGetDisplay(nativeDisplay_id);
+ if(DEBUG) {
+ System.err.println("EGLDisplayUtil.eglGetDisplay(): eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+
+ EGLContext.toHexString(eglDisplay)+
+ ", "+((EGL.EGL_NO_DISPLAY != eglDisplay)?"OK":"Failed"));
+ }
+ return eglDisplay;
+ }
+
+ public static long eglGetDisplay(NativeSurface surface, boolean allowFallBackToDefault) {
+ final long nDisplay;
+ if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
+ nDisplay = surface.getSurfaceHandle(); // don't even ask ..
+ } else {
+ nDisplay = surface.getDisplayHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY
+ }
+ long eglDisplay = EGLDisplayUtil.eglGetDisplay(nDisplay);
+ if (eglDisplay == EGL.EGL_NO_DISPLAY && nDisplay != EGL.EGL_DEFAULT_DISPLAY && allowFallBackToDefault) {
+ if(DEBUG) {
+ System.err.println("EGLDisplayUtil.eglGetDisplay(): Fall back to EGL_DEFAULT_DISPLAY");
+ }
+ eglDisplay = EGLDisplayUtil.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ }
+ return eglDisplay;
}
public static synchronized boolean eglInitialize(long eglDisplay, int[] major, int major_offset, int[] minor, int minor_offset) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
index 5c73b822c..32055c5e0 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
@@ -36,6 +36,8 @@
package jogamp.opengl.egl;
+import jogamp.nativewindow.NativeVisualID;
+import jogamp.nativewindow.NativeVisualID.NVIDType;
import jogamp.opengl.GLDynamicLookupHelper;
import jogamp.opengl.GLDrawableImpl;
@@ -113,6 +115,13 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
}
+ @Override
+ protected final void updateHandle() {
+ if(ownEGLSurface) {
+ recreateSurface();
+ }
+ }
+
protected void setRealizedImpl() {
if (realized) {
AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration();
@@ -141,9 +150,8 @@ public abstract class EGLDrawable extends GLDrawableImpl {
System.err.println(getThreadName() + ": setSurface re-using component's EGLSurface: handle "+toHexString(eglSurface));
}
} else {
- // EGLSurface is ours ..
+ // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface();
ownEGLSurface=true;
- recreateSurface();
}
} else {
throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig);
@@ -157,43 +165,44 @@ public abstract class EGLDrawable extends GLDrawableImpl {
// EGLSurface is ours ..
ownEGLSurface=true;
- long nDisplay=0;
- if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
- nDisplay = surface.getSurfaceHandle(); // don't even ask ..
- } else {
- nDisplay = aDevice.getHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY
- }
- eglDisplay = EGLDisplayUtil.eglGetDisplay(nDisplay);
+ eglDisplay = EGLDisplayUtil.eglGetDisplay(surface, true);
if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- if(DEBUG) {
- System.err.println(getThreadName() + ": eglDisplay("+toHexString(nDisplay)+" <surfaceHandle>): failed, using EGL_DEFAULT_DISPLAY");
- }
- nDisplay = EGL.EGL_DEFAULT_DISPLAY;
- eglDisplay = EGLDisplayUtil.eglGetDisplay(nDisplay);
- }
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Failed to created EGL display: nhandle "+toHexString(nDisplay)+", "+aDevice+", error "+toHexString(EGL.eglGetError()));
- } else if(DEBUG) {
- System.err.println(getThreadName() + ": eglDisplay("+toHexString(nDisplay)+"): "+toHexString(eglDisplay));
+ throw new GLException("Failed to created EGL display: "+surface+", "+aDevice+", error "+toHexString(EGL.eglGetError()));
}
if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) {
throw new GLException("eglInitialize failed"+", error "+Integer.toHexString(EGL.eglGetError()));
}
EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
- DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
- // use the original requested Capabilities, ignore previously chosen ones (x11,win32,..) - they are not fit
+ AbstractGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities();
- eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(
- capsRequested, capsRequested, null, s);
- if (null == eglConfig) {
- throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
- } else if(DEBUG) {
- System.err.println(getThreadName() + ": Chosen eglConfig: "+eglConfig);
+ if(aConfig instanceof EGLGraphicsConfiguration) {
+ eglConfig = new EGLGraphicsConfiguration(s, (EGLGLCapabilities)aConfig.getChosenCapabilities(), capsRequested, null);
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": Reusing chosenCaps: "+eglConfig);
+ }
+ } else {
+ final int nativeVisualID;
+ {
+ final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) aConfig.getChosenCapabilities();
+ if(capsChosen instanceof NativeVisualID) {
+ nativeVisualID = ((NativeVisualID)capsChosen).getVisualID(NVIDType.NATIVE_ID);
+ } else {
+ nativeVisualID = -1;
+ }
+ }
+ eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
+ capsRequested, capsRequested, null, s, nativeVisualID);
+
+ if (null == eglConfig) {
+ throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
+ } else if(DEBUG) {
+ System.err.println(getThreadName() + ": Chosen eglConfig: "+eglConfig);
+ }
}
- recreateSurface();
+ // subsequent updateHandle() will issue recreateSurface();
}
if(DEBUG) {
- System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): END: ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface+" - "+this);
+ System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): END: ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface);
}
} else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) {
if(DEBUG) {
@@ -205,9 +214,6 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
eglSurface = EGL.EGL_NO_SURFACE;
if (ownEGLDisplay && EGL.EGL_NO_DISPLAY!=eglDisplay) {
- if(DEBUG) {
- System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): eglTerminate: "+toHexString(eglDisplay));
- }
EGLDisplayUtil.eglTerminate(eglDisplay);
}
eglDisplay=EGL.EGL_NO_DISPLAY;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index bd5eb1b99..cc7d267b0 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -33,7 +33,9 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-public class EGLGLCapabilities extends GLCapabilities {
+import jogamp.nativewindow.NativeVisualID;
+
+public class EGLGLCapabilities extends GLCapabilities implements NativeVisualID {
final long eglcfg;
final int eglcfgid;
final int renderableType;
@@ -74,6 +76,7 @@ public class EGLGLCapabilities extends GLCapabilities {
" with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]");
}
this.renderableType = renderableType;
+ this.nativeVisualID = -1;
}
public Object cloneMutable() {
@@ -94,6 +97,21 @@ public class EGLGLCapabilities extends GLCapabilities {
final public void setNativeVisualID(int vid) { nativeVisualID=vid; }
final public int getNativeVisualID() { return nativeVisualID; }
+ final public int getVisualID(NVIDType type) {
+ switch(type) {
+ case GEN_ID:
+ // fall through intended
+ case EGL_ConfigID:
+ return getEGLConfigID();
+ case NATIVE_ID:
+ // fall through intended
+ case EGL_NativeVisualID:
+ return getNativeVisualID();
+ default:
+ throw new IllegalArgumentException("Invalid type <"+type+">");
+ }
+ }
+
public static boolean isCompatible(GLProfile glp, int renderableType) {
if(null == glp) {
return true;
@@ -147,8 +165,8 @@ public class EGLGLCapabilities extends GLCapabilities {
if(null == sink) {
sink = new StringBuffer();
}
- sink.append("0x").append(Long.toHexString(eglcfgid)).append(": ");
- sink.append("vid 0x").append(Integer.toHexString(nativeVisualID)).append(", ");
+ sink.append("egl cfg 0x").append(Integer.toHexString(eglcfgid));
+ sink.append(", vid 0x").append(Integer.toHexString(nativeVisualID)).append(": ");
super.toString(sink);
sink.append(", [");
renderableTypeToString(sink, renderableType);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index 2f486140f..99e8d1338 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -50,15 +50,13 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import jogamp.nativewindow.MutableGraphicsConfiguration;
-import jogamp.opengl.Debug;
import jogamp.opengl.GLGraphicsConfigurationUtil;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
- protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
-
+
public final long getNativeConfig() {
return ((EGLGLCapabilities)capabilitiesChosen).getEGLConfig();
}
@@ -275,11 +273,15 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
attrs[idx++] = EGL.EGL_BLUE_SIZE;
attrs[idx++] = caps.getBlueBits();
- attrs[idx++] = EGL.EGL_ALPHA_SIZE;
- attrs[idx++] = caps.getAlphaBits() > 0 ? caps.getAlphaBits() : EGL.EGL_DONT_CARE;
-
- attrs[idx++] = EGL.EGL_STENCIL_SIZE;
- attrs[idx++] = caps.getStencilBits() > 0 ? caps.getStencilBits() : EGL.EGL_DONT_CARE;
+ if(caps.getAlphaBits()>0) {
+ attrs[idx++] = EGL.EGL_ALPHA_SIZE;
+ attrs[idx++] = caps.getAlphaBits();
+ }
+
+ if(caps.getStencilBits()>0) {
+ attrs[idx++] = EGL.EGL_STENCIL_SIZE;
+ attrs[idx++] = caps.getStencilBits();
+ }
attrs[idx++] = EGL.EGL_DEPTH_SIZE;
attrs[idx++] = caps.getDepthBits();
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index ceeebe60b..831dceac2 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -40,6 +40,7 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.egl.EGLGraphicsDevice;
import javax.media.opengl.GLCapabilities;
@@ -52,8 +53,11 @@ import javax.media.opengl.GLDrawableFactory;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
+import jogamp.nativewindow.NativeVisualID;
+import jogamp.nativewindow.NativeVisualID.NVIDType;
import jogamp.opengl.GLGraphicsConfigurationFactory;
import jogamp.opengl.GLGraphicsConfigurationUtil;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -68,11 +72,24 @@ import java.nio.IntBuffer;
public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
static EGLGLCapabilities.EglCfgIDComparator EglCfgIDComparator = new EGLGLCapabilities.EglCfgIDComparator();
-
+ static GraphicsConfigurationFactory nativeGraphicsConfigurationFactory = null;
+
static void registerFactory() {
+ GraphicsConfigurationFactory eglFactory = new EGLGraphicsConfigurationFactory();
+
+ // become the pre-selector for X11/.. to match the native visual id w/ EGL, if native ES is selected
+ final String nwType = NativeWindowFactory.getNativeWindowType(false);
+ if(NativeWindowFactory.TYPE_X11 == nwType) {
+ nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, eglFactory);
+ } /* else if(NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false)) {
+ nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, eglFactory);
+ } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) {
+ } */
+
// become the selector for KD/EGL ..
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.egl.EGLGraphicsDevice.class, new EGLGraphicsConfigurationFactory());
+ GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.egl.EGLGraphicsDevice.class, eglFactory);
}
+
private EGLGraphicsConfigurationFactory() {
}
@@ -86,6 +103,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
if (! (capsChosen instanceof GLCapabilitiesImmutable) ) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
}
+ final GLCapabilitiesImmutable glCapsChosen = (GLCapabilitiesImmutable) capsChosen;
if (! (capsRequested instanceof GLCapabilitiesImmutable) ) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested");
@@ -96,10 +114,48 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
- return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen,
- (GLCapabilitiesImmutable) capsRequested,
- (GLCapabilitiesChooser) chooser,
- absScreen, -1);
+ AbstractGraphicsDevice absDevice = absScreen.getDevice();
+ if(null==absDevice) {
+ throw new GLException("Null AbstractGraphicsDevice");
+ }
+
+ AbstractGraphicsConfiguration cfg = null;
+
+ if( absDevice instanceof EGLGraphicsDevice ) {
+ cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen,
+ (GLCapabilitiesImmutable) capsRequested,
+ (GLCapabilitiesChooser) chooser,
+ absScreen, -1);
+ } else {
+ // handle non native cases (X11, ..)
+ if(null == nativeGraphicsConfigurationFactory) {
+ throw new InternalError("Native GraphicsConfigurationFactory is null, but call issued for device: "+absDevice+" of type "+absDevice.getClass().getSimpleName());
+ }
+
+ if(glCapsChosen.getGLProfile().usesNativeGLES()) {
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfigurationFactory.choose..: Handle native device "+absDevice.getClass().getSimpleName());
+ }
+ cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen,
+ (GLCapabilitiesImmutable) capsRequested,
+ (GLCapabilitiesChooser) chooser,
+ absScreen, -1);
+ if(null == cfg || 0>=((NativeVisualID)cfg.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID)) {
+ cfg = null;
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfigurationFactory.choose..: No native visual ID, fallback ..");
+ }
+ }
+ }
+ if(null == cfg) {
+ // fwd to native config factory (only X11 for now)
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfigurationFactory.choose..: Delegate to "+nativeGraphicsConfigurationFactory.getClass().getSimpleName());
+ }
+ cfg = nativeGraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen);
+ }
+ }
+ return cfg;
}
protected static List<GLCapabilitiesImmutable> getAvailableCapabilities(EGLDrawableFactory factory, AbstractGraphicsDevice device) {
@@ -147,79 +203,91 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
throw new GLException("Null AbstractGraphicsScreen");
}
AbstractGraphicsDevice absDevice = absScreen.getDevice();
-
- if(null==absDevice || !(absDevice instanceof EGLGraphicsDevice)) {
- throw new GLException("GraphicsDevice must be a valid EGLGraphicsDevice");
+ if(null==absDevice) {
+ throw new GLException("Null AbstractGraphicsDevice");
}
- long eglDisplay = absDevice.getHandle();
-
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Invalid EGL display: "+absDevice);
+
+ final long eglDisplay;
+ final boolean ownEGLDisplay;
+ if( !(absDevice instanceof EGLGraphicsDevice) ) {
+ eglDisplay = EGLDisplayUtil.eglGetDisplay(absDevice.getHandle());
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Could not get EGL display from: "+absDevice);
+ }
+ if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) {
+ throw new GLException("eglInitialize failed eglDisplay 0x"+Long.toHexString(eglDisplay)+", "+absDevice+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+ ownEGLDisplay = true;
+ } else {
+ eglDisplay = absDevice.getHandle();
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Invalid EGL display: "+absDevice);
+ }
+ ownEGLDisplay = false;
}
EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory();
capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory.canCreateGLPbuffer(absDevice) );
GLProfile glp = capsChosen.getGLProfile();
+ GLCapabilities fixedCaps;
EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, capsChosen, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
- }
- if(DEBUG) {
- System.err.println("eglChooseConfig failed with given capabilities "+capsChosen);
- }
-
- // Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..]
- //
- // rgb888 - d16, s4
- GLCapabilities fixedCaps = new GLCapabilities(glp);
- fixedCaps.setRedBits(8);
- fixedCaps.setGreenBits(8);
- fixedCaps.setBlueBits(8);
- fixedCaps.setDepthBits(16);
- fixedCaps.setSampleBuffers(true);
- fixedCaps.setNumSamples(4);
- if(DEBUG) {
- System.err.println("trying fixed caps (1): "+fixedCaps);
- }
- res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
+ if(null==res) {
+ if(DEBUG) {
+ System.err.println("eglChooseConfig failed with given capabilities "+capsChosen);
+ }
+
+ // Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..]
+ //
+ // rgb888 - d16, s4
+ fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(8);
+ fixedCaps.setGreenBits(8);
+ fixedCaps.setBlueBits(8);
+ fixedCaps.setDepthBits(16);
+ fixedCaps.setSampleBuffers(true);
+ fixedCaps.setNumSamples(4);
+ if(DEBUG) {
+ System.err.println("trying fixed caps (1): "+fixedCaps);
+ }
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
+ }
+ if(null==res) {
+ //
+ // rgb565 - d16, s0
+ fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(5);
+ fixedCaps.setGreenBits(6);
+ fixedCaps.setBlueBits(5);
+ fixedCaps.setDepthBits(16);
+ if(DEBUG) {
+ System.err.println("trying fixed caps (2): "+fixedCaps);
+ }
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
+ }
+ if(null==res) {
+ //
+ // rgb565 - d16, s4
+ fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(5);
+ fixedCaps.setGreenBits(6);
+ fixedCaps.setBlueBits(5);
+ fixedCaps.setDepthBits(16);
+ fixedCaps.setSampleBuffers(true);
+ fixedCaps.setNumSamples(4);
+ if(DEBUG) {
+ System.err.println("trying fixed caps (3): "+fixedCaps);
+ }
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
}
-
- //
- // rgb565 - d16, s0
- fixedCaps = new GLCapabilities(glp);
- fixedCaps.setRedBits(5);
- fixedCaps.setGreenBits(6);
- fixedCaps.setBlueBits(5);
- fixedCaps.setDepthBits(16);
- if(DEBUG) {
- System.err.println("trying fixed caps (2): "+fixedCaps);
- }
- res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
- }
-
- //
- // rgb565 - d16, s4
- fixedCaps = new GLCapabilities(glp);
- fixedCaps.setRedBits(5);
- fixedCaps.setGreenBits(6);
- fixedCaps.setBlueBits(5);
- fixedCaps.setDepthBits(16);
- fixedCaps.setSampleBuffers(true);
- fixedCaps.setNumSamples(4);
- if(DEBUG) {
- System.err.println("trying fixed caps (3): "+fixedCaps);
+ if(null==res) {
+ throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps(1-3)]");
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
+ if(ownEGLDisplay) {
+ EGLDisplayUtil.eglTerminate(eglDisplay);
}
- throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps(1-3)]");
+ return res;
}
static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay,
@@ -244,7 +312,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
if (DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig maxConfigs: "+numConfigs.get(0));
- System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglDisplay "+toHexString(eglDisplay)+", "+capsChosen);
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglDisplay "+toHexString(eglDisplay)+", "+capsChosen+", nativeVisualID "+toHexString(nativeVisualID));
}
final IntBuffer attrs = Buffers.newDirectIntBuffer(EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen));
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
index adfddddcd..6487dae1c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
@@ -30,6 +30,7 @@ package jogamp.opengl.windows.wgl;
import java.util.Comparator;
+import jogamp.nativewindow.NativeVisualID;
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
import javax.media.opengl.GL;
@@ -37,7 +38,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-public class WGLGLCapabilities extends GLCapabilities {
+public class WGLGLCapabilities extends GLCapabilities implements NativeVisualID {
final PIXELFORMATDESCRIPTOR pfd;
final int pfdID;
int arb_pixelformat; // -1 PFD, 0 NOP, 1 ARB
@@ -224,11 +225,23 @@ public class WGLGLCapabilities extends GLCapabilities {
final public boolean isSetByGDI() { return 0 > arb_pixelformat; }
final public boolean isSet() { return 0 != arb_pixelformat; }
+ final public int getVisualID(NVIDType type) {
+ switch(type) {
+ case GEN_ID:
+ case NATIVE_ID:
+ // fall through intended
+ case WIN32_PFDID:
+ return getPFDID();
+ default:
+ throw new IllegalArgumentException("Invalid type <"+type+">");
+ }
+ }
+
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
- sink.append(pfdID).append(" ");
+ sink.append("win32 vid 0x").append(Integer.toHexString(pfdID)).append(" ");
switch (arb_pixelformat) {
case -1:
sink.append("gdi");
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index cdb930280..3477a42c8 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -54,10 +54,7 @@ import jogamp.nativewindow.windows.MARGINS;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
import jogamp.opengl.GLGraphicsConfigurationUtil;
-public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
- // Keep this under the same debug flag as the drawable factory for convenience
- protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
-
+public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
protected static final int MAX_PFORMATS = 256;
protected static final int MAX_ATTRIBS = 256;
@@ -456,18 +453,22 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
iattributes[niattribs++] = GL.GL_FALSE;
}
- iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
- iattributes[niattribs++] = caps.getDepthBits();
iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB;
iattributes[niattribs++] = caps.getRedBits();
iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB;
iattributes[niattribs++] = caps.getGreenBits();
iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB;
iattributes[niattribs++] = caps.getBlueBits();
- iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
- iattributes[niattribs++] = caps.getAlphaBits();
- iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
- iattributes[niattribs++] = caps.getStencilBits();
+ if(caps.getAlphaBits()>0) {
+ iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
+ iattributes[niattribs++] = caps.getAlphaBits();
+ }
+ if(caps.getStencilBits()>0) {
+ iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
+ iattributes[niattribs++] = caps.getStencilBits();
+ }
+ iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
+ iattributes[niattribs++] = caps.getDepthBits();
if (caps.getAccumRedBits() > 0 ||
caps.getAccumGreenBits() > 0 ||
caps.getAccumBlueBits() > 0 ||
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index abfb17a0c..a7042b347 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -230,6 +230,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
if (config == null) {
throw new IllegalArgumentException("WindowsWGLGraphicsConfiguration is null");
}
+ if ( !(_factory instanceof WindowsWGLDrawableFactory) ) {
+ throw new GLException("GLDrawableFactory is not a WindowsWGLDrawableFactory, but: "+_factory.getClass().getSimpleName());
+ }
WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory) _factory;
WindowsWGLDrawable sharedDrawable = factory.getOrCreateSharedDrawable(device);
if(null == sharedDrawable) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index 5cd783221..6c214a0f2 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -56,6 +56,7 @@ import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLException;
+import jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory;
import jogamp.opengl.windows.wgl.WindowsWGLGraphicsConfiguration;
import javax.media.opengl.GLDrawableFactory;
@@ -104,8 +105,6 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu
WindowsGraphicsDevice winDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex());
GraphicsConfigurationFactory configFactory = GraphicsConfigurationFactory.getFactory(winDevice);
- GLDrawableFactory drawableFactory = GLDrawableFactory.getFactory( ((GLCapabilitiesImmutable)capsChosen).getGLProfile() );
-
WindowsWGLGraphicsConfiguration winConfig = (WindowsWGLGraphicsConfiguration)
configFactory.chooseGraphicsConfiguration(capsChosen,
capsRequested,
@@ -114,61 +113,68 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu
throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+winScreen);
}
+ GLDrawableFactory drawableFactory = GLDrawableFactory.getFactory(((GLCapabilitiesImmutable)capsChosen).getGLProfile());
GraphicsConfiguration chosenGC = null;
- // 1st Choice: Create an AWT GraphicsConfiguration with the desired PFD
- // This gc will probably not be able to support GDI (WGL_SUPPORT_GDI_ARB, PFD_SUPPORT_GDI)
- // however on most GPUs this is the current situation for Windows,
- // otherwise no hardware accelerated PFD could be achieved.
- // - preselect with no constrains
- // - try to create dedicated GC
- try {
- winConfig.preselectGraphicsConfiguration(drawableFactory, null);
- if ( 1 <= winConfig.getPixelFormatID() ) {
- chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
- if(DEBUG) {
- System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ if ( drawableFactory instanceof WindowsWGLDrawableFactory ) {
+ // 1st Choice: Create an AWT GraphicsConfiguration with the desired PFD
+ // This gc will probably not be able to support GDI (WGL_SUPPORT_GDI_ARB, PFD_SUPPORT_GDI)
+ // however on most GPUs this is the current situation for Windows,
+ // otherwise no hardware accelerated PFD could be achieved.
+ // - preselect with no constrains
+ // - try to create dedicated GC
+ try {
+ winConfig.preselectGraphicsConfiguration(drawableFactory, null);
+ if ( 1 <= winConfig.getPixelFormatID() ) {
+ chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
+ if(DEBUG) {
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ }
}
- }
- } catch (GLException gle0) {
- gle0.printStackTrace();
- // go on ..
- }
-
- if( null == chosenGC ) {
- // 2nd Choice: Choose and match the GL Visual with AWT:
- // - collect all AWT PFDs
- // - choose a GL config from the pool of AWT PFDs
- //
- // The resulting GraphicsConfiguration has to be 'forced' on the AWT native peer,
- // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify().
- //
-
- // collect all available PFD IDs
- GraphicsConfiguration[] configs = device.getConfigurations();
- int[] pfdIDs = new int[configs.length];
- ArrayHashSet pfdIDOSet = new ArrayHashSet();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration gc = configs[i];
- pfdIDs[i] = Win32SunJDKReflection.graphicsConfigurationGetPixelFormatID(gc);
- pfdIDOSet.add(new Integer(pfdIDs[i]));
+ } catch (GLException gle0) {
if(DEBUG) {
- System.err.println("AWT pfd["+i+"] "+pfdIDs[i]);
+ gle0.printStackTrace();
}
+ // go on ..
}
- if(DEBUG) {
- System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: PFD IDs: "+pfdIDs.length+", unique: "+pfdIDOSet.size());
- }
- winConfig.preselectGraphicsConfiguration(drawableFactory, pfdIDs);
- int gcIdx = pfdIDOSet.indexOf(new Integer(winConfig.getPixelFormatID()));
- if( 0 > gcIdx ) {
- chosenGC = configs[gcIdx];
+
+ if( null == chosenGC ) {
+ // 2nd Choice: Choose and match the GL Visual with AWT:
+ // - collect all AWT PFDs
+ // - choose a GL config from the pool of AWT PFDs
+ //
+ // The resulting GraphicsConfiguration has to be 'forced' on the AWT native peer,
+ // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify().
+ //
+
+ // collect all available PFD IDs
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ int[] pfdIDs = new int[configs.length];
+ ArrayHashSet<Integer> pfdIDOSet = new ArrayHashSet<Integer>();
+ for (int i = 0; i < configs.length; i++) {
+ GraphicsConfiguration gc = configs[i];
+ pfdIDs[i] = Win32SunJDKReflection.graphicsConfigurationGetPixelFormatID(gc);
+ pfdIDOSet.add(new Integer(pfdIDs[i]));
+ if(DEBUG) {
+ System.err.println("AWT pfd["+i+"] "+pfdIDs[i]);
+ }
+ }
if(DEBUG) {
- System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found matching AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: PFD IDs: "+pfdIDs.length+", unique: "+pfdIDOSet.size());
}
- }
+ winConfig.preselectGraphicsConfiguration(drawableFactory, pfdIDs);
+ int gcIdx = pfdIDOSet.indexOf(new Integer(winConfig.getPixelFormatID()));
+ if( 0 > gcIdx ) {
+ chosenGC = configs[gcIdx];
+ if(DEBUG) {
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found matching AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ }
+ }
+ }
+ } else {
+ chosenGC = device.getDefaultConfiguration();
}
-
+
if ( null == chosenGC ) {
throw new GLException("Unable to determine GraphicsConfiguration: "+winConfig);
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
index f4f01195f..9ca9c5e81 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
@@ -28,13 +28,14 @@
package jogamp.opengl.x11.glx;
+import jogamp.nativewindow.NativeVisualID;
import jogamp.nativewindow.x11.XVisualInfo;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import java.util.Comparator;
-public class X11GLCapabilities extends GLCapabilities {
+public class X11GLCapabilities extends GLCapabilities implements NativeVisualID {
final XVisualInfo xVisualInfo; // maybe null if !onscreen
final long fbcfg;
final int fbcfgid;
@@ -53,10 +54,10 @@ public class X11GLCapabilities extends GLCapabilities {
}
final X11GLCapabilities caps1 = (X11GLCapabilities) o1;
- final long id1 = caps1.getXVisualID();
+ final int id1 = caps1.getXVisualID();
final X11GLCapabilities caps2 = (X11GLCapabilities) o2;
- final long id2 = caps2.getXVisualID();
+ final int id2 = caps2.getXVisualID();
if(id1 > id2) {
return 1;
@@ -94,25 +95,40 @@ public class X11GLCapabilities extends GLCapabilities {
}
final public XVisualInfo getXVisualInfo() { return xVisualInfo; }
- final public long getXVisualID() { return (null!=xVisualInfo) ? xVisualInfo.getVisualid() : 0; }
+ final public int getXVisualID() { return (null!=xVisualInfo) ? (int) xVisualInfo.getVisualid() : 0; }
final public boolean hasXVisualInfo() { return null!=xVisualInfo; }
final public long getFBConfig() { return fbcfg; }
final public int getFBConfigID() { return fbcfgid; }
final public boolean hasFBConfig() { return 0!=fbcfg && fbcfgid>0; }
+ final public int getVisualID(NVIDType type) {
+ switch(type) {
+ case GEN_ID:
+ case NATIVE_ID:
+ // fall through intended
+ case X11_XVisualID:
+ return getXVisualID();
+ case X11_FBConfigID:
+ return getFBConfigID();
+ default:
+ throw new IllegalArgumentException("Invalid type <"+type+">");
+ }
+ }
+
final static String na_str = "----" ;
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
+ sink.append("x11 vid ");
if(hasXVisualInfo()) {
sink.append("0x").append(Long.toHexString(xVisualInfo.getVisualid()));
} else {
sink.append(na_str);
}
- sink.append(" ");
+ sink.append(", fbc ");
if(hasFBConfig()) {
sink.append("0x").append(Integer.toHexString(fbcfgid));
} else {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
index b2d679438..f1d804b35 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -51,14 +51,11 @@ import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.XRenderDirectFormat;
import jogamp.nativewindow.x11.XRenderPictFormat;
import jogamp.nativewindow.x11.XVisualInfo;
-import jogamp.opengl.Debug;
import jogamp.opengl.GLGraphicsConfigurationUtil;
import com.jogamp.common.nio.PointerBuffer;
public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implements Cloneable {
- protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
-
public static final int MAX_ATTRIBS = 128;
private GLCapabilitiesChooser chooser;
@@ -176,14 +173,16 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
res[idx++] = caps.getGreenBits();
res[idx++] = GLX.GLX_BLUE_SIZE;
res[idx++] = caps.getBlueBits();
- res[idx++] = GLX.GLX_ALPHA_SIZE;
- res[idx++] = caps.getAlphaBits();
- res[idx++] = GLX.GLX_DEPTH_SIZE;
- res[idx++] = caps.getDepthBits();
+ if(caps.getAlphaBits()>0) {
+ res[idx++] = GLX.GLX_ALPHA_SIZE;
+ res[idx++] = caps.getAlphaBits();
+ }
if (caps.getStencilBits() > 0) {
res[idx++] = GLX.GLX_STENCIL_SIZE;
res[idx++] = caps.getStencilBits();
}
+ res[idx++] = GLX.GLX_DEPTH_SIZE;
+ res[idx++] = caps.getDepthBits();
if (caps.getAccumRedBits() > 0 ||
caps.getAccumGreenBits() > 0 ||
caps.getAccumBlueBits() > 0 ||
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
index fc7aac06d..b2a8326cb 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
@@ -75,7 +75,7 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
}
@Override
- protected void updateHandle() {
+ protected final void updateHandle() {
if(USE_GLXWINDOW) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration();
if(config.getFBConfig()>=0) {
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 3eb7a6c9a..15c9e6a36 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -32,7 +32,11 @@
package javax.media.nativewindow;
+import jogamp.nativewindow.Debug;
+
public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration {
+ protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
+
private AbstractGraphicsScreen screen;
protected CapabilitiesImmutable capabilitiesChosen;
protected CapabilitiesImmutable capabilitiesRequested;
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java b/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
new file mode 100644
index 000000000..3451e28e8
--- /dev/null
+++ b/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
@@ -0,0 +1,78 @@
+/**
+ * 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.nativewindow;
+
+/**
+ * Specifies query to the native capabilities identification.
+ * Semantics may differ depending on the native windowing system,
+ * see {@link #getVisualID(int)}.
+ */
+public interface NativeVisualID {
+
+ public enum NVIDType {
+ GEN_ID(0), NATIVE_ID(1),
+ EGL_ConfigID(2), EGL_NativeVisualID(3), X11_XVisualID(4), X11_FBConfigID(5), WIN32_PFDID(6);
+
+ public final int id;
+
+ NVIDType(int id){
+ this.id = id;
+ }
+ }
+
+ /**
+ * Returns the native identification of the given <code>type</code>.
+ * <p>
+ * Depending on the native windowing system, this might be
+ * <ul>
+ * <li>X11
+ * <ul>
+ * <li>GEN_ID: X11_XVisualID</li>
+ * <li>NATIVE_ID: X11_XVisualID</li>
+ * <li>X11_XVisualID</li>
+ * <li>X11FBConfigID</li>
+ * </ul></li>
+ * <li>Windows
+ * <ul>
+ * <li>GEN_ID: WIN32_PFDID</li>
+ * <li>NATIVE_ID: WIN32_PFDID</li>
+ * <li>WIN32_PFDID</li>
+ * </ul></li>
+ * <li>EGL
+ * <ul>
+ * <li>GEN_ID: EGL_ConfigID</li>
+ * <li>NATIVE_ID: EGL_NativeVisualID (X11_XVisualID, WIN32_PFDID, ..)</li>
+ * <li>EGL_ConfigID</li>
+ * <li>EGL_NativeVisualID</li>
+ * </ul></li>
+ * </ul>
+ * </p>
+ */
+ int getVisualID(NVIDType type);
+}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
index aa09fc798..863b336fc 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTWindow.java
@@ -80,6 +80,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
protected Rectangle bounds;
protected Insets insets;
+ private long drawable_old;
+
/**
* Constructed by {@link jogamp.nativewindow.NativeWindowFactoryImpl#getNativeWindow(Object, AbstractGraphicsConfiguration)}
* via this platform's specialization (X11, OSX, Windows, ..).
@@ -121,6 +123,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
jawt = null;
isOffscreenLayerSurface = false;
drawable= 0;
+ drawable_old = 0;
bounds = new Rectangle();
insets = new Insets();
}
@@ -275,6 +278,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
jawt = fetchJAWTImpl();
isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt);
res = lockSurfaceImpl();
+ if(LOCK_SUCCESS == res && drawable_old != drawable) {
+ res = LOCK_SURFACE_CHANGED;
+ if(DEBUG) {
+ System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable));
+ // Thread.dumpStack();
+ }
+ }
} finally {
if (LOCK_SURFACE_NOT_READY >= res) {
adevice.unlock();
@@ -293,6 +303,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
public final void unlockSurface() {
surfaceLock.validateLocked();
+ drawable_old = drawable;
if (surfaceLock.getHoldCount() == 1) {
final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice();
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
index c83e549cb..5dc143559 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java
@@ -48,10 +48,11 @@ import javax.media.nativewindow.ToolkitLock;
import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
import javax.media.nativewindow.awt.AWTGraphicsDevice;
import javax.media.nativewindow.awt.AWTGraphicsScreen;
-import javax.media.nativewindow.x11.X11GraphicsConfiguration;
import javax.media.nativewindow.x11.X11GraphicsDevice;
import javax.media.nativewindow.x11.X11GraphicsScreen;
+import jogamp.nativewindow.NativeVisualID;
+import jogamp.nativewindow.NativeVisualID.NVIDType;
import jogamp.nativewindow.jawt.x11.X11SunJDKReflection;
import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.X11Util;
@@ -119,13 +120,13 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device);
- X11GraphicsConfiguration x11Config = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
- if (x11Config == null) {
+ AbstractGraphicsConfiguration aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
+ if (aConfig == null) {
throw new NativeWindowException("Unable to choose a GraphicsConfiguration (1): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
}
if(DEBUG) {
- System.err.println("X11AWTGraphicsConfigurationFactory: chosen x11Config: "+x11Config);
- Thread.dumpStack();
+ System.err.println("X11AWTGraphicsConfigurationFactory: chosen config: "+aConfig);
+ // Thread.dumpStack();
}
//
@@ -137,17 +138,17 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
// ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify().
//
final GraphicsConfiguration[] configs = device.getConfigurations();
- long visualID = x11Config.getVisualID();
+ int visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID);
for (int i = 0; i < configs.length; i++) {
GraphicsConfiguration gc = configs[i];
if (gc != null) {
if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) {
if(DEBUG) {
- System.err.println("Found matching AWT visual: 0x"+Long.toHexString(visualID) +" -> "+x11Config);
+ System.err.println("Found matching AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig);
}
return new AWTGraphicsConfiguration(awtScreen,
- x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
- gc, x11Config);
+ aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(),
+ gc, aConfig);
}
}
}
@@ -155,20 +156,20 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
// try again using an AWT Colormodel compatible configuration
GraphicsConfiguration gc = device.getDefaultConfiguration();
capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc);
- x11Config = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
- if (x11Config == null) {
+ aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen);
+ if (aConfig == null) {
throw new NativeWindowException("Unable to choose a GraphicsConfiguration (2): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen);
}
- visualID = x11Config.getVisualID();
+ visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID);
for (int i = 0; i < configs.length; i++) {
gc = configs[i];
if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) {
if(DEBUG) {
- System.err.println("Found matching default AWT visual: 0x"+Long.toHexString(visualID) +" -> "+x11Config);
+ System.err.println("Found matching default AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig);
}
return new AWTGraphicsConfiguration(awtScreen,
- x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(),
- gc, x11Config);
+ aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(),
+ gc, aConfig);
}
}
@@ -180,7 +181,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac
}
gc = device.getDefaultConfiguration();
- return new AWTGraphicsConfiguration(awtScreen, x11Config.getChosenCapabilities(), x11Config.getRequestedCapabilities(), gc, x11Config);
+ return new AWTGraphicsConfiguration(awtScreen, aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), gc, aConfig);
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java
index be3fbd323..940652846 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java
@@ -57,8 +57,6 @@ public class AndroidDisplay extends jogamp.newt.DisplayImpl {
final long eglDisplay = EGLDisplayUtil.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()));
- } else if(DEBUG) {
- System.err.println("Android Display.createNativeImpl: eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay));
}
if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) {
throw new GLException("eglInitialize failed eglDisplay 0x"+Long.toHexString(eglDisplay)+", error 0x"+Integer.toHexString(EGL.eglGetError()));
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
index 588e26eb7..a30aa133c 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java
@@ -79,7 +79,7 @@ public class WindowsWindow extends WindowImpl {
return LOCK_SUCCESS;
}
if(DEBUG_IMPLEMENTATION) {
- System.err.println("********** HDC change "+toHexString(hdc_old)+" -> "+toHexString(hdc));
+ System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc));
// Thread.dumpStack();
}
return LOCK_SURFACE_CHANGED;
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
index c975306b4..ad691eb0b 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
@@ -34,12 +34,13 @@
package jogamp.newt.driver.x11;
+import jogamp.nativewindow.NativeVisualID;
+import jogamp.nativewindow.NativeVisualID.NVIDType;
import jogamp.nativewindow.x11.X11Lib;
import jogamp.newt.DisplayImpl;
import jogamp.newt.DisplayImpl.DisplayRunnable;
import jogamp.newt.WindowImpl;
import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.InsetsImmutable;
import javax.media.nativewindow.util.Point;
@@ -64,7 +65,7 @@ public class X11Window extends WindowImpl {
final X11Screen screen = (X11Screen) getScreen();
final X11Display display = (X11Display) screen.getDisplay();
final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice());
- final X11GraphicsConfiguration cfg = (X11GraphicsConfiguration) factory.chooseGraphicsConfiguration(
+ final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration(
capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen());
if(DEBUG_IMPLEMENTATION) {
System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg);
@@ -73,7 +74,7 @@ public class X11Window extends WindowImpl {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
setGraphicsConfiguration(cfg);
- final long visualID = cfg.getVisualID();
+ final int visualID = ((NativeVisualID) cfg.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID);
final int flags = getReconfigureFlags(0, true) &
( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ;
setWindowHandle(CreateWindow0(getParentWindowHandle(),
@@ -236,8 +237,8 @@ public class X11Window extends WindowImpl {
protected static native boolean initIDs0();
private native long CreateWindow0(long parentWindowHandle, long display, int screen_index,
- long visualID, long javaObjectAtom, long windowDeleteAtom,
- int x, int y, int width, int height, boolean autoPosition, int flags);
+ int visualID, long javaObjectAtom, long windowDeleteAtom,
+ int x, int y, int width, int height, boolean autoPosition, int flags);
private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom);
private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle,
int x, int y, int width, int height, int flags);
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 6953140c0..6312a9186 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -510,7 +510,7 @@ static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint
*/
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0
(JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index,
- jlong visualID,
+ jint visualID,
jlong javaObjectAtom, jlong windowDeleteAtom,
jint x, jint y, jint width, jint height, jboolean autoPosition, int flags)
{
@@ -548,8 +548,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0
if(0==windowParent) {
windowParent = root;
}
- DBG_PRINT( "X11: CreateWindow dpy %p, parent %p, %d/%d %dx%d, undeco %d, alwaysOnTop %d, autoPosition %d\n",
- (void*)dpy, (void*)windowParent, x, y, width, height,
+ DBG_PRINT( "X11: CreateWindow dpy %p, screen %d, visualID 0x%X, parent %p, %d/%d %dx%d, undeco %d, alwaysOnTop %d, autoPosition %d\n",
+ (void*)dpy, scrn_idx, (int)visualID, (void*)windowParent, x, y, width, height,
TST_FLAG_IS_UNDECORATED(flags), TST_FLAG_IS_ALWAYSONTOP(flags), autoPosition);
// try given VisualID on screen
@@ -557,20 +557,18 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0
visualTemplate.screen = scrn_idx;
visualTemplate.visualid = (VisualID)visualID;
pVisualQuery = XGetVisualInfo(dpy, VisualIDMask|VisualScreenMask, &visualTemplate,&n);
- DUMP_VISUAL_INFO("Given VisualID,ScreenIdx", pVisualQuery);
+ DUMP_VISUAL_INFO("Given VisualID", pVisualQuery);
if(pVisualQuery!=NULL) {
visual = pVisualQuery->visual;
depth = pVisualQuery->depth;
- visualID = (jlong)pVisualQuery->visualid;
+ visualID = (jint)pVisualQuery->visualid;
XFree(pVisualQuery);
pVisualQuery=NULL;
}
- DBG_PRINT( "X11: [CreateWindow] trying given (dpy %p, screen %d, visualID: %d, parent %p) found: %p\n",
- dpy, scrn_idx, (int)visualID, (void*)windowParent, visual);
+ DBG_PRINT( "X11: [CreateWindow] found visual: %p\n", visual);
- if (visual==NULL)
- {
- NewtCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID, bail out!");
+ if (visual==NULL) {
+ NewtCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID 0x%X, bail out!", (int)visualID);
return 0;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
index 8b41141f1..dffe61f69 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java
@@ -47,19 +47,10 @@ import org.junit.AfterClass;
import org.junit.Test;
public class TestGearsES1NEWT extends UITestCase {
- static GLProfile glp;
static int width, height;
@BeforeClass
public static void initClass() {
- /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
- // exact match
- glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
- } else */ {
- // default device, somehow ES1 compatible
- glp = GLProfile.getGL2ES1();
- }
- Assert.assertNotNull(glp);
width = 512;
height = 512;
}
@@ -115,7 +106,7 @@ public class TestGearsES1NEWT extends UITestCase {
@Test
public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES1());
runTestGL(caps);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
index 13aafe48f..c327a3005 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java
@@ -47,19 +47,10 @@ import org.junit.AfterClass;
import org.junit.Test;
public class TestRedSquareES1NEWT extends UITestCase {
- static GLProfile glp;
static int width, height;
@BeforeClass
public static void initClass() {
- /* if(GLProfile.isAvailable(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1)) {
- // exact match
- glp = GLProfile.get(GLProfile.getDefaultEGLDevice(), GLProfile.GLES1);
- } else */ {
- // default device, somehow ES1 compatible
- glp = GLProfile.getGL2ES1();
- }
- Assert.assertNotNull(glp);
width = 512;
height = 512;
}
@@ -115,7 +106,7 @@ public class TestRedSquareES1NEWT extends UITestCase {
@Test
public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES1());
runTestGL(caps);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index 262a79671..5a106901d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -174,7 +174,9 @@ public class GearsES2 implements GLEventListener {
}
st.useProgram(gl, false);
- gl.setSwapInterval(swapInterval);
+ if(0<=swapInterval) {
+ gl.setSwapInterval(swapInterval);
+ }
System.err.println(Thread.currentThread()+" GearsES2.init FIN");
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index 2a86a5bd8..6f3438ec8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -122,6 +122,10 @@ public class RedSquareES2 implements GLEventListener {
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
st.useProgram(gl, false);
+ if(0<=swapInterval) {
+ gl.setSwapInterval(swapInterval);
+ }
+
if (glad instanceof GLWindow) {
glWindow = (GLWindow) glad;
glWindow.addMouseListener(myMouse);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
index e2b1e4844..5bf341388 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java
@@ -49,14 +49,12 @@ import org.junit.AfterClass;
import org.junit.Test;
public class TestGearsES2AWT extends UITestCase {
- static GLProfile glp;
static int width, height;
static boolean firstUIActionOnProcess = false;
+ static boolean forceES2 = false;
@BeforeClass
public static void initClass() {
- glp = GLProfile.getGL2ES2();
- Assert.assertNotNull(glp);
width = 512;
height = 512;
}
@@ -86,7 +84,7 @@ public class TestGearsES2AWT extends UITestCase {
public void run() {
frame.setVisible(true);
}});
- animator.setUpdateFPSFrames(60, System.err);
+ animator.setUpdateFPSFrames(60, System.err);
animator.start();
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
@@ -110,7 +108,7 @@ public class TestGearsES2AWT extends UITestCase {
@Test
public void test01() throws InterruptedException, InvocationTargetException {
- GLCapabilities caps = new GLCapabilities(glp);
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
runTestGL(caps);
}
@@ -123,10 +121,13 @@ public class TestGearsES2AWT extends UITestCase {
try {
duration = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
} else if(args[i].equals("-firstUIAction")) {
firstUIActionOnProcess = true;
}
}
+ System.err.println("forceES2 "+forceES2);
org.junit.runner.JUnitCore.main(TestGearsES2AWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index d2ba81294..88da8db23 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -40,6 +40,7 @@ import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
@@ -55,6 +56,7 @@ import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
@@ -79,6 +81,8 @@ public class TestGearsES2NEWT extends UITestCase {
static boolean mouseVisible = true;
static boolean mouseConfined = false;
static boolean showFPS = false;
+ static int loops = 1;
+ static boolean forceES2 = false;
@BeforeClass
public static void initClass() {
@@ -91,13 +95,13 @@ public class TestGearsES2NEWT extends UITestCase {
public static void releaseClass() {
}
- protected void runTestGL(GLCapabilities caps, boolean undecorated) throws InterruptedException {
- System.err.println("requested: "+caps);
+ protected void runTestGL(GLCapabilitiesImmutable caps, boolean undecorated) throws InterruptedException {
+ System.err.println("requested: vsync "+vsync+", "+caps);
Display dpy = NewtFactory.createDisplay(null);
Screen screen = NewtFactory.createScreen(dpy, screenIdx);
final GLWindow glWindow = GLWindow.create(screen, caps);
Assert.assertNotNull(glWindow);
- glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), size "+wsize+", pos "+wpos);
+ glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), vsync "+vsync+", size "+wsize+", pos "+wpos);
glWindow.setSize(wsize.getWidth(), wsize.getHeight());
if(null != wpos) {
glWindow.setPosition(wpos.getX(), wpos.getY());
@@ -108,7 +112,7 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.setPointerVisible(mouseVisible);
glWindow.confinePointer(mouseConfined);
- final GearsES2 demo = new GearsES2(vsync ? 1 : 0);
+ final GearsES2 demo = new GearsES2(vsync ? 1 : -1);
demo.setPMVUseBackingArray(pmvUseBackingArray);
glWindow.addGLEventListener(demo);
if(waitForKey) {
@@ -215,15 +219,17 @@ public class TestGearsES2NEWT extends UITestCase {
}
});
- animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
animator.start();
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
- System.err.println("chosen: "+glWindow.getChosenCapabilities());
+ System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
+ System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
@@ -234,19 +240,15 @@ public class TestGearsES2NEWT extends UITestCase {
@Test
public void test01GL2ES2() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setBackgroundOpaque(opaque);
- runTestGL(caps, undecorated);
+ for(int i=1; i<=loops; i++) {
+ System.err.println("Loop "+i+"/"+loops);
+ runTestGL(caps, undecorated);
+ }
}
- static int atoi(String a) {
- try {
- return Integer.parseInt(a);
- } catch (Exception ex) { throw new RuntimeException(ex); }
- }
-
- public static void main(String args[]) throws IOException {
-
+ public static void main(String args[]) throws IOException {
int x=0, y=0, w=200, h=200;
boolean useSize = false;
boolean usePos = false;
@@ -254,7 +256,7 @@ public class TestGearsES2NEWT extends UITestCase {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
- duration = atoi(args[i]);
+ duration = MiscUtils.atol(args[i], duration);
} else if(args[i].equals("-translucent")) {
opaque = false;
} else if(args[i].equals("-undecorated")) {
@@ -267,6 +269,8 @@ public class TestGearsES2NEWT extends UITestCase {
pmvUseBackingArray = false;
} else if(args[i].equals("-vsync")) {
vsync = true;
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
} else if(args[i].equals("-wait")) {
waitForKey = true;
} else if(args[i].equals("-mouseInvisible")) {
@@ -277,23 +281,26 @@ public class TestGearsES2NEWT extends UITestCase {
showFPS = true;
} else if(args[i].equals("-width")) {
i++;
- w = atoi(args[i]);
+ w = MiscUtils.atoi(args[i], w);
useSize = true;
} else if(args[i].equals("-height")) {
i++;
- h = atoi(args[i]);
+ h = MiscUtils.atoi(args[i], h);
useSize = true;
} else if(args[i].equals("-x")) {
i++;
- x = atoi(args[i]);
+ x = MiscUtils.atoi(args[i], x);
usePos = true;
} else if(args[i].equals("-y")) {
i++;
- y = atoi(args[i]);
+ y = MiscUtils.atoi(args[i], y);
usePos = true;
} else if(args[i].equals("-screen")) {
i++;
- screenIdx = atoi(args[i]);
+ screenIdx = MiscUtils.atoi(args[i], 0);
+ } else if(args[i].equals("-loops")) {
+ i++;
+ loops = MiscUtils.atoi(args[i], 1);
}
}
if(useSize) {
@@ -313,6 +320,8 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("vsync "+vsync);
System.err.println("mouseVisible "+mouseVisible);
System.err.println("mouseConfined "+mouseConfined);
+ System.err.println("loops "+loops);
+ System.err.println("forceES2 "+forceES2);
if(waitForKey) {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
index 49dbc062a..f658b2b2b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java
@@ -31,11 +31,13 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.QuitAdapter;
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2;
import javax.media.opengl.GLCapabilities;
@@ -48,6 +50,9 @@ import org.junit.Test;
public class TestRedSquareES2NEWT extends UITestCase {
static int width, height;
+ static int loops = 1;
+ static boolean vsync = false;
+ static boolean forceES2 = false;
@BeforeClass
public static void initClass() {
@@ -60,11 +65,13 @@ public class TestRedSquareES2NEWT extends UITestCase {
}
protected void runTestGL(GLCapabilities caps) throws InterruptedException {
+ System.err.println("requested: vsync "+vsync+", "+caps);
GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test");
+ glWindow.setSize(width, height);
- glWindow.addGLEventListener(new RedSquareES2());
+ glWindow.addGLEventListener(new RedSquareES2(vsync ? 1 : -1));
Animator animator = new Animator(glWindow);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -91,11 +98,16 @@ public class TestRedSquareES2NEWT extends UITestCase {
}
});
- glWindow.setSize(width, height);
- glWindow.setVisible(true);
- animator.setUpdateFPSFrames(60, System.err);
animator.start();
+
+ glWindow.setVisible(true);
+ System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
+ System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
+ System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
+
+ animator.setUpdateFPSFrames(60, System.err);
+
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
Thread.sleep(100);
}
@@ -106,20 +118,13 @@ public class TestRedSquareES2NEWT extends UITestCase {
@Test
public void test01GL2ES2() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
- runTestGL(caps);
- }
-
- @Test
- public void test02GLES2() throws InterruptedException {
- if(!GLProfile.isAvailable(GLProfile.GLES2)) {
- System.out.println("GLProfile GLES2 n/a");
- return;
+ GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ for(int i=1; i<=loops; i++) {
+ System.err.println("Loop "+i+"/"+loops);
+ runTestGL(caps);
}
- GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
- runTestGL(caps);
}
-
+
static long duration = 500; // ms
public static void main(String args[]) {
@@ -129,8 +134,15 @@ public class TestRedSquareES2NEWT extends UITestCase {
try {
duration = Integer.parseInt(args[i]);
} catch (Exception ex) { ex.printStackTrace(); }
+ } else if(args[i].equals("-es2")) {
+ forceES2 = true;
+ } else if(args[i].equals("-loops")) {
+ i++;
+ loops = MiscUtils.atoi(args[i], 1);
}
}
+ System.err.println("loops "+loops);
+ System.err.println("forceES2 "+forceES2);
org.junit.runner.JUnitCore.main(TestRedSquareES2NEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
index 506fe2d97..9cbeabb85 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
@@ -40,6 +40,15 @@ public class MiscUtils {
}
return def;
}
+
+ public static long atol(String str, long def) {
+ try {
+ return Long.parseLong(str);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return def;
+ }
public static boolean setFieldIfExists(Object instance, String fieldName, Object value) {
try {