[libjogl2-java] 03/04: Imported Upstream version 2.2.4+dfsg
Tony Mancill
tmancill at moszumanska.debian.org
Mon Nov 3 14:57:33 UTC 2014
This is an automated email from the git hooks/post-receive script.
tmancill pushed a commit to branch master
in repository libjogl2-java.
commit 60aeab45dc7a499b33c37d3f6c3a5c0456dc2fde
Author: tony mancill <tmancill at debian.org>
Date: Mon Nov 3 06:38:38 2014 -0800
Imported Upstream version 2.2.4+dfsg
---
LICENSE.txt | 1 +
doc/HowToBuild.html | 19 +-
doc/bouml | 1 -
jnlp-files/jogl-applet-bug818_gljpanel01.html | 12 +-
...anel01.html => jogl-applet-gl2_gljpanel02.html} | 12 +-
jnlp-files/jogl-test-applets.html | 3 +-
make/build-test.xml | 233 ++---
make/build.xml | 6 +-
.../assets-test/arrow-blue-alpha-64x64.png | Bin 0 -> 2327 bytes
.../assets-test/arrow-red-alpha-64x64.png | Bin 0 -> 2331 bytes
make/resources/assets-test/red-16x16.png | Bin 0 -> 168 bytes
make/resources/assets-test/red-32x32.png | Bin 0 -> 383 bytes
make/scripts/make.jogl.all.linux-x86_64.sh | 6 +
make/scripts/make.jogl.all.win32.bat | 6 +-
make/scripts/make.jogl.all.win64.bat | 6 +-
make/scripts/run-tests-linux-x86_64.sh | 3 +
make/scripts/run-tests-osx.sh | 3 +
make/scripts/tests-javaws-x64.bat | 2 +-
make/scripts/tests-osx-x64.sh | 3 +-
make/scripts/tests-win.bat | 10 +-
make/scripts/tests-x32-dbg.bat | 8 +-
make/scripts/tests-x32.bat | 8 +-
make/scripts/tests-x64-dbg.bat | 9 +-
make/scripts/tests-x64.bat | 8 +-
make/scripts/tests-x64.sh | 6 +
make/scripts/tests.sh | 40 +-
.../com/jogamp/graph/curve/OutlineShape.java | 6 +
.../classes/com/jogamp/graph/curve/Region.java | 5 +-
.../com/jogamp/graph/curve/opengl/GLRegion.java | 8 +-
.../jogamp/graph/curve/opengl/RegionRenderer.java | 9 +
src/jogl/classes/com/jogamp/graph/font/Font.java | 43 +-
.../classes/com/jogamp/graph/geom/Outline.java | 10 +-
src/jogl/classes/com/jogamp/opengl/FBObject.java | 691 ++++++++++-----
.../com/jogamp/opengl/GLAutoDrawableDelegate.java | 7 +
.../com/jogamp/opengl/GLRendererQuirks.java | 129 ++-
.../classes/com/jogamp/opengl/math/FloatUtil.java | 18 +-
src/jogl/classes/com/jogamp/opengl/math/Ray.java | 4 +-
.../com/jogamp/opengl/math/geom/AABBox.java | 6 +-
.../com/jogamp/opengl/math/geom/Frustum.java | 14 +-
.../classes/com/jogamp/opengl/swt/GLCanvas.java | 6 +
.../classes/com/jogamp/opengl/util/Animator.java | 152 ++--
.../com/jogamp/opengl/util/AnimatorBase.java | 33 +-
.../com/jogamp/opengl/util/FPSAnimator.java | 89 +-
.../classes/com/jogamp/opengl/util/GLBuffers.java | 15 +-
.../com/jogamp/opengl/util/GLDrawableUtil.java | 2 +-
.../jogamp/opengl/util/GLPixelStorageModes.java | 20 +-
.../com/jogamp/opengl/util/glsl/ShaderCode.java | 94 +-
.../jogamp/opengl/util/glsl/sdk/CompileShader.java | 34 +-
.../opengl/util/stereo/StereoClientRenderer.java | 13 +-
.../com/jogamp/opengl/util/texture/TextureIO.java | 6 +-
src/jogl/classes/javax/media/opengl/GLContext.java | 67 +-
.../classes/javax/media/opengl/GLDrawable.java | 5 +-
.../classes/javax/media/opengl/GLFBODrawable.java | 30 +-
.../media/opengl/GLOffscreenAutoDrawable.java | 6 +
src/jogl/classes/javax/media/opengl/GLProfile.java | 257 +++---
.../javax/media/opengl/GLSharedContextSetter.java | 38 +-
.../classes/javax/media/opengl/awt/GLCanvas.java | 176 ++--
.../classes/javax/media/opengl/awt/GLJPanel.java | 494 ++++++-----
.../graph/curve/opengl/VBORegion2PMSAAES2.java | 10 +-
.../graph/curve/opengl/VBORegion2PVBAAES2.java | 6 +-
.../jogamp/graph/font/typecast/TypecastGlyph.java | 58 +-
.../jogamp/graph/font/typecast/ot/OTGlyph.java | 22 +-
src/jogl/classes/jogamp/opengl/GLContextImpl.java | 554 ++++++------
.../classes/jogamp/opengl/GLContextShareSet.java | 129 +--
.../jogamp/opengl/GLDrawableFactoryImpl.java | 18 +-
.../classes/jogamp/opengl/GLDrawableHelper.java | 49 +-
.../classes/jogamp/opengl/GLFBODrawableImpl.java | 175 ++--
.../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 2 +-
src/jogl/classes/jogamp/opengl/GLStateTracker.java | 12 +-
.../classes/jogamp/opengl/glu/mipmap/Mipmap.java | 5 +-
.../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 2 +-
.../windows/wgl/WindowsPbufferWGLDrawable.java | 12 +-
.../wgl/WindowsWGLGraphicsConfiguration.java | 132 ++-
.../WindowsWGLGraphicsConfigurationFactory.java | 64 +-
.../native/macosx/MacOSXWindowSystemInterface.m | 2 +-
.../javax/media/nativewindow/util/PixelFormat.java | 7 +-
.../javax/media/nativewindow/util/Rectangle.java | 6 +
.../jogamp/nativewindow/GlobalToolkitLock.java | 9 +-
.../jogamp/nativewindow/NullToolkitLock.java | 11 +-
.../jogamp/nativewindow/ResourceToolkitLock.java | 12 +-
.../nativewindow/SharedResourceToolkitLock.java | 9 +-
src/nativewindow/native/macosx/OSXmisc.m | 9 +-
src/newt/classes/com/jogamp/newt/Display.java | 10 +-
.../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 23 +-
.../classes/com/jogamp/newt/opengl/GLWindow.java | 11 +-
.../jogamp/newt/driver/bcm/egl/ScreenDriver.java | 1 +
.../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 1 +
.../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 1 +
.../jogamp/newt/driver/kd/ScreenDriver.java | 1 +
.../jogamp/newt/driver/macosx/DisplayDriver.java | 5 +-
.../jogamp/newt/driver/windows/ScreenDriver.java | 1 +
.../jogamp/newt/driver/x11/DisplayDriver.java | 3 -
.../jogamp/newt/driver/x11/ScreenDriver.java | 1 +
src/newt/native/NewtMacWindow.m | 9 +-
.../jogamp/opengl/test/junit/graph/FontSet01.java | 35 +
.../opengl/test/junit/graph/TestFontsNEWT00.java | 93 ++
.../test/junit/graph/TestTextRendererNEWT10.java | 101 ++-
...EWT10.java => TestTextRendererNEWTBugXXXX.java} | 93 +-
.../graph/demos/ui/GLEventListenerButton.java | 4 +-
.../test/junit/graph/fonts/freefont/FreeMono.ttf | Bin 0 -> 592632 bytes
.../junit/graph/fonts/freefont/FreeMonoBold.ttf | Bin 0 -> 299136 bytes
.../graph/fonts/freefont/FreeMonoBoldOblique.ttf | Bin 0 -> 298940 bytes
.../junit/graph/fonts/freefont/FreeMonoOblique.ttf | Bin 0 -> 395188 bytes
.../test/junit/graph/fonts/freefont/FreeSans.ttf | Bin 0 -> 1563256 bytes
.../junit/graph/fonts/freefont/FreeSansBold.ttf | Bin 0 -> 416128 bytes
.../graph/fonts/freefont/FreeSansBoldOblique.ttf | Bin 0 -> 342492 bytes
.../junit/graph/fonts/freefont/FreeSansOblique.ttf | Bin 0 -> 763676 bytes
.../test/junit/graph/fonts/freefont/FreeSerif.ttf | Bin 0 -> 3303588 bytes
.../junit/graph/fonts/freefont/FreeSerifBold.ttf | Bin 0 -> 1310828 bytes
.../graph/fonts/freefont/FreeSerifBoldItalic.ttf | Bin 0 -> 608676 bytes
.../junit/graph/fonts/freefont/FreeSerifItalic.ttf | Bin 0 -> 922104 bytes
.../test/junit/jogl/acore/GLReadBuffer00Base.java | 13 +-
.../junit/jogl/acore/GLReadBuffer00BaseAWT.java | 120 +++
.../acore/TestBug669RecursiveGLContext01NEWT.java | 4 +-
.../acore/TestBug669RecursiveGLContext02NEWT.java | 4 +-
.../jogl/acore/TestFBOAutoDrawableDeadlockAWT.java | 2 +-
.../jogl/acore/TestFBOAutoDrawableFactoryNEWT.java | 55 +-
.../test/junit/jogl/acore/TestFBOMRTNEWT01.java | 6 +-
.../junit/jogl/acore/TestFBOMix2DemosES2NEWT.java | 45 +-
.../TestGLOffscreenAutoDrawableBug1044AWT.java | 106 +++
.../test/junit/jogl/acore/TestGLProfile00NEWT.java | 26 +-
.../test/junit/jogl/acore/TestGLProfile01NEWT.java | 972 ++++++++++++++++-----
.../jogl/acore/TestGLReadBuffer01GLCanvasAWT.java | 116 +--
.../jogl/acore/TestGLReadBuffer01GLJPanelAWT.java | 121 +--
.../jogl/acore/TestGLReadBuffer01GLWindowNEWT.java | 39 +-
.../junit/jogl/acore/TestPBufferDeadlockAWT.java | 2 +-
.../junit/jogl/acore/TestSharedContextListAWT.java | 2 +-
.../jogl/acore/TestSharedContextListNEWT.java | 2 +-
.../jogl/acore/TestSharedContextListNEWT2.java | 2 +-
.../jogl/acore/TestSharedContextNewtAWTBug523.java | 15 +-
.../jogl/acore/TestSharedContextVBOES1NEWT.java | 11 +-
.../jogl/acore/TestSharedContextVBOES2AWT3.java | 18 +-
.../jogl/acore/TestSharedContextVBOES2AWT3b.java | 18 +-
.../jogl/acore/TestSharedContextVBOES2NEWT0.java | 49 +-
.../jogl/acore/TestSharedContextVBOES2NEWT1.java | 56 +-
.../jogl/acore/TestSharedContextVBOES2NEWT2.java | 109 +--
.../jogl/acore/TestSharedContextVBOES2NEWT3.java | 89 +-
...EWT2.java => TestSharedContextVBOES2NEWT4.java} | 223 ++---
.../jogl/acore/TestSharedContextVBOES2SWT3.java | 18 +-
.../junit/jogl/acore/TestVersionSemanticsNOUI.java | 62 +-
.../jogl/awt/TestAWT03GLCanvasRecreate01.java | 134 ++-
...ate01.java => TestAWT03GLJPanelRecreate01.java} | 161 ++--
.../junit/jogl/caps/TestMultisampleES2NEWT.java | 6 +-
.../opengl/test/junit/jogl/demos/es1/GearsES1.java | 67 +-
.../test/junit/jogl/demos/es1/GearsObjectES1.java | 4 +
.../test/junit/jogl/demos/es2/FBOMix2DemosES2.java | 19 +-
.../opengl/test/junit/jogl/demos/es2/GearsES2.java | 107 ++-
.../junit/jogl/demos/es2/MultisampleDemoES2.java | 15 +-
.../demos/es2/TextureDraw02ES2ListenerFBO.java | 25 +-
.../demos/es2/awt/TestGearsES2GLJPanelAWT.java | 34 +
.../jogl/demos/es2/newt/TestGearsES2NEWT.java | 45 +-
.../jogl/demos/es2/newt/TestLandscapeES2NEWT.java | 2 +-
.../es2/newt/TestLandscapeES2NewtCanvasAWT.java | 14 +-
.../test/junit/jogl/demos/es2/shader/landscape.fp | 339 -------
.../opengl/test/junit/jogl/demos/gl2/Gears.java | 204 +++--
.../opengl/test/junit/jogl/demos/gl2/Teapot.java | 62 +-
...t.java => Bug818GLJPanelAndGLCanvasApplet.java} | 30 +-
.../gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java | 180 ++++
.../jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java | 51 ++
.../TessellationShader01aGLSL440CoreHardcoded.java | 225 +++++
.../jogl/demos/gl4/TessellationShader01bGL4.java | 154 ++++
.../gl4/newt/TestTessellationShader01GL4NEWT.java | 117 +++
.../junit/jogl/demos/gl4/shader/tess_example01.fp | 6 +
.../junit/jogl/demos/gl4/shader/tess_example01.tcp | 12 +
.../junit/jogl/demos/gl4/shader/tess_example01.tep | 8 +
.../junit/jogl/demos/gl4/shader/tess_example01.vp | 12 +
.../jogl/perf/TestPerf001GLJPanelInit01AWT.java | 120 ++-
.../jogl/perf/TestPerf001GLJPanelInit02AWT.java | 153 +++-
.../test/junit/jogl/stereo/StereoDemo01.java | 1 +
.../test/junit/newt/TestMultipleNewtCanvasAWT.java | 185 ++++
.../junit/newt/TestWindowAndPointerIconNEWT.java | 142 +++
.../test/junit/newt/mm/TestScreenMode00aNEWT.java | 18 +
.../test/junit/newt/mm/TestScreenMode00cNEWT.java | 13 +-
.../test/junit/newt/mm/TestScreenMode01aNEWT.java | 2 +-
.../jogamp/opengl/test/junit/util/MiscUtils.java | 17 +-
.../jogamp/opengl/test/junit/util/UITestCase.java | 110 +--
176 files changed, 6481 insertions(+), 3218 deletions(-)
diff --git a/LICENSE.txt b/LICENSE.txt
index 8083843..02d605c 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -8,6 +8,7 @@ if not stated otherwise.
A.7) The JOGL source tree _may_ contain code from Oculus VR, Inc.
which is covered by it's own permissive Oculus VR Rift SDK Software License.
+ (Optional, see A.7 below for details)
Below you find a detailed list of licenses used in this project.
diff --git a/doc/HowToBuild.html b/doc/HowToBuild.html
index 0abcdb1..3879b95 100644
--- a/doc/HowToBuild.html
+++ b/doc/HowToBuild.html
@@ -56,14 +56,17 @@
(not yet tested)</li>
</ul>
</li>
- <li> <b><a href="http://ant.apache.org/">Ant</a></b> 1.8.2 or later</li>
+ <li> <b><a href="http://ant.apache.org/">Ant</a></b> 1.9.0 or later</li>
<li> <b><a href="http://www.kernel.org/pub/software/scm/git/docs/">Git</a></b> 1.6.0 or later<br/>
<ul>
<li> Use your Unix distribution's version, if available, or</li>
<li> <a href="http://www.kernel.org/pub/software/scm/git/">Source Code for GNU/Linux, MacOSX, ..</a>, or</li>
- <li> <a href="http://code.google.com/p/msysgit/">Git on Windows</a>,
- <a href="http://code.google.com/p/msysgit/downloads/list">download</a> version
- <a href="http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.0.2-preview20100309.exe&can=2&q=">1.7.0</a> or later.</li>
+ <li> Git on Windows
+ <ul>
+ <li> <a href="https://cygwin.com">cygwin</a></li>
+ <li> <a href="http://code.google.com/p/msysgit/">msysgit</a></li>
+ </ul>
+ </li>
<li> <a href="http://code.google.com/p/git-osx-installer/">git-osx-installer</a> </li>
</ul>
</li>
@@ -121,6 +124,14 @@ apt-get install ia32-libs ia32-libs-gtk gcc-multilib lib32gcc1 lib32gomp1 lib32i
dpkg --add-architecture i386
apt-get update
apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 gcc-multilib lib32gcc1 lib32gomp1 lib32itm1 lib32quadmath0 libudev1:i386 libc6-i386 libc6-dev-i386 g++-multilib lib32stdc++6 openjdk-7-jre:i386 openjdk-7-jdk:i386
+
+cd /usr/lib/i386-linux-gnu/
+ln -s libXrender.so.1 libXrender.so
+ln -s libXxf86vm.so.1 libXxf86vm.so
+ln -s libXrandr.so.2 libXrandr.so
+ln -s libXcursor.so.1 libXcursor.so
+cd /lib/i386-linux-gnu/
+ln -s libudev.so.1 libudev.so
</pre></li>
</ul>
</li>
diff --git a/doc/bouml b/doc/bouml
deleted file mode 120000
index 3490e7a..0000000
--- a/doc/bouml
+++ /dev/null
@@ -1 +0,0 @@
-uml
\ No newline at end of file
diff --git a/jnlp-files/jogl-applet-bug818_gljpanel01.html b/jnlp-files/jogl-applet-bug818_gljpanel01.html
index 4bb09d0..0f62062 100644
--- a/jnlp-files/jogl-applet-bug818_gljpanel01.html
+++ b/jnlp-files/jogl-applet-bug818_gljpanel01.html
@@ -1,24 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
-<title>Bug818 OSX GLJPanel NV GT330 Crash</title>
+<title>Bug818 OSX GLJPanel and GLCanvas NV GT330 Crash</title>
</head>
<body BGCOLOR="#ffffff">
<P>
-Bug818 OSX GLJPanel NV GT330 Crash
+Bug818 OSX GLJPanel and GLCanvas NV GT330 Crash
</P>
<P>
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
- width="750" height="350">
- <param name="code" value="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.Bug818GLJPanelApplet">
+ width="750" height="650">
+ <param name="code" value="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.Bug818GLJPanelAndGLCanvasApplet">
<param name="archive" value="jar/lib/gluegen-rt.jar,
jar/lib/jogl-all.jar,
jar/jogl-test.jar">
<comment>
- <embed code="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.Bug818GLJPanelApplet"
- width="750" height="350"
+ <embed code="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.Bug818GLJPanelAndGLCanvasApplet"
+ width="750" height="650"
type="application/x-java-applet;version=1.6"
archive="jar/gluegen-rt.jar,
jar/jogl-all.jar,
diff --git a/jnlp-files/jogl-applet-bug818_gljpanel01.html b/jnlp-files/jogl-applet-gl2_gljpanel02.html
similarity index 76%
copy from jnlp-files/jogl-applet-bug818_gljpanel01.html
copy to jnlp-files/jogl-applet-gl2_gljpanel02.html
index 4bb09d0..fa5f569 100644
--- a/jnlp-files/jogl-applet-bug818_gljpanel01.html
+++ b/jnlp-files/jogl-applet-gl2_gljpanel02.html
@@ -1,24 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
-<title>Bug818 OSX GLJPanel NV GT330 Crash</title>
+<title>GLJPanels and GLCanvas w/ GL2 Demos</title>
</head>
<body BGCOLOR="#ffffff">
<P>
-Bug818 OSX GLJPanel NV GT330 Crash
+GLJPanels and GLCanvas w/ Gears GL2 Demos
</P>
<P>
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
- width="750" height="350">
- <param name="code" value="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.Bug818GLJPanelApplet">
+ width="750" height="800">
+ <param name="code" value="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.GLJPanelsAndGLCanvasDemoGL2Applet">
<param name="archive" value="jar/lib/gluegen-rt.jar,
jar/lib/jogl-all.jar,
jar/jogl-test.jar">
<comment>
- <embed code="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.Bug818GLJPanelApplet"
- width="750" height="350"
+ <embed code="com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.GLJPanelsAndGLCanvasDemoGL2Applet"
+ width="750" height="800"
type="application/x-java-applet;version=1.6"
archive="jar/gluegen-rt.jar,
jar/jogl-all.jar,
diff --git a/jnlp-files/jogl-test-applets.html b/jnlp-files/jogl-test-applets.html
index 55db0ca..b0b5477 100644
--- a/jnlp-files/jogl-test-applets.html
+++ b/jnlp-files/jogl-test-applets.html
@@ -211,7 +211,8 @@ Misc tests:
</ul></li>
<li>Misc Issues
<ul>
- <li><a href="jogl-applet-bug818_gljpanel01.html">Bug 818: OSX 10.6.8 NV GT 330M GLJPanel Crash</a></li>
+ <li><a href="jogl-applet-gl2_gljpanel02.html">GLJPanels and GLCanvas w/ GL2 Demos</a></li>
+ <li><a href="jogl-applet-bug818_gljpanel01.html">Bug 818: OSX 10.6.8 NV GT 330M GLJPanel and GLCanvas Crash</a></li>
<li><a href="jogl-applet-bug848_glcanvas01.html">Bug 848: Applet on OSX w/ CALayer and 2 or more GLCanvas may crash</a></li>
<li><a href="Bug910-AppletLifecycleCheck.html">Bug 910: Extended AWT Applet Lifecycle Check</a></li>
</ul></li>
diff --git a/make/build-test.xml b/make/build-test.xml
index 88d40bc..eed264e 100644
--- a/make/build-test.xml
+++ b/make/build-test.xml
@@ -202,7 +202,7 @@
<antcall target="test.package.android" inheritRefs="true" inheritAll="true"/>
</target>
- <target name="test.manual.run" depends="test.compile">
+ <target name="test.manual.run" depends="test.compile, junit.run.settings">
<for param="test.class.path.m" keepgoing="true">
<!-- results in absolute path -->
<fileset dir="${classes}">
@@ -284,7 +284,9 @@
</junit>
</target>
- <target name="junit.run.newt.headless" depends="test.compile">
+ <target name="generic.junit.run.newt.headless">
+ <!-- attribute name="generic.junit.run.newt.headless.include.pattern" -->
+
<!-- Test*NEWT*
Emulation of junit task,
@@ -295,7 +297,7 @@
<for param="test.class.path.m" keepgoing="true">
<!-- results in absolute path -->
<fileset dir="${classes}">
- <include name="${java.dir.junit}/**/Test*NEWT*"/>
+ <include name="${generic.junit.run.newt.headless.include.pattern}"/>
<exclude name="**/*$$*"/>
<exclude name="**/*AWT*"/>
<exclude name="**/*SWT*"/>
@@ -349,6 +351,13 @@
</apply>
</sequential>
</for>
+ <var name="generic.junit.run.newt.headless.include.pattern" unset="true"/>
+ </target>
+
+ <target name="junit.run.newt.headless" depends="test.compile">
+ <!-- Test*NEWT* -->
+ <property name="generic.junit.run.newt.headless.include.pattern" value="${java.dir.junit}/**/Test*NEWT*"/>
+ <antcall target="generic.junit.run.newt.headless" inheritRefs="true" inheritAll="true"/>
</target>
<!-- junit.run.newt is covered by junit.run.newt.headless, disable it for now, but may be checked manually.
@@ -394,7 +403,9 @@
</junit>
</target>
- <target name="junit.run.awt" depends="test.compile">
+ <target name="generic.junit.run.awt">
+ <!-- attribute name="generic.junit.run.awt.include.pattern" -->
+
<!-- Test*AWT* -->
<junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
<env key="${system.env.library.path}" path="${obj.all.paths}"/>
@@ -420,7 +431,7 @@
<batchtest todir="${results.test}">
<fileset dir="${classes}">
- <include name="${java.dir.junit}/**/Test*AWT*"/>
+ <include name="${generic.junit.run.awt.include.pattern}"/>
<exclude name="**/*$$*"/>
<exclude name="**/*SWT*"/>
<exclude name="**/newt/**"/>
@@ -429,9 +440,18 @@
<formatter usefile="true" type="xml"/>
</batchtest>
</junit>
+ <var name="generic.junit.run.awt.include.pattern" unset="true"/>
</target>
- <target name="junit.run.newt.awt" depends="test.compile">
+ <target name="junit.run.awt" depends="test.compile">
+ <!-- Test*AWT* -->
+ <property name="generic.junit.run.awt.include.pattern" value="${java.dir.junit}/**/Test*AWT*"/>
+ <antcall target="generic.junit.run.awt" inheritRefs="true" inheritAll="true"/>
+ </target>
+
+ <target name="generic.junit.run.newt.awt">
+ <!-- attribute name="generic.junit.run.newt.awt.include.pattern" -->
+
<!-- Test*AWT* -->
<junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
<env key="${system.env.library.path}" path="${obj.all.paths}"/>
@@ -459,9 +479,7 @@
<batchtest todir="${results.test}">
<fileset dir="${classes}">
- <include name="${java.dir.junit}/**/newt/**/Test*AWT*"/>
- <!--include name="${java.dir.junit}/**/newt/**/TestNewtEventModifiers*AWT*"/-->
- <!--include name="${java.dir.junit}/**/acore/glels/Test**"/-->
+ <include name="${generic.junit.run.newt.awt.include.pattern}"/>
<exclude name="**/*SWT*"/>
<exclude name="**/*$$*"/>
</fileset>
@@ -469,123 +487,58 @@
<formatter usefile="true" type="xml"/>
</batchtest>
</junit>
+ <var name="generic.junit.run.newt.awt.include.pattern" unset="true"/>
</target>
- <target name="junit.run.sharedctx" depends="test.compile, junit.run.settings">
+ <target name="junit.run.newt.awt" depends="test.compile">
<!-- Test*AWT* -->
- <junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
- <env key="${system.env.library.path}" path="${obj.all.paths}"/>
- <jvmarg value="${junit.run.arg0}"/>
- <jvmarg value="${junit.run.arg1}"/>
- <jvmarg value="${jvmDataModel.arg}"/>
- <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
-
- <!--
- <jvmarg value="-Dnewt.debug.EDT"/>
- <jvmarg value="-Djogl.debug=all"/>
- <jvmarg value="-Dgluegen.debug.NativeLibrary=true"/>
- <jvmarg value="-Dgluegen.debug.ProcAddressHelper=true"/>
- <jvmarg value="-Djogl.debug.GLSLState"/>
- <jvmarg value="-Dnativewindow.debug=all"/>
- <jvmarg value="-Dnewt.debug=all"/>
- <jvmarg value="-verbose:jni"/>
- <jvmarg value="-client"/>
- <jvmarg value="-d32"/>
- -->
+ <property name="generic.junit.run.newt.awt.include.pattern" value="${java.dir.junit}/**/newt/**/Test*AWT*"/>
+ <antcall target="generic.junit.run.newt.awt" inheritRefs="true" inheritAll="true"/>
+
+ <!--
+ <property name="generic.junit.run.newt.awt.include.pattern" value="${java.dir.junit}/**/newt/**/TestNewtEventModifiers*AWT*"/>
+ <antcall target="generic.junit.run.newt.awt" inheritRefs="true" inheritAll="true"/>
+ <property name="generic.junit.run.newt.awt.include.pattern" value="${java.dir.junit}/**/acore/glels/Test**"/>
+ <antcall target="generic.junit.run.newt.awt" inheritRefs="true" inheritAll="true"/>
+ -->
+ </target>
- <formatter usefile="false" type="plain"/>
- <formatter usefile="true" type="xml"/>
- <!--classpath refid="junit_jogl_awt.run.classpath"/-->
- <classpath refid="junit_jogl_swt.run.classpath"/>
+ <target name="junit.run.sharedctx" depends="test.compile, junit.run.settings">
+ <!-- Test*NEWT* -->
+ <echo message="+++ "/>
+ <echo message="+++ Testing Shared NEWT"/>
+ <echo message="+++ "/>
+ <property name="generic.junit.run.newt.headless.include.pattern" value="${java.dir.junit}/**/acore/Test*Shared*NEWT*"/>
+ <antcall target="generic.junit.run.newt.headless" inheritRefs="true" inheritAll="true"/>
- <batchtest todir="${results.test}">
- <fileset dir="${classes}">
- <include name="${java.dir.junit}/**/acore/TestSharedContext**"/>
- <exclude name="**/*$$*"/>
- </fileset>
- <formatter usefile="false" type="brief"/>
- <formatter usefile="true" type="xml"/>
- </batchtest>
- </junit>
+ <!-- Test*AWT* -->
+ <echo message="+++ "/>
+ <echo message="+++ Testing Shared AWT"/>
+ <echo message="+++ "/>
+ <property name="generic.junit.run.awt.include.pattern" value="${java.dir.junit}/**/acore/Test*Shared*AWT*"/>
+ <antcall target="generic.junit.run.awt" inheritRefs="true" inheritAll="true"/>
+
+ <!-- Test*SWTHeadless* -->
+ <echo message="+++ "/>
+ <echo message="+++ Testing Shared SWT"/>
+ <echo message="+++ "/>
+ <property name="generic.junit.run.swt.headless.include.pattern" value="${java.dir.junit}/**/acore/Test*Shared*SWT*"/>
+ <antcall target="generic.junit.run.swt.headless" inheritRefs="true" inheritAll="true"/>
</target>
<target name="junit.run.newt.event" depends="test.compile, junit.run.settings">
<!-- Test*AWT* -->
- <junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
- <env key="${system.env.library.path}" path="${obj.all.paths}"/>
- <jvmarg value="${junit.run.arg0}"/>
- <jvmarg value="${junit.run.arg1}"/>
- <jvmarg value="${jvmDataModel.arg}"/>
- <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
-
- <!--
- <jvmarg value="-Dnewt.debug.EDT"/>
- <jvmarg value="-Djogl.debug=all"/>
- <jvmarg value="-Dgluegen.debug.NativeLibrary=true"/>
- <jvmarg value="-Dgluegen.debug.ProcAddressHelper=true"/>
- <jvmarg value="-Djogl.debug.GLSLState"/>
- <jvmarg value="-Dnativewindow.debug=all"/>
- <jvmarg value="-Dnewt.debug=all"/>
- <jvmarg value="-verbose:jni"/>
- <jvmarg value="-client"/>
- <jvmarg value="-d32"/>
- -->
-
- <formatter usefile="false" type="plain"/>
- <formatter usefile="true" type="xml"/>
- <!--classpath refid="junit_jogl_awt.run.classpath"/-->
- <classpath refid="junit_jogl_swt.run.classpath"/>
-
- <batchtest todir="${results.test}">
- <fileset dir="${classes}">
- <include name="${java.dir.junit}/**/newt/event/Test**"/>
- <exclude name="**/*$$*"/>
- </fileset>
- <formatter usefile="false" type="brief"/>
- <formatter usefile="true" type="xml"/>
- </batchtest>
- </junit>
+ <property name="generic.junit.run.newt.awt.include.pattern" value="${java.dir.junit}/**/newt/event/Test**"/>
+ <antcall target="generic.junit.run.newt.awt" inheritRefs="true" inheritAll="true"/>
</target>
<target name="junit.run.newt.monitormode" depends="test.compile, junit.run.settings">
<!-- Test*AWT* -->
- <junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
- <env key="${system.env.library.path}" path="${obj.all.paths}"/>
- <jvmarg value="${junit.run.arg0}"/>
- <jvmarg value="${junit.run.arg1}"/>
- <jvmarg value="${jvmDataModel.arg}"/>
- <jvmarg value="-Djava.library.path=${obj.all.paths}"/>
-
- <!--
- <jvmarg value="-Dnewt.debug.EDT"/>
- <jvmarg value="-Djogl.debug=all"/>
- <jvmarg value="-Dgluegen.debug.NativeLibrary=true"/>
- <jvmarg value="-Dgluegen.debug.ProcAddressHelper=true"/>
- <jvmarg value="-Djogl.debug.GLSLState"/>
- <jvmarg value="-Dnativewindow.debug=all"/>
- <jvmarg value="-Dnewt.debug=all"/>
- <jvmarg value="-verbose:jni"/>
- <jvmarg value="-client"/>
- <jvmarg value="-d32"/>
- -->
-
- <formatter usefile="false" type="plain"/>
- <formatter usefile="true" type="xml"/>
- <!--classpath refid="junit_jogl_awt.run.classpath"/-->
- <classpath refid="junit_jogl_swt.run.classpath"/>
-
- <batchtest todir="${results.test}">
- <fileset dir="${classes}">
- <include name="${java.dir.junit}/**/newt/mm/Test**"/>
- <exclude name="**/*$$*"/>
- </fileset>
- <formatter usefile="false" type="brief"/>
- <formatter usefile="true" type="xml"/>
- </batchtest>
- </junit>
+ <property name="generic.junit.run.newt.awt.include.pattern" value="${java.dir.junit}/**/newt/mm/Test**"/>
+ <antcall target="generic.junit.run.newt.awt" inheritRefs="true" inheritAll="true"/>
</target>
- <target name="junit.run.awt.singletest" depends="test.compile">
+ <target name="junit.run.awt.singletest" depends="test.compile, junit.run.settings">
<!-- Test*AWT* -->
<junit jvm="${jvmJava.exe}" forkmode="perTest" showoutput="true" fork="true" haltonerror="off" timeout="${batchtest.timeout}">
<env key="${system.env.library.path}" path="${obj.all.paths}"/>
@@ -613,7 +566,53 @@
</junit>
</target>
- <target name="junit.run.swt.headless" depends="test.compile" description="Runs all pure SWT tests." if="isSWTRuntimeAvailable">
+ <target name="junit.run.newt.headless.singletest" depends="test.compile, junit.run.settings">
+ <!-- Test*NEWT*
+
+ Emulation of junit task,
+ due to the fact that we have to place invoke our MainThread class first (-> MacOSX).
+
+ Utilizing Ant-1.8.0 and ant-contrib-1.0b3 (loops, mutable properties).
+ -->
+ <var name="test.class.result.file" value="${results.test}/TEST-${testclass}.xml"/>
+ <echo message="Testing ${testclass} -- ${test.class.result.file}"/>
+ <apply dir="." executable="${jvmJava.exe}"
+ parallel="false"
+ timeout="${batchtest.timeout}"
+ vmlauncher="false"
+ relative="true"
+ failonerror="false">
+ <env key="${system.env.library.path}" path="${obj.all.paths}"/>
+ <env key="CLASSPATH" value="${junit_jogl_noawt.run.jars}"/>
+ <arg line="${junit.run.arg0}"/>
+ <arg line="${junit.run.arg1}"/>
+ <arg line="${jvmDataModel.arg}"/>
+ <arg value="-Djava.library.path=${obj.all.paths}"/>
+ <arg line="${jvmarg.headless}"/>
+ <arg line="${jvmarg.mainthrd}"/>
+ <!--
+ <arg line="-Dnewt.debug.EDT"/>
+ -->
+ <arg line="com.jogamp.newt.util.MainThread"/>
+ <arg line="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"/>
+ <!-- srcfile/ -->
+ <arg line="${testclass}"/>
+ <arg line="filtertrace=true"/>
+ <arg line="haltOnError=false"/>
+ <arg line="haltOnFailure=false"/>
+ <arg line="showoutput=true"/>
+ <arg line="outputtoformatters=true"/>
+ <arg line="logfailedtests=true"/>
+ <arg line="logtestlistenerevents=true"/>
+ <arg line="formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter"/>
+ <arg line="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.class.result.file}"/>
+ <fileset dir="${results.test}" includes="dummy.txt"/>
+ </apply>
+ </target>
+
+ <target name="generic.junit.run.swt.headless">
+ <!-- attribute name="generic.junit.run.swt.headless.include.pattern" -->
+
<!-- Test*SWTHeadless*
Emulation of junit task.
@@ -623,7 +622,7 @@
<for param="test.class.path.m" keepgoing="true">
<!-- results in absolute path -->
<fileset dir="${classes}">
- <include name="${java.dir.junit}/**/Test*SWT*"/>
+ <include name="@{generic.junit.run.swt.headless.include.pattern}"/>
<exclude name="**/*AWT*"/>
<exclude name="**/*$$*"/>
</fileset>
@@ -675,6 +674,13 @@
</apply>
</sequential>
</for>
+ <var name="generic.junit.run.swt.headless.include.pattern" unset="true"/>
+ </target>
+
+ <target name="junit.run.swt.headless" depends="test.compile" description="Runs all pure SWT tests." if="isSWTRuntimeAvailable">
+ <!-- Test*SWTHeadless* -->
+ <property name="generic.junit.run.swt.headless.include.pattern" value="${java.dir.junit}/**/Test*SWT*"/>
+ <antcall target="generic.junit.run.swt.headless" inheritRefs="true" inheritAll="true"/>
</target>
<target name="junit.run.swt.awt" depends="test.compile" description="Runs all pure SWT AWT tests." if="isSWTRuntimeAvailable">
@@ -1131,6 +1137,7 @@ ${line.separator}
<fileset dir="." includes="hs_err_pid*.log" />
</delete>
<mkdir dir="${results.test}" />
+ <touch file="${results.test}/dummy.txt"/>
</target>
<target name="junit.run.if.enabled" unless="junit.is.disabled">
diff --git a/make/build.xml b/make/build.xml
index f572ee5..03a711c 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -398,13 +398,13 @@
<property name="javadoc.nw.spec.windowtitle" value="NativeWindow API -- ${jogamp.version.base} Specification" />
<property name="javadoc.nw.spec.packagenames" value="javax.media.nativewindow.*" />
- <property name="javadoc.spec.windowtitle" value="JOGL API -- JSR-231 ${jogamp.version.base} Specification" />
+ <property name="javadoc.spec.windowtitle" value="JOGL API -- ${jogamp.version.base} Specification" />
<property name="javadoc.spec.packagenames" value="javax.media.opengl.*" />
<property name="javadoc.windowtitle" value="JOGL, NativeWindow and NEWT APIs" />
- <property name="javadoc.packagenames" value="${javadoc.nw.spec.packagenames}, ${javadoc.spec.packagenames}, com.jogamp.opengl.*, com.jogamp.nativewindow.*, com.jogamp.newt.* com.jogamp.oculusvr.*" />
+ <property name="javadoc.packagenames" value="${javadoc.nw.spec.packagenames}, ${javadoc.spec.packagenames}, com.jogamp.opengl.*, com.jogamp.graph.*, com.jogamp.nativewindow.*, com.jogamp.newt.*, com.jogamp.oculusvr.*" />
- <property name="javadoc.dev.packagenames" value="${javadoc.packagenames}, com.jogamp.opengl.*, com.jogamp.nativewindow.*, com.jogamp.newt.*, com.jogamp.gluegen.opengl.*, com.jogamp.gluegen.runtime.opengl.*, jogamp.nativewindow.*, jogamp.opengl.*, jogamp.newt.*" />
+ <property name="javadoc.dev.packagenames" value="${javadoc.packagenames}, com.jogamp.opengl.*, com.jogamp.graph.*, com.jogamp.nativewindow.*, com.jogamp.newt.*, com.jogamp.gluegen.opengl.*, com.jogamp.gluegen.runtime.opengl.*, jogamp.nativewindow.*, jogamp.opengl.*, jogamp.graph.*, jogamp.newt.*" />
<property name="java.excludes.javadoc.packagenames" value="jogamp.opengl.gl2.fixme.*,com.jogamp.audio.windows.waveout.TestSpatialization"/>
<property name="javadoc.bottom" value="Copyright 2010 JogAmp Community." />
diff --git a/make/resources/assets-test/arrow-blue-alpha-64x64.png b/make/resources/assets-test/arrow-blue-alpha-64x64.png
new file mode 100644
index 0000000..ec29db5
Binary files /dev/null and b/make/resources/assets-test/arrow-blue-alpha-64x64.png differ
diff --git a/make/resources/assets-test/arrow-red-alpha-64x64.png b/make/resources/assets-test/arrow-red-alpha-64x64.png
new file mode 100644
index 0000000..b8775ae
Binary files /dev/null and b/make/resources/assets-test/arrow-red-alpha-64x64.png differ
diff --git a/make/resources/assets-test/red-16x16.png b/make/resources/assets-test/red-16x16.png
new file mode 100644
index 0000000..7468390
Binary files /dev/null and b/make/resources/assets-test/red-16x16.png differ
diff --git a/make/resources/assets-test/red-32x32.png b/make/resources/assets-test/red-32x32.png
new file mode 100644
index 0000000..da2b44d
Binary files /dev/null and b/make/resources/assets-test/red-32x32.png differ
diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh
index 9e8d529..bb6bdf0 100755
--- a/make/scripts/make.jogl.all.linux-x86_64.sh
+++ b/make/scripts/make.jogl.all.linux-x86_64.sh
@@ -2,6 +2,12 @@
SDIR=`dirname $0`
+#J2RE_HOME=/opt-linux-x86_64/jre1.7.0_45
+#JAVA_HOME=/opt-linux-x86_64/jdk1.7.0_45
+#J2RE_HOME=/opt-linux-x86_64/jre7
+#JAVA_HOME=/opt-linux-x86_64/j2se7
+#export J2RE_HOME JAVA_HOME
+
if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then
. $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh
fi
diff --git a/make/scripts/make.jogl.all.win32.bat b/make/scripts/make.jogl.all.win32.bat
index 3e84d01..064b372 100755
--- a/make/scripts/make.jogl.all.win32.bat
+++ b/make/scripts/make.jogl.all.win32.bat
@@ -1,8 +1,8 @@
set THISDIR="C:\JOGL"
-set J2RE_HOME=c:\jre1.7.0_45_x32
-set JAVA_HOME=c:\jdk1.7.0_45_x32
-set ANT_PATH=C:\apache-ant-1.8.2
+set J2RE_HOME=c:\jre1.8.0_20_x32
+set JAVA_HOME=c:\jdk1.8.0_20_x32
+set ANT_PATH=C:\apache-ant-1.9.4
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat
index 6efa62b..b14b772 100755
--- a/make/scripts/make.jogl.all.win64.bat
+++ b/make/scripts/make.jogl.all.win64.bat
@@ -1,8 +1,8 @@
set THISDIR="C:\JOGL"
-set J2RE_HOME=c:\jre1.7.0_45_x64
-set JAVA_HOME=c:\jdk1.7.0_45_x64
-set ANT_PATH=C:\apache-ant-1.8.2
+set J2RE_HOME=c:\jre1.8.0_20_x32
+set JAVA_HOME=c:\jdk1.8.0_20_x32
+set ANT_PATH=C:\apache-ant-1.9.4
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH%
diff --git a/make/scripts/run-tests-linux-x86_64.sh b/make/scripts/run-tests-linux-x86_64.sh
new file mode 100755
index 0000000..28dca21
--- /dev/null
+++ b/make/scripts/run-tests-linux-x86_64.sh
@@ -0,0 +1,3 @@
+#! /bin/bash
+
+bash scripts/make.jogl.all.linux-x86_64.sh -f build-test.xml junit.run.sharedctx
diff --git a/make/scripts/run-tests-osx.sh b/make/scripts/run-tests-osx.sh
new file mode 100755
index 0000000..c83edab
--- /dev/null
+++ b/make/scripts/run-tests-osx.sh
@@ -0,0 +1,3 @@
+#! /bin/bash
+
+bash scripts/make.jogl.all.macosx.sh -f build-test.xml junit.run.sharedctx
diff --git a/make/scripts/tests-javaws-x64.bat b/make/scripts/tests-javaws-x64.bat
index 6186bc5..11e1575 100755
--- a/make/scripts/tests-javaws-x64.bat
+++ b/make/scripts/tests-javaws-x64.bat
@@ -1,4 +1,4 @@
-set JRE_PATH=C:\jre1.7.0_45_x64\bin
+set JRE_PATH=C:\jre1.7.0_67_x64\bin
set LOG_PATH=%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\log
%JRE_PATH%\javaws -uninstall
diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh
index 3828806..c95c69b 100755
--- a/make/scripts/tests-osx-x64.sh
+++ b/make/scripts/tests-osx-x64.sh
@@ -3,7 +3,8 @@
#export DYLD_LIBRARY_PATH=$HOME/ffmpeg-0.8_0.9/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$HOME/ffmpeg-2.2.3/lib:$DYLD_LIBRARY_PATH
-JAVA_HOME=`/usr/libexec/java_home -version 1.7`
+JAVA_HOME=`/usr/libexec/java_home -version 1.8`
+#JAVA_HOME=`/usr/libexec/java_home -version 1.7`
#JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_25`
#JAVA_HOME=`/usr/libexec/java_home -version 1.6.0`
PATH=$JAVA_HOME/bin:$PATH
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat
index fb6e847..2f67f43 100755
--- a/make/scripts/tests-win.bat
+++ b/make/scripts/tests-win.bat
@@ -10,7 +10,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGe
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.gl2.awt.TestGearsAWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %*
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 %*
@@ -77,12 +77,13 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDraw
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %*
-scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %*
-REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLException01NEWT %*
+
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT %*
@@ -184,7 +185,7 @@ REM scripts\java-win.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestMult
REM scripts\java-win.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT %*
REM scripts\java-win.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT %*
REM scripts\java-win.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT %*
-scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %*
+REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT
@@ -193,6 +194,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompil
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT %*
+scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindowAndPointerIconNEWT %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %*
REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %*
diff --git a/make/scripts/tests-x32-dbg.bat b/make/scripts/tests-x32-dbg.bat
index a37dd7b..4eb543a 100755
--- a/make/scripts/tests-x32-dbg.bat
+++ b/make/scripts/tests-x32-dbg.bat
@@ -1,8 +1,8 @@
set BLD_SUB=build-win32
-set J2RE_HOME=c:\jre1.7.0_45_x32
-set JAVA_HOME=c:\jdk1.7.0_45_x32
-set ANT_PATH=C:\apache-ant-1.8.2
+set J2RE_HOME=c:\jre1.7.0_67_x32
+set JAVA_HOME=c:\jdk1.7.0_67_x32
+set ANT_PATH=C:\apache-ant-1.9.4
set PROJECT_ROOT=D:\projects\jogamp\jogl
set BLD_DIR=..\%BLD_SUB%
@@ -20,7 +20,7 @@ set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH%
REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj
set LIB_DIR=
-set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar
+set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\%BLD_SUB%\gluegen-test-util.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar
echo CP_ALL %CP_ALL%
diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat
index 4111385..5396f91 100755
--- a/make/scripts/tests-x32.bat
+++ b/make/scripts/tests-x32.bat
@@ -1,8 +1,8 @@
set BLD_SUB=build-win32
-set J2RE_HOME=c:\jre1.7.0_45_x32
-set JAVA_HOME=c:\jdk1.7.0_45_x32
-set ANT_PATH=C:\apache-ant-1.8.2
+set J2RE_HOME=c:\jre1.7.0_67_x32
+set JAVA_HOME=c:\jdk1.7.0_67_x32
+set ANT_PATH=C:\apache-ant-1.9.4
set PROJECT_ROOT=D:\projects\jogamp\jogl
set BLD_DIR=..\%BLD_SUB%
@@ -21,7 +21,7 @@ set BLD_DIR=..\%BLD_SUB%
REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib
set LIB_DIR=
-set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar
+set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\%BLD_SUB%\gluegen-test-util.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar
echo CP_ALL %CP_ALL%
diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat
index f18072b..1f0b881 100755
--- a/make/scripts/tests-x64-dbg.bat
+++ b/make/scripts/tests-x64-dbg.bat
@@ -1,8 +1,8 @@
set BLD_SUB=build-win64
-set J2RE_HOME=c:\jre1.7.0_45_x64
-set JAVA_HOME=c:\jdk1.7.0_45_x64
-set ANT_PATH=C:\apache-ant-1.8.2
+set J2RE_HOME=c:\jre1.7.0_67_x64
+set JAVA_HOME=c:\jdk1.7.0_67_x64
+set ANT_PATH=C:\apache-ant-1.9.4
set PROJECT_ROOT=D:\projects\jogamp\jogl
set BLD_DIR=..\%BLD_SUB%
@@ -16,7 +16,7 @@ REM 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\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH%
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH%
-set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar
+set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\%BLD_SUB%\gluegen-test-util.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar
echo CP_ALL %CP_ALL%
@@ -36,6 +36,7 @@ REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryN
REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas"
REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile"
REM set D_ARGS="-Djogamp.debug.IOUtil"
+set D_ARGS="-Djogl.debug.GLSLCode"
REM set D_ARGS="-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer"
REM set D_ARGS="-Djogl.debug.GLMediaPlayer"
REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.AudioSink"
diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat
index f13ea2e..e8e58a2 100755
--- a/make/scripts/tests-x64.bat
+++ b/make/scripts/tests-x64.bat
@@ -1,8 +1,8 @@
set BLD_SUB=build-win64
-set J2RE_HOME=c:\jre1.7.0_45_x64
-set JAVA_HOME=c:\jdk1.7.0_45_x64
-set ANT_PATH=C:\apache-ant-1.8.2
+set J2RE_HOME=c:\jre1.7.0_67_x64
+set JAVA_HOME=c:\jdk1.7.0_67_x64
+set ANT_PATH=C:\apache-ant-1.9.4
REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x64
REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64
@@ -16,7 +16,7 @@ set BLD_DIR=..\%BLD_SUB%
REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj
set LIB_DIR=
-set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar
+set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\atomic\oculusvr.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\%BLD_SUB%\gluegen-test-util.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar
echo CP_ALL %CP_ALL%
set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true"
diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-x64.sh
index 421b912..30b0aaf 100755
--- a/make/scripts/tests-x64.sh
+++ b/make/scripts/tests-x64.sh
@@ -12,6 +12,12 @@ SDIR=`dirname $0`
#export LD_LIBRARY_PATH=$HOME/ffmpeg-2.2.2/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$HOME/ffmpeg-2.2.3/lib:$LD_LIBRARY_PATH
+#J2RE_HOME=/opt-linux-x86_64/jre1.7.0_45
+#JAVA_HOME=/opt-linux-x86_64/jdk1.7.0_45
+#J2RE_HOME=/opt-linux-x86_64/jre7
+#JAVA_HOME=/opt-linux-x86_64/j2se7
+#export J2RE_HOME JAVA_HOME
+
if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then
. $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh
fi
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 1e229ec..fb4130f 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -96,6 +96,7 @@ function jrun() {
#D_ARGS="-Djogamp.debug=all"
#D_ARGS="-Dnativewindow.debug=all"
#D_ARGS="-Djogl.debug=all"
+ #D_ARGS="-Djogl.debug=all -Dnewt.debug=all -Djogl.debug.DebugGL"
#D_ARGS="-Dnewt.debug=all"
#D_ARGS="-Djogl.debug=all -Dnewt.debug=all"
#D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all"
@@ -122,6 +123,7 @@ function jrun() {
#D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject"
#D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker"
#D_ARGS="-Djogl.debug.FBObject"
+ #D_ARGS="-Djogl.debug.FBObject.Swap -Djogl.debug.GLJPanel.Frames"
#D_ARGS="-Djogl.debug.GLBufferStateTracker -Djogl.debug.GLBufferObjectTracker -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=600000 -Dnewt.debug.EDT"
#D_ARGS="-Djogl.debug.GLBufferStateTracker -Djogl.debug.GLBufferObjectTracker"
#D_ARGS="-Djogl.debug.GLBufferObjectTracker"
@@ -143,6 +145,7 @@ function jrun() {
#D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState -Djogl.debug.ImmModeSink.Buffer -Djogl.debug.ImmModeSink.Draw"
#D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode"
#D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window"
+ #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch -Djogl.debug.GLDrawable"
#D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject"
#D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration"
#D_ARGS="-Dnativewindow.debug.GraphicsConfiguration"
@@ -155,7 +158,6 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas"
#D_ARGS="-Djogl.debug.GLDrawable"
#D_ARGS="-Djogl.debug.GLEventListenerState"
- #D_ARGS="-Djogl.fbo.force.none"
#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"
@@ -194,8 +196,10 @@ function jrun() {
#D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window"
#D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext"
#D_ARGS="-Dnativewindow.debug.NativeWindow -Dnativewindow.debug.X11Util"
+ #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Dnativewindow.debug.ToolkitLock.TraceLock"
+ #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnewt.debug=all"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Dnativewindow.debug.X11Util"
@@ -231,6 +235,10 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl -Djogl.debug.FBObject.MaxTextureSize=512"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Dnativewindow.awt.nohidpi"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.debug.GLJPanel.Viewport"
+ #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.debug.FBObject"
+ #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.FBObject -Djogl.fbo.force.nocolorrenderbuffer"
+ #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.FBObject"
+ #D_ARGS="-Djogl.fbo.force.none"
#D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL"
#D_ARGS="-Djogl.gljpanel.noverticalflip"
#D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator"
@@ -284,7 +292,7 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer"
#D_ARGS="-Djogl.debug.GLMediaPlayer.Native"
#D_ARGS="-Djogl.debug.StereoDevice -Djogl.debug.StereoDevice.DumpData"
- D_ARGS="-Djogl.debug.StereoDevice"
+ #D_ARGS="-Djogl.debug.StereoDevice"
if [ $awton -eq 1 ] ; then
export USE_CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH
@@ -377,12 +385,12 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $*
+testawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $*
#
# Stereo
#
-testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#
# HiDPI
@@ -425,6 +433,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl4.newt.TestTessellationShader01GL4NEWT $*
#
# av demos
@@ -488,19 +497,20 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestCPUSourcingAPINEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLExtensionQueryOffscreen $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $*
+#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.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 $*
-#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $*
-#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $*
-#testswt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $*
-#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $*
-#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $*
-#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT4 $*
+#testswt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $*
@@ -531,6 +541,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLOffscreenAutoDrawableBug1044AWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $*
@@ -545,6 +556,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch13Newt2AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestBug722GLContextDrawableSwitchNewt2AWT $*
@@ -575,6 +587,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowAndPointerIconNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $*
@@ -651,6 +664,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $*
+#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLJPanelRecreate01 $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $*
@@ -665,6 +679,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.Bug818GLJPanelAndGLCanvasApplet $*
+#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.GLJPanelsAndGLCanvasDemoGL2Applet $*
+
#testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $*
#testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $*
#testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $*
@@ -728,6 +745,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
#testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $*
+#testawt com.jogamp.opengl.test.junit.newt.TestMultipleNewtCanvasAWT $*
#testawt $*
@@ -800,6 +818,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.stereo.StereoDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $*
#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $*
+#testnoawt com.jogamp.opengl.test.junit.graph.TestFontsNEWT00 $*
+#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWTBugXXXX $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo $*
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index e7c452f..bc500d8 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -796,4 +796,10 @@ public class OutlineShape implements Comparable<OutlineShape> {
public final int hashCode() {
throw new InternalError("hashCode not designed");
}
+
+ @Override
+ public String toString() {
+ // Avoid calling this.hashCode() !
+ return getClass().getName() + "@" + Integer.toHexString(super.hashCode());
+ }
}
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 350e3ef..023ca83 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -35,6 +35,7 @@ import jogamp.opengl.Debug;
import com.jogamp.graph.geom.Triangle;
import com.jogamp.graph.geom.Vertex;
+import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.math.geom.Frustum;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -43,7 +44,7 @@ import com.jogamp.opengl.util.texture.TextureSequence;
* Abstract Outline shape representation define the method an OutlineShape(s)
* is bound and rendered.
*
- * @see com.jogamp.graph.curve.opengl.GLRegion
+ * @see GLRegion
*/
public abstract class Region {
@@ -179,7 +180,7 @@ public abstract class Region {
protected abstract void pushIndex(int idx);
/**
- * Return bit-field of render modes, see {@link com.jogamp.graph.curve.opengl.GLRegion#create(int, TextureSequence)}.
+ * Return bit-field of render modes, see {@link GLRegion#create(int, TextureSequence)}.
*/
public final int getRenderModes() { return renderModes; }
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
index 8f3a10d..654f9a6 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -37,6 +37,7 @@ import jogamp.graph.curve.opengl.VBORegionSPES2;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.texture.TextureSequence;
import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.OutlineShape;
/** A GLRegion is the OGL binding of one or more OutlineShapes
* Defined by its vertices and generated triangles. The Region
@@ -46,7 +47,8 @@ import com.jogamp.graph.curve.Region;
* Implementations of the GLRegion shall take care of the OGL
* binding of the depending on its context, profile.
*
- * @see Region, RegionFactory, OutlineShape
+ * @see Region
+ * @see OutlineShape
*/
public abstract class GLRegion extends Region {
@@ -118,7 +120,7 @@ public abstract class GLRegion extends Region {
* it afterwards when used in conjunction with other renderer.
* </p>
* <p>
- * Users shall also consider setting the {@link GL#glClearColor(float, float, float, float) Clear Color}
+ * Users shall also consider setting the {@link GL#glClearColor(float, float, float, float) clear-color}
* appropriately:
* <ul>
* <li>If {@link GL#GL_BLEND blending} is enabled, <i>RGB</i> shall be set to text color, otherwise
@@ -129,7 +131,7 @@ public abstract class GLRegion extends Region {
* Note: If {@link GL#GL_BLEND blending} is enabled, the
* {@link RegionRenderer} might need to be
* {@link RegionRenderer#create(RenderState, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback) created}
- * with the appropriate {@link {@link RegionRenderer.GLCallback callbacks}.
+ * with the appropriate {@link RegionRenderer.GLCallback callbacks}.
* </p>
* @param matrix current {@link PMVMatrix}.
* @param renderer the {@link RegionRenderer} to be used
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index 23b8263..a0f54d3 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -59,6 +59,15 @@ public class RegionRenderer {
protected static final boolean DEBUG = Region.DEBUG;
protected static final boolean DEBUG_INSTANCE = Region.DEBUG_INSTANCE;
+ /**
+ * May be passed to
+ * {@link RegionRenderer#create(RenderState, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback, com.jogamp.graph.curve.opengl.RegionRenderer.GLCallback) RegionRenderer ctor},
+ * e.g.
+ * <ul>
+ * <li>{@link RegionRenderer#defaultBlendEnable}</li>
+ * <li>{@link RegionRenderer#defaultBlendDisable}</li>
+ * </ul>
+ */
public interface GLCallback {
/**
* @param gl a current GL object
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index 92d3576..52ad407 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -88,7 +88,7 @@ public interface Font {
float getScale(final float pixelSize);
/**
* @param dest AABBox instance set to this metrics boundary w/ given pixelSize
- * @param pixelSize
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
* @param tmpV3 caller provided temporary 3-component vector
* @return the given and set AABBox 'dest'
*/
@@ -113,14 +113,25 @@ public interface Font {
public char getSymbol();
public short getID();
public AABBox getBBox();
+ /**
+ *
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
+ * @return
+ */
public float getScale(final float pixelSize);
/**
* @param dest AABBox instance set to this metrics boundary w/ given pixelSize
- * @param pixelSize
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
* @param tmpV3 caller provided temporary 3-component vector
* @return the given and set AABBox 'dest'
*/
public AABBox getBBox(final AABBox dest, final float pixelSize, float[] tmpV3);
+ /**
+ *
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link Font#getPixelSize(float, float)}
+ * @param useFrationalMetrics
+ * @return
+ */
public float getAdvance(final float pixelSize, boolean useFrationalMetrics);
public OutlineShape getShape();
public int hashCode();
@@ -153,13 +164,37 @@ public interface Font {
*/
public float getPixelSize(final float fontSize /* points per inch */, final float resolution);
+ /**
+ *
+ * @param glyphID
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @return
+ */
public float getAdvanceWidth(final int glyphID, final float pixelSize);
public Metrics getMetrics();
public Glyph getGlyph(final char symbol);
public int getNumGlyphs();
+ /**
+ *
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @return
+ */
public float getLineHeight(final float pixelSize);
+ /**
+ *
+ * @param string
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @return
+ */
public float getMetricWidth(final CharSequence string, final float pixelSize);
+ /**
+ *
+ * @param string
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
+ * @param tmp
+ * @return
+ */
public float getMetricHeight(final CharSequence string, final float pixelSize, final AABBox tmp);
/**
* Return the <i>layout</i> bounding box as computed by each glyph's metrics.
@@ -168,7 +203,7 @@ public interface Font {
* See {@link #getPointsBounds(AffineTransform, CharSequence, float, AffineTransform, AffineTransform)} for pixel correct results.
* </p>
* @param string string text
- * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
*/
public AABBox getMetricBounds(final CharSequence string, final float pixelSize);
@@ -176,7 +211,7 @@ public interface Font {
* Return the bounding box by taking each glyph's point-based bounding box into account.
* @param transform optional given transform
* @param string string text
- * @param pixelSize Use {@link Font#getPixelSize(float, float)} for resolution correct pixel-size.
+ * @param pixelSize Use <code>pointSize * resolution</code> for resolution correct pixel-size, see {@link #getPixelSize(float, float)}
* @param temp1 temporary AffineTransform storage, mandatory
* @param temp2 temporary AffineTransform storage, mandatory
*/
diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java
index 4caf06e..ec0225b 100644
--- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java
+++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java
@@ -32,6 +32,8 @@ import java.util.ArrayList;
import jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.geom.Vertex;
+import com.jogamp.graph.curve.OutlineShape;
+import com.jogamp.graph.curve.Region;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.VectorUtil;
import com.jogamp.opengl.math.geom.AABBox;
@@ -45,7 +47,8 @@ import com.jogamp.opengl.math.geom.AABBox;
*
* Note: An outline should be closed to be rendered as a region.
*
- * @see OutlineShape, Region
+ * @see OutlineShape
+ * @see Region
*/
public class Outline implements Comparable<Outline> {
@@ -278,4 +281,9 @@ public class Outline implements Comparable<Outline> {
public final int hashCode() {
throw new InternalError("hashCode not designed");
}
+ @Override
+ public String toString() {
+ // Avoid calling this.hashCode() !
+ return getClass().getName() + "@" + Integer.toHexString(super.hashCode());
+ }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java
index a378171..58fde80 100644
--- a/src/jogl/classes/com/jogamp/opengl/FBObject.java
+++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java
@@ -37,6 +37,7 @@ import javax.media.opengl.GL2GL3;
import javax.media.opengl.GL3;
import javax.media.opengl.GLBase;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
@@ -623,7 +624,7 @@ public class FBObject {
* <p>
* For GLES3, sampling-sink format <b>must be equal</b> w/ the sampling-source {@link Colorbuffer},
* see details below. Implementation aligns w/ {@link #createColorAttachment(boolean)}
- * and is enforced via {@link #sampleSinkFormatMismatch(GL)}.
+ * and is enforced via {@link #sampleSinkExFormatMismatch(GL)}.
* </p>
* <p>
* ES3 BlitFramebuffer Requirements: OpenGL ES 3.0.2 p194: 4.3.2 Copying Pixels
@@ -664,23 +665,40 @@ public class FBObject {
*/
public static final TextureAttachment createColorTextureAttachment(final GL gl, final boolean alpha, final int width, final int height,
final int magFilter, final int minFilter, final int wrapS, final int wrapT) {
- final int textureInternalFormat, textureDataFormat, textureDataType;
+ final int internalFormat, dataFormat, dataType;
if(gl.isGLES3()) {
- textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8;
- textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
- textureDataType = GL.GL_UNSIGNED_BYTE;
+ internalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8;
+ dataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
+ dataType = GL.GL_UNSIGNED_BYTE;
} else if(gl.isGLES()) {
- textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
- textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
- textureDataType = GL.GL_UNSIGNED_BYTE;
+ internalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
+ dataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
+ dataType = GL.GL_UNSIGNED_BYTE;
} else {
- textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8;
+ internalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8;
// textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
// textureInternalFormat = alpha ? 4 : 3;
- textureDataFormat = alpha ? GL.GL_BGRA : GL.GL_RGB;
- textureDataType = alpha ? GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV : GL.GL_UNSIGNED_BYTE;
+ dataFormat = alpha ? GL.GL_BGRA : GL.GL_RGB;
+ dataType = alpha ? GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV : GL.GL_UNSIGNED_BYTE;
}
- return createColorTextureAttachment(textureInternalFormat, width, height, textureDataFormat, textureDataType, magFilter, minFilter, wrapS, wrapT);
+ return createColorTextureAttachment(internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT);
+ }
+
+ public static final TextureAttachment createColorTextureAttachment(final GL gl, final int internalFormat, final int width, final int height,
+ final int magFilter, final int minFilter, final int wrapS, final int wrapT) {
+ final int dataFormat, dataType;
+ final boolean alpha = hasAlpha(internalFormat);
+ if( gl.isGLES3() ) {
+ dataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
+ dataType = GL.GL_UNSIGNED_BYTE;
+ } else if( gl.isGLES() ) {
+ dataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB;
+ dataType = GL.GL_UNSIGNED_BYTE;
+ } else {
+ dataFormat = alpha ? GL.GL_BGRA : GL.GL_RGB;
+ dataType = alpha ? GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV : GL.GL_UNSIGNED_BYTE;
+ }
+ return createColorTextureAttachment(internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT);
}
/**
@@ -738,6 +756,7 @@ public class FBObject {
private int textureAttachmentCount;
private Colorbuffer[] colorbufferAttachments; // colorbuffer attachment points
private RenderAttachment depth, stencil; // depth and stencil maybe equal in case of packed-depth-stencil
+ private boolean modified; // size, sampleCount, or any attachment modified
private FBObject samplingSink; // MSAA sink
private Colorbuffer samplingColorSink;
@@ -752,44 +771,59 @@ public class FBObject {
throw new GLException("FBO not initialized");
}
if(maxColorAttachments != colorbufferAttachments.length) {
- throw new InternalError("maxColorAttachments "+maxColorAttachments+", array.length "+colorbufferAttachments.length);
+ throw new InternalError(String.format("maxColorAttachments %d, array.length %d",
+ maxColorAttachments, colorbufferAttachments.length) );
}
if(0 > point || point >= maxColorAttachments) {
- throw new IllegalArgumentException("attachment point out of range: "+point+", should be within [0.."+(maxColorAttachments-1)+"], "+this);
+ throw new IllegalArgumentException(String.format("attachment point out of range: %d, should be within [0..%d], %s",
+ point, maxColorAttachments-1, this.toString() ) );
}
}
private final void validateAddColorAttachment(final int point, final Colorbuffer ca) {
validateColorAttachmentPointRange(point);
if( null != colorbufferAttachments[point] ) {
- throw new IllegalArgumentException("Cannot attach "+ca+", attachment point already in use by "+colorbufferAttachments[point]+", "+this);
+ throw new IllegalStateException(String.format("Cannot attach %s at %d, attachment point already in use by %s, %s",
+ ca.toString(), point, colorbufferAttachments[point].toString(), this.toString() ) );
}
}
- private final void addColorAttachment(final int point, final Colorbuffer ca) {
- validateColorAttachmentPointRange(point);
+ private final void addColorAttachment(final int point, final Colorbuffer ca, final boolean validate) {
final Colorbuffer c = colorbufferAttachments[point];
- if( null != c && c != ca ) {
- throw new IllegalArgumentException("Add failed: requested to add "+ca+" at "+point+", but slot is holding "+c+"; "+this);
+ if( validate ) {
+ validateColorAttachmentPointRange(point);
+ if( null == ca ) {
+ throw new IllegalArgumentException("Colorbuffer is null");
+ }
+ if( null != c ) {
+ throw new IllegalStateException(String.format("Cannot attach %s at %d, attachment point already in use by %s, %s",
+ ca.toString(), point, c.toString(), this.toString() ) );
+ }
}
colorbufferAttachments[point] = ca;
colorbufferCount++;
if( ca.isTextureAttachment() ) {
textureAttachmentCount++;
}
+ modified = true;
}
private final void removeColorAttachment(final int point, final Colorbuffer ca) {
validateColorAttachmentPointRange(point);
+ if( null == ca ) {
+ throw new IllegalArgumentException("Colorbuffer is null");
+ }
final Colorbuffer c = colorbufferAttachments[point];
- if( null != c && c != ca ) {
- throw new IllegalArgumentException("Remove failed: requested to removed "+ca+" at "+point+", but slot is holding "+c+"; "+this);
+ if( c != ca ) {
+ throw new IllegalStateException(String.format("Cannot detach %s at %d, slot is holding other: %s, %s",
+ ca.toString(), point, c.toString(), this.toString() ) );
}
colorbufferAttachments[point] = null;
colorbufferCount--;
if( ca.isTextureAttachment() ) {
textureAttachmentCount--;
}
+ modified = true;
}
/**
@@ -899,15 +933,32 @@ public class FBObject {
this.textureAttachmentCount = 0;
this.depth = null;
this.stencil = null;
+ this.modified = true;
this.samplingSink = null;
this.samplingColorSink = null;
this.samplingSinkDirty = true;
}
- private void init(final GL gl, int width, int height, final int samples) throws GLException {
- if(initialized) {
- throw new GLException("FBO already initialized");
+ /**
+ * Initializes this FBO's instance.
+ * <p>
+ * The sampling sink is not initializes, allowing manual assignment via {@link #setSamplingSink(FBObject)}
+ * if {@code newSamples > 0}.
+ * </p>
+ *
+ * <p>Leaves the FBO bound</p>
+ *
+ * @param gl the current GL context
+ * @param newWidth the initial width, it's minimum is capped to 1
+ * @param newHeight the initial height, it's minimum is capped to 1
+ * @param newSamples if > 0, MSAA will be used, otherwise no multisampling. Will be capped to {@link #getMaxSamples()}.
+ * @throws IllegalStateException if already initialized
+ * @throws GLException in case of an error, i.e. size too big, etc ..
+ */
+ public void init(final GL gl, final int newWidth, final int newHeight, final int newSamples) throws IllegalStateException, GLException {
+ if( initialized ) {
+ throw new IllegalStateException("FBO already initialized");
}
if( !gl.hasBasicFBOSupport() ) {
throw new GLException("FBO not supported w/ context: "+gl.getContext()+", "+this);
@@ -947,7 +998,7 @@ public class FBObject {
colorbufferCount = 0;
textureAttachmentCount = 0;
- maxSamples = gl.getMaxRenderbufferSamples();
+ maxSamples = gl.getMaxRenderbufferSamples(); // if > 0 implies fullFBOSupport
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0);
final int _maxTextureSize = val[0];
if( 0 < USER_MAX_TEXTURE_SIZE ) {
@@ -960,14 +1011,12 @@ public class FBObject {
checkPreGLError(gl);
- if( 0 >= width ) { width = 1; }
- if( 0 >= height ) { height = 1; }
- this.width = width;
- this.height = height;
- this.samples = samples <= maxSamples ? samples : maxSamples;
+ this.width = 0 < newWidth ? newWidth : 1;
+ this.height = 0 < newHeight ? newHeight : 1;
+ this.samples = newSamples <= maxSamples ? newSamples : maxSamples;
if(DEBUG) {
- System.err.println("FBObject.init() START: "+width+"x"+height+", "+samples+" -> "+this.samples+" samples");
+ System.err.println("FBObject.init() START: "+width+"x"+height+", "+newSamples+" -> "+this.samples+" samples");
System.err.println("fullFBOSupport: "+fullFBOSupport);
System.err.println("maxColorAttachments: "+maxColorAttachments+"/"+realMaxColorAttachments+" [capped/real]");
System.err.println("maxSamples: "+maxSamples);
@@ -988,14 +1037,12 @@ public class FBObject {
checkNoError(null, gl.glGetError(), "FBObject Init.pre"); // throws GLException if error
- if( textureAttachmentCount > 0 && ( width > 2 + maxTextureSize || height > 2 + maxTextureSize ) ) {
- throw new GLException("Size "+width+"x"+height+" exceeds on of the maximum texture size "+maxTextureSize+": \n\t"+this);
- }
if( width > maxRenderbufferSize || height > maxRenderbufferSize ) {
throw new GLException("Size "+width+"x"+height+" exceeds on of the maxima renderbuffer size "+maxRenderbufferSize+": \n\t"+this);
}
- resetSamplingSink(gl);
+ modified = true;
+ samplingSinkDirty = true;
// generate fbo ..
gl.glGenFramebuffers(1, val, 0);
@@ -1011,7 +1058,6 @@ public class FBObject {
checkNoError(gl, GL.GL_INVALID_VALUE, "FBObject Init.isFB"); // throws GLException
}
bound = true;
- samplingSinkDirty = true;
initialized = true;
vStatus = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; // always incomplete w/o attachments!
@@ -1022,15 +1068,41 @@ public class FBObject {
}
/**
- * Initializes or resets this FBO's instance.
+ * Resets this FBO's instance.
* <p>
* In case the new parameters are compatible with the current ones
- * no action will be performed. Otherwise all attachments will be recreated
+ * no action will be performed and method returns immediately.<br>
+ * Otherwise all attachments will be recreated
* to match the new given parameters.
* </p>
* <p>
- * Incompatibility and hence recreation is forced if
- * the size or sample count doesn't match for subsequent calls.
+ * {@link #resetSamplingSink(GL)} is being issued immediately
+ * to match the new configuration.
+ * </p>
+ *
+ * <p>Leaves the FBO bound state untouched</p>
+ *
+ * @param gl the current GL context
+ * @param newWidth the new width, it's minimum is capped to 1
+ * @param newHeight the new height, it's minimum is capped to 1
+ * @param newSamples if > 0, MSAA will be used, otherwise no multisampling. Will be capped to {@link #getMaxSamples()}.
+ * @return {@code true} if this instance has been modified, otherwise {@code false}.
+ * @throws IllegalStateException if not initialized via {@link #init(GL, int, int, int)}.
+ * @throws GLException in case of an error, i.e. size too big, etc ..
+ */
+ public final boolean reset(final GL gl, final int newWidth, final int newHeight, final int newSamples) throws GLException, IllegalStateException {
+ if( !initialized ) {
+ throw new IllegalStateException("FBO not initialized");
+ }
+ return resetImpl(gl, newWidth, newHeight, newSamples, true);
+ }
+
+ /**
+ * Initializes or resets this FBO's instance.
+ * <p>
+ * In case the new parameters are compatible with the current ones
+ * no action will be performed. Otherwise all attachments will be recreated
+ * to match the new given parameters.
* </p>
*
* <p>Leaves the FBO bound state untouched</p>
@@ -1039,9 +1111,10 @@ public class FBObject {
* @param newWidth
* @param newHeight
* @throws GLException in case of an error
+ * @deprecated Use {@link #init(GL, int, int, int)} or {@link #reset(GL, int, int, int)}
*/
public final void reset(final GL gl, final int newWidth, final int newHeight) {
- reset(gl, newWidth, newHeight, 0, false);
+ resetImpl(gl, newWidth, newHeight, 0, false);
}
/**
@@ -1051,10 +1124,6 @@ public class FBObject {
* no action will be performed. Otherwise all attachments will be recreated
* to match the new given parameters.
* </p>
- * <p>
- * Currently incompatibility and hence recreation of the attachments will be performed
- * if the size or sample count doesn't match for subsequent calls.
- * </p>
*
* <p>Leaves the FBO bound state untouched</p>
*
@@ -1068,11 +1137,16 @@ public class FBObject {
* from implicit double buffering while resetting the sink just before it's being used, eg. at swap-buffer.
*
* @throws GLException in case of an error, i.e. size too big, etc ..
+ * @deprecated Use {@link #init(GL, int, int, int)} or {@link #reset(GL, int, int, int)}
*/
- public final void reset(final GL gl, int newWidth, int newHeight, int newSamples, final boolean resetSamplingSink) {
+ public final void reset(final GL gl, final int newWidth, final int newHeight, final int newSamples, final boolean resetSamplingSink) {
+ resetImpl(gl, newWidth, newHeight, newSamples, resetSamplingSink);
+ }
+
+ private final boolean resetImpl(final GL gl, int newWidth, int newHeight, int newSamples, final boolean resetSamplingSink) {
if( !initialized ) {
init(gl, newWidth, newHeight, newSamples);
- return;
+ return true;
}
newSamples = newSamples <= maxSamples ? newSamples : maxSamples; // clamp
@@ -1107,25 +1181,52 @@ public class FBObject {
height = newHeight;
samples = newSamples;
- if(0 < samples && null == samplingSink ) {
- // needs valid samplingSink for detach*() -> bind()
- samplingSink = new FBObject();
- samplingSink.init(gl, width, height, 0);
- }
+ modified = true;
+ samplingSinkDirty = true;
+
detachAllImpl(gl, true, true, sampleCountChange);
- if(resetSamplingSink) {
+ if( resetSamplingSink ) {
resetSamplingSink(gl);
}
- samplingSinkDirty = true;
-
if(!wasBound) {
unbind(gl);
}
if(DEBUG) {
- System.err.println("FBObject.reset - END - "+this);
+ System.err.println("FBObject.reset - END - wasBound, "+wasBound+", "+this);
}
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Simply resets this instance's size only, w/o validation.
+ *
+ * <p>Leaves the FBO bound</p>
+ *
+ * @param gl the current GL context
+ * @param newWidth the new width, it's minimum is capped to 1
+ * @param newHeight the new height, it's minimum is capped to 1
+ */
+ private final void resetSizeImpl(final GL gl, final int newWidth, final int newHeight) {
+ if(DEBUG) {
+ System.err.println("FBObject.resetSize - START - "+width+"x"+height+", "+samples+" -> "+newWidth+"x"+newHeight);
+ }
+
+ final int sampleCountChange = 0; // keep MSAA settings
+ width = newWidth;
+ height = newHeight;
+
+ modified = true;
+ samplingSinkDirty = true;
+
+ detachAllImpl(gl, true, true, sampleCountChange);
+
+ if(DEBUG) {
+ System.err.println("FBObject.resetSize - END - "+this);
}
}
@@ -1349,7 +1450,7 @@ public class FBObject {
* <p>
* For GLES3, sampling-sink {@link Colorbuffer} format <b>must be equal</b> w/ the sampling-source {@link Colorbuffer}.
* Implementation aligns w/ {@link #createColorTextureAttachment(GLProfile, boolean, int, int, int, int, int, int)}
- * and is enforced via {@link #sampleSinkFormatMismatch(GL)}.
+ * and is enforced via {@link #sampleSinkExFormatMismatch(GL)}.
* </p>
*
* @param alpha set to <code>true</code> if you request alpha channel, otherwise <code>false</code>;
@@ -1371,7 +1472,7 @@ public class FBObject {
* <p>
* For GLES3, sampling-sink {@link Colorbuffer} format <b>must be equal</b> w/ the sampling-source {@link Colorbuffer}.
* Implementation aligns w/ {@link #createColorTextureAttachment(GLProfile, boolean, int, int, int, int, int, int)}
- * and is enforced via {@link #sampleSinkFormatMismatch(GL)}.
+ * and is enforced via {@link #sampleSinkExFormatMismatch(GL)}.
* </p>
*
* @param alpha set to <code>true</code> if you request alpha channel, otherwise <code>false</code>;
@@ -1386,8 +1487,11 @@ public class FBObject {
}
/**
- * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point,
- * selecting the format automatically.
+ * Attaches a newly created and {@link Colorbuffer#initialize(GL) initialized} {@link Colorbuffer}, i.e. a {@link ColorAttachment},
+ * at the given attachment point.
+ * <p>
+ * The {@link ColorAttachment} is created using {@code alpha} if {@code true} and current {@code sample count} and {@code size}.
+ * </p>
*
* <p>Leaves the FBO bound.</p>
*
@@ -1403,7 +1507,11 @@ public class FBObject {
}
/**
- * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point.
+ * Attaches a newly created and {@link Colorbuffer#initialize(GL) initialized} {@link Colorbuffer}, i.e. a {@link ColorAttachment},
+ * at the given attachment point.
+ * <p>
+ * The {@link ColorAttachment} is created using the given {@code internalFormat} and current {@code sample count} and {@code size}.
+ * </p>
*
* <p>Leaves the FBO bound.</p>
*
@@ -1424,9 +1532,11 @@ public class FBObject {
}
/**
- * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment},
- * to this FBO's instance at the given attachment point.
- *
+ * Attaches a {@link Colorbuffer} at the given attachment point
+ * and {@link Colorbuffer#initialize(GL) initializes} it, if not done yet.
+ * <p>
+ * {@link Colorbuffer} may be a {@link ColorAttachment} or {@link TextureAttachment}.
+ * </p>
* <p>
* If {@link Colorbuffer} is a {@link TextureAttachment} and is uninitialized, i.e. it's texture name is <code>zero</code>,
* a new texture name is generated and setup w/ the texture parameter.<br/>
@@ -1439,7 +1549,7 @@ public class FBObject {
* @param gl
* @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1]
* @param colbuf the to be attached {@link Colorbuffer}
- * @return newly attached {@link Colorbuffer} instance if bound and configured successfully, otherwise GLException is thrown
+ * @return given {@link Colorbuffer} instance if bound and configured successfully, otherwise GLException is thrown
* @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment}
*/
public final Colorbuffer attachColorbuffer(final GL gl, final int attachmentPoint, final Colorbuffer colbuf) throws GLException {
@@ -1449,10 +1559,10 @@ public class FBObject {
private final Colorbuffer attachColorbufferImpl(final GL gl, final int attachmentPoint, final Colorbuffer colbuf) throws GLException {
validateAddColorAttachment(attachmentPoint, colbuf);
-
validateAttachmentSize((Attachment)colbuf);
+
final boolean initializedColorbuf = colbuf.initialize(gl);
- addColorAttachment(attachmentPoint, colbuf);
+ addColorAttachment(attachmentPoint, colbuf, false);
if( colbuf.isTextureAttachment() ) {
final TextureAttachment texA = colbuf.getTextureAttachment();
@@ -1498,6 +1608,68 @@ public class FBObject {
return colbuf;
}
+ private final int getDepthIFormat(final int reqBits) {
+ if( 32 <= reqBits && depth32Avail ) {
+ return GL.GL_DEPTH_COMPONENT32;
+ } else if( 24 <= reqBits && ( depth24Avail || depth32Avail ) ) {
+ if( depth24Avail ) {
+ return GL.GL_DEPTH_COMPONENT24;
+ } else {
+ return GL.GL_DEPTH_COMPONENT32;
+ }
+ } else {
+ return GL.GL_DEPTH_COMPONENT16;
+ }
+ }
+ private final int getStencilIFormat(final int reqBits) {
+ if( 16 <= reqBits && stencil16Avail ) {
+ return GL2GL3.GL_STENCIL_INDEX16;
+ } else if( 8 <= reqBits && ( stencil08Avail || stencil16Avail ) ) {
+ if( stencil08Avail ) {
+ return GL.GL_STENCIL_INDEX8;
+ } else {
+ return GL2GL3.GL_STENCIL_INDEX16;
+ }
+ } else if( 4 <= reqBits && ( stencil04Avail || stencil08Avail || stencil16Avail ) ) {
+ if( stencil04Avail ) {
+ return GL.GL_STENCIL_INDEX4;
+ } else if( stencil08Avail ) {
+ return GL.GL_STENCIL_INDEX8;
+ } else {
+ return GL2GL3.GL_STENCIL_INDEX16;
+ }
+ } else if( 1 <= reqBits && ( stencil01Avail || stencil04Avail || stencil08Avail || stencil16Avail ) ) {
+ if( stencil01Avail ) {
+ return GL.GL_STENCIL_INDEX1;
+ } else if( stencil04Avail ) {
+ return GL.GL_STENCIL_INDEX4;
+ } else if( stencil08Avail ) {
+ return GL.GL_STENCIL_INDEX8;
+ } else {
+ return GL2GL3.GL_STENCIL_INDEX16;
+ }
+ } else {
+ throw new GLException("stencil buffer n/a");
+ }
+ }
+
+ /** Request default bit count for depth- or stencil buffer (depth 24 bits, stencil 8 bits), value {@value} */
+ public static final int DEFAULT_BITS = 0;
+
+ /**
+ * Request current context drawable's <i>requested</i>
+ * {@link GLCapabilitiesImmutable#getDepthBits() depth-} or {@link GLCapabilitiesImmutable#getStencilBits() stencil-}bits; value {@value} */
+ public static final int REQUESTED_BITS = -1;
+
+ /**
+ * Request current context drawable's <i>chosen</i>
+ * {@link GLCapabilitiesImmutable#getDepthBits() depth-} or {@link GLCapabilitiesImmutable#getStencilBits() stencil-}bits; value {@value} */
+ public static final int CHOSEN_BITS = -2;
+
+ /** Request maximum bit count for depth- or stencil buffer (depth 32 bits, stencil 16 bits), value {@value} */
+ public static final int MAXIMUM_BITS = -3;
+
+
/**
* Attaches one depth, stencil or packed-depth-stencil buffer to this FBO's instance,
* selecting the internalFormat automatically.
@@ -1505,7 +1677,8 @@ public class FBObject {
* Stencil and depth buffer can be attached only once.
* </p>
* <p>
- * In case the desired type or bit-number is not supported, the next available one is chosen.
+ * In case the bit-count is not supported,
+ * the next available one is chosen, i.e. next higher (preferred) or lower bit-count.
* </p>
* <p>
* Use {@link #getDepthAttachment()} and/or {@link #getStencilAttachment()} to retrieve details
@@ -1517,68 +1690,58 @@ public class FBObject {
*
* @param gl
* @param atype either {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#DEPTH_STENCIL}
- * @param reqBits desired bits for depth or -1 for default (24 bits)
+ * @param reqBits desired bits for depth or stencil,
+ * may use generic values {@link #DEFAULT_BITS}, {@link #REQUESTED_BITS}, {@link #CHOSEN_BITS} or {@link #MAXIMUM_BITS}.
* @throws GLException in case the renderbuffer couldn't be allocated or one is already attached.
* @throws IllegalArgumentException
* @see #getDepthAttachment()
* @see #getStencilAttachment()
*/
- public final void attachRenderbuffer(final GL gl, final Attachment.Type atype, int reqBits) throws GLException, IllegalArgumentException {
- if( 0 > reqBits ) {
- reqBits = 24;
+ public final void attachRenderbuffer(final GL gl, final Attachment.Type atype, final int reqBits) throws GLException, IllegalArgumentException {
+ final int reqDepth, reqStencil;
+ if( MAXIMUM_BITS > reqBits ) {
+ throw new IllegalArgumentException("reqBits out of range, shall be >= "+MAXIMUM_BITS);
+ } else if( MAXIMUM_BITS == reqBits ) {
+ reqDepth = 32;
+ reqStencil = 16;
+ } else if( CHOSEN_BITS == reqBits ) {
+ final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getChosenGLCapabilities();
+ reqDepth = caps.getDepthBits();
+ reqStencil = caps.getStencilBits();
+ } else if( REQUESTED_BITS == reqBits ) {
+ final GLCapabilitiesImmutable caps = gl.getContext().getGLDrawable().getRequestedGLCapabilities();
+ reqDepth = caps.getDepthBits();
+ reqStencil = caps.getStencilBits();
+ } else if( DEFAULT_BITS == reqBits ) {
+ reqDepth = 24;
+ reqStencil = 8;
+ } else {
+ reqDepth = reqBits;
+ reqStencil = reqBits;
}
final int internalFormat;
int internalStencilFormat = -1;
switch ( atype ) {
case DEPTH:
- if( 32 <= reqBits && depth32Avail ) {
- internalFormat = GL.GL_DEPTH_COMPONENT32;
- } else if( 24 <= reqBits && depth24Avail ) {
- internalFormat = GL.GL_DEPTH_COMPONENT24;
- } else {
- internalFormat = GL.GL_DEPTH_COMPONENT16;
- }
+ internalFormat = getDepthIFormat(reqDepth);
break;
case STENCIL:
- if( 16 <= reqBits && stencil16Avail ) {
- internalFormat = GL2GL3.GL_STENCIL_INDEX16;
- } else if( 8 <= reqBits && stencil08Avail ) {
- internalFormat = GL.GL_STENCIL_INDEX8;
- } else if( 4 <= reqBits && stencil04Avail ) {
- internalFormat = GL.GL_STENCIL_INDEX4;
- } else if( 1 <= reqBits && stencil01Avail ) {
- internalFormat = GL.GL_STENCIL_INDEX1;
- } else {
- throw new GLException("stencil buffer n/a");
- }
+ internalFormat = getStencilIFormat(reqStencil);
break;
case DEPTH_STENCIL:
if( packedDepthStencilAvail ) {
internalFormat = GL.GL_DEPTH24_STENCIL8;
} else {
- if( 24 <= reqBits && depth24Avail ) {
- internalFormat = GL.GL_DEPTH_COMPONENT24;
- } else {
- internalFormat = GL.GL_DEPTH_COMPONENT16;
- }
- if( stencil08Avail ) {
- internalStencilFormat = GL.GL_STENCIL_INDEX8;
- } else if( stencil04Avail ) {
- internalStencilFormat = GL.GL_STENCIL_INDEX4;
- } else if( stencil01Avail ) {
- internalStencilFormat = GL.GL_STENCIL_INDEX1;
- } else {
- throw new GLException("stencil buffer n/a");
- }
+ internalFormat = getDepthIFormat(reqDepth);
+ internalStencilFormat = getStencilIFormat(reqStencil);
}
break;
default:
throw new IllegalArgumentException("only depth/stencil types allowed, was "+atype+", "+this);
}
-
attachRenderbufferImpl(gl, atype, internalFormat);
if(0<=internalStencilFormat) {
@@ -1630,6 +1793,7 @@ public class FBObject {
}
private final void attachRenderbufferImpl2(final GL gl, final Attachment.Type atype, final int internalFormat) throws GLException {
+ // atype and current depth and stencil instance are already validated in 'attachRenderbufferImpl(..)'
if( Attachment.Type.DEPTH == atype ) {
if(null == depth) {
depth = createRenderAttachment(Type.DEPTH, internalFormat, samples, width, height);
@@ -1674,6 +1838,8 @@ public class FBObject {
gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, stencil.getName());
}
+ modified = true;
+
if(!ignoreStatus) {
updateStatus(gl);
if( !isStatusValid() ) {
@@ -1711,16 +1877,16 @@ public class FBObject {
}
private final Colorbuffer detachColorbufferImpl(final GL gl, final int attachmentPoint, final DetachAction detachAction, final int sampleCountChange) {
- Colorbuffer colbuf = colorbufferAttachments[attachmentPoint]; // shortcut, don't validate here
+ final Colorbuffer colbufOld = colorbufferAttachments[attachmentPoint]; // shortcut, don't validate here
- if(null == colbuf) {
+ if(null == colbufOld) {
return null;
}
- removeColorAttachment(attachmentPoint, colbuf);
+ removeColorAttachment(attachmentPoint, colbufOld);
- if( colbuf.isTextureAttachment() ) {
- final TextureAttachment texA = colbuf.getTextureAttachment();
+ if( colbufOld.isTextureAttachment() ) {
+ final TextureAttachment texA = colbufOld.getTextureAttachment();
if( 0 != texA.getName() ) {
gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER,
GL.GL_COLOR_ATTACHMENT0 + attachmentPoint,
@@ -1735,17 +1901,19 @@ public class FBObject {
}
}
if(DetachAction.RECREATE == detachAction) {
+ final Colorbuffer colbufNew;
if( 0 < sampleCountChange ) {
// switch to MSAA: TextureAttachment -> ColorAttachment
- colbuf = createColorAttachment(hasAlpha(texA.format));
+ colbufNew = createColorAttachment(hasAlpha(texA.format));
} else {
// keep MSAA settings
texA.setSize(width, height);
+ colbufNew = texA;
}
- attachColorbufferImpl(gl, attachmentPoint, colbuf);
+ attachColorbufferImpl(gl, attachmentPoint, colbufNew);
}
} else {
- final ColorAttachment colA = colbuf.getColorAttachment();
+ final ColorAttachment colA = colbufOld.getColorAttachment();
if( 0 != colA.getName() ) {
gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER,
GL.GL_COLOR_ATTACHMENT0+attachmentPoint,
@@ -1759,28 +1927,30 @@ public class FBObject {
}
}
if(DetachAction.RECREATE == detachAction) {
+ final Colorbuffer colbufNew;
if( 0 <= sampleCountChange || null == samplingColorSink ) {
// keep ColorAttachment,
// including 'switch to non-MSAA' if no samplingColorSink is available
// to determine whether a TextureAttachment or ColorAttachment is desired!
colA.setSize(width, height);
colA.setSamples(samples);
+ colbufNew = colA;
} else {
// switch to non MSAA
if( samplingColorSink.isTextureAttachment() ) {
final TextureAttachment samplingTextureSink = samplingColorSink.getTextureAttachment();
- colbuf = createColorTextureAttachment(samplingTextureSink.format, width, height,
- samplingTextureSink.dataFormat, samplingTextureSink.dataType,
- samplingTextureSink.magFilter, samplingTextureSink.minFilter,
- samplingTextureSink.wrapS, samplingTextureSink.wrapT);
+ colbufNew = createColorTextureAttachment(samplingTextureSink.format, width, height,
+ samplingTextureSink.dataFormat, samplingTextureSink.dataType,
+ samplingTextureSink.magFilter, samplingTextureSink.minFilter,
+ samplingTextureSink.wrapS, samplingTextureSink.wrapT);
} else {
- colbuf = createColorAttachment(samplingColorSink.getFormat(), 0, width, height);
+ colbufNew = createColorAttachment(samplingColorSink.getFormat(), 0, width, height);
}
}
- attachColorbuffer(gl, attachmentPoint, colbuf);
+ attachColorbuffer(gl, attachmentPoint, colbufNew);
}
}
- return colbuf;
+ return colbufOld;
}
private final void freeAllColorbufferImpl(final GL gl) {
@@ -1820,7 +1990,10 @@ public class FBObject {
*/
public final void detachRenderbuffer(final GL gl, final Attachment.Type atype, final boolean dispose) throws IllegalArgumentException {
bind(gl);
- detachRenderbufferImpl(gl, atype, dispose ? DetachAction.DISPOSE : DetachAction.NONE);
+ final RenderAttachment res = detachRenderbufferImpl(gl, atype, dispose ? DetachAction.DISPOSE : DetachAction.NONE);
+ if(null == res) {
+ throw new IllegalArgumentException("RenderAttachment type "+atype+", not attached, "+this);
+ }
if(DEBUG) {
System.err.println("FBObject.detachRenderbuffer.X: [attachmentType "+atype+", dispose "+dispose+"]: "+this);
}
@@ -1840,7 +2013,7 @@ public class FBObject {
return res;
}
- private final void detachRenderbufferImpl(final GL gl, Attachment.Type atype, final DetachAction detachAction) throws IllegalArgumentException {
+ private final RenderAttachment detachRenderbufferImpl(final GL gl, Attachment.Type atype, final DetachAction detachAction) throws IllegalArgumentException {
switch ( atype ) {
case DEPTH:
case STENCIL:
@@ -1850,23 +2023,25 @@ public class FBObject {
throw new IllegalArgumentException("only depth/stencil types allowed, was "+atype+", "+this);
}
if( null == depth && null == stencil ) {
- return ; // nop
+ return null; // nop
}
final boolean packed = isDepthStencilPackedFormat();
if( packed ) {
// Note: DEPTH_STENCIL shares buffer w/ depth and stencil
atype = Attachment.Type.DEPTH_STENCIL;
}
+ final RenderAttachment renderOld;
switch ( atype ) {
case DEPTH:
- if( null != depth ) {
- final int format = depth.format;
- if( 0 != depth.getName() ) {
+ renderOld = depth;
+ if( null != renderOld ) {
+ final int format = renderOld.format;
+ if( 0 != renderOld.getName() ) {
gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
switch(detachAction) {
case DISPOSE:
case RECREATE:
- depth.free(gl);
+ renderOld.free(gl);
break;
default:
}
@@ -1879,14 +2054,15 @@ public class FBObject {
}
break;
case STENCIL:
- if( null != stencil ) {
- final int format = stencil.format;
- if(0 != stencil.getName()) {
+ renderOld = stencil;
+ if( null != renderOld ) {
+ final int format = renderOld.format;
+ if(0 != renderOld.getName()) {
gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
switch(detachAction) {
case DISPOSE:
case RECREATE:
- stencil.free(gl);
+ renderOld.free(gl);
break;
default:
}
@@ -1899,9 +2075,10 @@ public class FBObject {
}
break;
case DEPTH_STENCIL:
- if( null != depth ) {
- final int format = depth.format;
- if(0 != depth.getName()) {
+ renderOld = depth;
+ if( null != renderOld ) {
+ final int format = renderOld.format;
+ if(0 != renderOld.getName()) {
gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
if(packed) {
gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
@@ -1909,7 +2086,7 @@ public class FBObject {
switch(detachAction) {
case DISPOSE:
case RECREATE:
- depth.free(gl);
+ renderOld.free(gl);
break;
default:
}
@@ -1942,8 +2119,11 @@ public class FBObject {
}
}
break;
- default: // handled
+ default:
+ throw new InternalError("XXX"); // handled by caller
}
+ modified = true;
+ return renderOld;
}
private final void freeAllRenderbufferImpl(final GL gl) throws IllegalArgumentException {
@@ -2113,41 +2293,50 @@ public class FBObject {
private final boolean sampleSinkSizeMismatch() {
return samplingSink.getWidth() != width || samplingSink.getHeight() != height ;
}
- private final boolean sampleColorsinkUninit() {
- return null != samplingColorSink && 0 == samplingColorSink.getName() ;
- }
private final boolean sampleSinkDepthStencilMismatch() {
- final boolean depthMismatch = null != depth &&
- ( null == samplingSink.depth ||
- depth.format != samplingSink.depth.format );
+ if ( ( null != depth && ( null == samplingSink.depth || depth.format != samplingSink.depth.format ) )
+ ||
+ ( null == depth && null != samplingSink.depth )
+ ) {
+ return true;
+ }
- final boolean stencilMismatch = null != stencil &&
- ( null == samplingSink.stencil ||
- stencil.format != samplingSink.stencil.format );
+ if ( ( null != stencil && ( null == samplingSink.stencil || stencil.format != samplingSink.stencil.format ) )
+ ||
+ ( null == stencil && null != samplingSink.stencil )
+ ) {
+ return true;
+ }
- return depthMismatch || stencilMismatch;
+ return false;
}
/**
- * For GLES3, sampling-sink {@link Colorbuffer} format <b>must be equal</b> w/ the sampling-source {@link Colorbuffer}.
+ * For GLES3, sampling-sink {@link Colorbuffer} <i>internal format</i> <b>must be equal</b> w/ the sampling-source {@link Colorbuffer}.
* Implementation aligns w/ {@link #createColorTextureAttachment(GLProfile, boolean, int, int, int, int, int, int)}
* and {@link #createColorAttachment(boolean)}.
*/
- private final boolean sampleSinkFormatMismatch(final GL gl) {
+ private final boolean sampleSinkExFormatMismatch(final GL gl) {
if( null != samplingColorSink && getColorbufferCount() > 0 && gl.isGL2ES3() ) {
final Attachment ca = (Attachment)getColorbuffer(0); // should be at attachment-point 0
- return ( null != ca && ca.format != samplingColorSink.getFormat() ) ||
- hasAlpha(samplingColorSink.getFormat()) != hasAttachmentUsingAlpha();
+ // We cannot comply w/ attachment's format other than attachment point 0!
+ // return ( null != ca && ca.format != samplingColorSink.getFormat() ) ||
+ // hasAlpha(samplingColorSink.getFormat()) != hasAttachmentUsingAlpha();
+ return null != ca && ca.format != samplingColorSink.getFormat();
}
return false;
}
/**
- * Manually reset the MSAA sampling sink, if used.
+ * Manually validates the MSAA sampling sink, if used.
* <p>
* If MSAA is being used and no sampling sink is attached via {@link #setSamplingSink(FBObject)}
* a new sampling sink is being created.
* </p>
* <p>
+ * If the sampling sink size or attributes differs from the source, its attachments are reset
+ * to match the source.
+ * </p>
+ * <p>
* Automatically called by {@link #reset(GL, int, int, int, boolean)}
* and {@link #syncSamplingSink(GL)}.
* </p>
@@ -2155,118 +2344,181 @@ public class FBObject {
* It is recommended to call this method after initializing the FBO and attaching renderbuffer etc for the 1st time
* if access to sampling sink resources is required.
* </p>
+ *
+ * <p>Leaves the FBO bound state untouched</p>
+ *
* @param gl the current GL context
* @throws GLException in case of an error, i.e. size too big, etc ..
*/
public final void resetSamplingSink(final GL gl) throws GLException {
if(DEBUG) {
System.err.println("FBObject.resetSamplingSink.0");
+ Thread.dumpStack();
}
+
if( 0 == samples ) {
+ final boolean modifiedInstance;
// MSAA off
- if(null != samplingSink && samplingSink.initialized) {
+ if( null != samplingSink ) {
// cleanup
- samplingSink.detachAll(gl);
+ if( samplingSink.initialized ) {
+ samplingSink.detachAll(gl);
+ }
+ samplingSink = null;
+ samplingColorSink = null;
+ modifiedInstance = true;
+ } else {
+ modifiedInstance = false;
}
+ this.modified = false;
if(DEBUG) {
- System.err.println("FBObject.resetSamplingSink.X1: zero samples \n\tTHIS "+this);
+ System.err.println("FBObject.resetSamplingSink.X1: zero samples, mod "+modifiedInstance+"\n\tTHIS "+this);
}
- return;
+ return; // modifiedInstance;
}
+ boolean modifiedInstance = false;
+
if( null == samplingSink ) {
samplingSink = new FBObject();
- }
-
- if( !samplingSink.initialized ) {
samplingSink.init(gl, width, height, 0);
+ samplingColorSink = null;
+ modifiedInstance = true;
+ } else if( !samplingSink.initialized ) {
+ throw new InternalError("InitState Mismatch: samplingSink set, but not initialized "+samplingSink);
+ } else if( null == samplingColorSink || 0 == samplingColorSink.getName() ) {
+ throw new InternalError("InitState Mismatch: samplingColorSink set, but not initialized "+samplingColorSink+", "+samplingSink);
}
if(DEBUG) {
- System.err.println("FBObject.resetSamplingSink.1: \n\tTHIS "+this+",\n\tSINK "+samplingSink);
+ System.err.println("FBObject.resetSamplingSink.1: mod "+modifiedInstance+"\n\tTHIS "+this+",\n\tSINK "+samplingSink);
}
- boolean sampleSinkFormatMismatch = sampleSinkFormatMismatch(gl);
+ boolean sampleSinkExFormatMismatch = sampleSinkExFormatMismatch(gl);
boolean sampleSinkSizeMismatch = sampleSinkSizeMismatch();
boolean sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch();
- boolean sampleColorsinkUninit = sampleColorsinkUninit();
- if(!sampleSinkFormatMismatch && !sampleSinkSizeMismatch && !sampleColorsinkUninit && !sampleSinkDepthStencilMismatch) {
- if(DEBUG) {
- System.err.println("FBObject.resetSamplingSink.X2: Matching: format "+!sampleSinkFormatMismatch+", size "+!sampleSinkSizeMismatch +", csUninit "+!sampleColorsinkUninit +", depthStencil "+!sampleSinkDepthStencilMismatch);
+ if( modifiedInstance ) {
+ // samplingColorSink == null
+ // must match size, format and colorbuffer do not exist yet
+ if( sampleSinkExFormatMismatch || sampleSinkSizeMismatch ) {
+ throw new InternalError("InitState Mismatch: Matching exFormat "+!sampleSinkExFormatMismatch+
+ ", size "+!sampleSinkSizeMismatch +", "+this);
+ }
+ } else {
+ // samplingColorSink != null
+ if(!sampleSinkExFormatMismatch && !sampleSinkSizeMismatch && !sampleSinkDepthStencilMismatch) {
+ if(DEBUG) {
+ System.err.println("FBObject.resetSamplingSink.X2: Matching: exFormat "+!sampleSinkExFormatMismatch+
+ ", size "+!sampleSinkSizeMismatch +", depthStencil "+!sampleSinkDepthStencilMismatch+
+ ", mod "+modifiedInstance);
+ }
+ // all properties match ..
+ samplingSink.modified = false;
+ this.modified = false;
+ return; // modifiedInstance;
}
- // all properties match ..
- return;
}
- unbind(gl);
+ final boolean wasBound;
+ if( isBound() ) {
+ markUnbound(); // automatic GL unbind by sampleSink binding
+ wasBound = true;
+ } else {
+ wasBound = false;
+ }
if(DEBUG) {
- System.err.println("FBObject.resetSamplingSink.2: Mismatch. Matching: format "+!sampleSinkFormatMismatch+", size "+!sampleSinkSizeMismatch +", csUninit "+!sampleColorsinkUninit +", depthStencil "+!sampleSinkDepthStencilMismatch);
- Thread.dumpStack();
+ System.err.println("FBObject.resetSamplingSink.2: wasBound "+wasBound+", matching: exFormat "+!sampleSinkExFormatMismatch+
+ ", size "+!sampleSinkSizeMismatch +", depthStencil "+!sampleSinkDepthStencilMismatch);
}
- if( sampleSinkDepthStencilMismatch ) {
+ modifiedInstance = true;
+
+ if( sampleSinkDepthStencilMismatch ) { // includes 1st init
samplingSink.detachAllRenderbuffer(gl);
}
- final Colorbuffer preSamplingColorSink = samplingColorSink;
- final boolean samplingColorSinkShallBeTA = null == preSamplingColorSink || preSamplingColorSink.isTextureAttachment();
+ final boolean samplingColorSinkShallBeTA = null == samplingColorSink || samplingColorSink.isTextureAttachment();
- if( sampleSinkFormatMismatch ) {
+ if( sampleSinkExFormatMismatch ) {
samplingSink.detachAllColorbuffer(gl);
samplingColorSink = null;
} else if( sampleSinkSizeMismatch ) {
- samplingSink.reset(gl, width, height);
- }
-
- if(null == samplingColorSink) {
- final boolean hasAlpha = hasAttachmentUsingAlpha();
- if( samplingColorSinkShallBeTA ) {
- samplingColorSink = samplingSink.attachTexture2D(gl, 0, hasAlpha);
+ samplingSink.resetSizeImpl(gl, width, height);
+ samplingColorSink = samplingSink.getColorbuffer(0);
+ }
+
+ if( null == samplingColorSink ) { // sampleSinkFormatMismatch || 1st init
+ final Colorbuffer cb0 = getColorbuffer(0); // align with colorbuffer at attachment-point 0
+ if( null != cb0 ) {
+ // match pre-existing format
+ if( samplingColorSinkShallBeTA ) {
+ samplingColorSink = createColorTextureAttachment(gl, cb0.getFormat(), width, height,
+ GL.GL_NEAREST, GL.GL_NEAREST,
+ GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
+ } else {
+ samplingColorSink = createColorAttachment(cb0.getFormat(), 0, width, height);
+ }
+ samplingSink.attachColorbuffer(gl, 0, samplingColorSink);
} else {
- samplingColorSink = samplingSink.attachColorbuffer(gl, 0, hasAlpha);
+ // match default format
+ final boolean hasAlpha = hasAttachmentUsingAlpha();
+ if( samplingColorSinkShallBeTA ) {
+ samplingColorSink = samplingSink.attachTexture2D(gl, 0, hasAlpha);
+ } else {
+ samplingColorSink = samplingSink.attachColorbuffer(gl, 0, hasAlpha);
+ }
}
- } else if( 0 == samplingColorSink.getName() ) {
- // final boolean dispose = true;
- // detachColorbufferImpl(gl, 0, dispose ? DetachAction.DISPOSE : DetachAction.NONE);
- ((Attachment)samplingColorSink).setSize(width, height);
- samplingSink.attachColorbuffer(gl, 0, samplingColorSink);
}
- if( sampleSinkDepthStencilMismatch ) {
+ if( sampleSinkDepthStencilMismatch ) { // includes 1st init
samplingSink.attachRenderbuffer(gl, depth.format);
if( null != stencil && !isDepthStencilPackedFormat() ) {
samplingSink.attachRenderbuffer(gl, stencil.format);
}
}
- sampleSinkFormatMismatch = sampleSinkFormatMismatch(gl);
+ sampleSinkExFormatMismatch = sampleSinkExFormatMismatch(gl);
sampleSinkSizeMismatch = sampleSinkSizeMismatch();
sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch();
- sampleColorsinkUninit = sampleColorsinkUninit();
- if(sampleSinkFormatMismatch || sampleSinkSizeMismatch || sampleColorsinkUninit || sampleSinkDepthStencilMismatch) {
+ if(sampleSinkExFormatMismatch || sampleSinkSizeMismatch || sampleSinkDepthStencilMismatch) {
throw new InternalError("Samples sink mismatch after reset: \n\tTHIS "+this+",\n\t SINK "+samplingSink+
- "\n\t Mismatch. Matching: format "+!sampleSinkFormatMismatch+", size "+!sampleSinkSizeMismatch +", csUninit "+!sampleColorsinkUninit +", depthStencil "+!sampleSinkDepthStencilMismatch);
+ "\n\t Mismatch. Matching: exFormat "+!sampleSinkExFormatMismatch+
+ ", size "+!sampleSinkSizeMismatch +", depthStencil "+!sampleSinkDepthStencilMismatch);
+ }
+
+ samplingSink.modified = false;
+ samplingSink.unbind(gl);
+ this.modified = false;
+
+ if(wasBound) {
+ bind(gl);
}
if(DEBUG) {
- System.err.println("FBObject.resetSamplingSink.XX: END\n\tTHIS "+this+",\n\tSINK "+samplingSink+
- "\n\t Matching: format "+!sampleSinkFormatMismatch+", size "+!sampleSinkSizeMismatch +", csUninit "+!sampleColorsinkUninit +", depthStencil "+!sampleSinkDepthStencilMismatch);
+ System.err.println("FBObject.resetSamplingSink.XX: END mod "+modifiedInstance+"\n\tTHIS "+this+",\n\tSINK "+samplingSink+
+ "\n\t Matching: exFormat "+!sampleSinkExFormatMismatch+
+ ", size "+!sampleSinkSizeMismatch +", depthStencil "+!sampleSinkDepthStencilMismatch);
}
+ return; // modifiedInstance;
}
/**
* Setting this FBO sampling sink.
- * @param newSamplingSink the new FBO sampling sink to use, or null to remove current sampling sink
+ * @param newSamplingSink the new and initialized FBO sampling sink to use, or null to remove current sampling sink
* @return the previous sampling sink or null if none was attached
* @throws GLException if this FBO doesn't use MSAA or the given sink uses MSAA itself
+ * @throws IllegalStateException if the {@code newSamplingSink} is not null and not initialized
*/
- public FBObject setSamplingSink(final FBObject newSamplingSink) throws GLException {
+ public FBObject setSamplingSink(final FBObject newSamplingSink) throws /* IllegalStateException, */ GLException {
final FBObject prev = samplingSink;
if( null == newSamplingSink) {
samplingSink = null;
samplingColorSink = null;
} else if( samples > 0 ) {
+ if( !newSamplingSink.isInitialized() ) {
+ throw new IllegalStateException("SamplingSink not initialized: "+newSamplingSink);
+ }
if( newSamplingSink.getNumSamples() > 0 ) {
throw new GLException("SamplingSink FBO cannot use MSAA itself: "+newSamplingSink);
}
@@ -2275,6 +2527,7 @@ public class FBObject {
} else {
throw new GLException("Setting SamplingSink for non MSAA FBO not allowed: "+this);
}
+ modified = true;
samplingSinkDirty = true;
return prev;
}
@@ -2282,9 +2535,9 @@ public class FBObject {
/**
* Bind this FBO, i.e. bind write framebuffer to {@link #getWriteFramebuffer()}.
*
- * <p>If multisampling is used, it sets the read framebuffer to the sampling sink {@link #getWriteFramebuffer()},
- * if full FBO is supported.</p>
- *
+ * <p>
+ * If multisampling is used, it sets the read framebuffer to the sampling sink {@link #getWriteFramebuffer()}.
+ * </p>
* <p>
* In case you have attached more than one color buffer,
* you may want to setup {@link GL2ES3#glDrawBuffers(int, int[], int)}.
@@ -2295,15 +2548,12 @@ public class FBObject {
public final void bind(final GL gl) throws GLException {
if(!bound || fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER)) {
checkInitialized();
- if(samples > 0 && fullFBOSupport) {
- // draw to multisampling - read from samplesSink
- gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, getWriteFramebuffer());
- gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, getReadFramebuffer());
+ if( fullFBOSupport ) {
+ gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, getWriteFramebuffer()); // this fb, msaa or normal
+ gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, getReadFramebuffer()); // msaa: sampling sink, normal: this fb
} else {
- // one for all
- gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer());
+ gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer()); // normal: read/write
}
-
bound = true;
samplingSinkDirty = true;
}
@@ -2351,7 +2601,7 @@ public class FBObject {
* @param gl the current GL context
*/
public final boolean isBound(final GL gl) {
- bound = bound && fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER) ;
+ bound = bound && fbName == gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER) ;
return bound;
}
@@ -2384,15 +2634,19 @@ public class FBObject {
*/
public final void syncSamplingSink(final GL gl) {
markUnbound();
- if(samples>0 && samplingSinkDirty) {
+ if(samples>0 && samplingSinkDirty) { // implies fullFBOSupport
samplingSinkDirty = false;
- resetSamplingSink(gl);
+ if( isModified() ) {
+ resetSamplingSink(gl);
+ }
checkPreGLError(gl);
- gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, fbName);
- gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, samplingSink.getWriteFramebuffer());
+ gl.glBindFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER, fbName); // read from this MSAA fb
+ gl.glBindFramebuffer(GL2ES3.GL_DRAW_FRAMEBUFFER, samplingSink.getWriteFramebuffer()); // write to sampling sink
((GL2ES3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, casting to GL2ES3 is OK
GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST);
checkNoError(null, gl.glGetError(), "FBObject syncSampleSink"); // throws GLException if error
+ } else {
+ modified = false;
}
if(fullFBOSupport) {
// default read/draw buffers, may utilize GLContext/GLDrawable override of
@@ -2507,7 +2761,9 @@ public class FBObject {
/** Returns the framebuffer name to render to. */
public final int getWriteFramebuffer() { return fbName; }
/** Returns the framebuffer name to read from. Depending on multisampling, this may be a different framebuffer. */
- public final int getReadFramebuffer() { return ( samples > 0 ) ? samplingSink.getReadFramebuffer() : fbName; }
+ public final int getReadFramebuffer() {
+ return 0 < samples ? ( null != samplingSink ? samplingSink.getReadFramebuffer() : 0 ) : fbName;
+ }
public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; }
/** Return the number of attached {@link Colorbuffer}s */
public final int getColorbufferCount() { return colorbufferCount; }
@@ -2531,13 +2787,24 @@ public class FBObject {
*/
public final boolean isSamplingBufferDirty() { return samplingSinkDirty; }
+ /**
+ * Returns <code>true</code> if size, sample-count or any attachment of this instance
+ * or its {@link #getSamplingSink() sampling-sink} has been modified since last {@link #syncSamplingSink(GL) sync},
+ * {@link #use(GL, TextureAttachment) use}, {@link #reset(GL, int, int, int) reset}
+ * or {@link #resetSamplingSink(GL) resetSamplingSink}.
+ * <p>
+ * Otherwise method returns <code>false</code>.
+ * </p>
+ */
+ public final boolean isModified() { return modified || ( null != samplingSink && samplingSink.modified ); }
+
int objectHashCode() { return super.hashCode(); }
@Override
public final String toString() {
final String caps = null != colorbufferAttachments ? Arrays.asList(colorbufferAttachments).toString() : null ;
return "FBO[name r/w "+fbName+"/"+getReadFramebuffer()+", init "+initialized+", bound "+bound+", size "+width+"x"+height+
- ", samples "+samples+"/"+maxSamples+", depth "+depth+", stencil "+stencil+
+ ", samples "+samples+"/"+maxSamples+", modified "+modified+"/"+isModified()+", depth "+depth+", stencil "+stencil+
", colorbuffer attachments: "+colorbufferCount+"/"+maxColorAttachments+", with "+textureAttachmentCount+" textures"+
": "+caps+", msaa["+samplingColorSink+", hasSink "+(null != samplingSink)+
", dirty "+samplingSinkDirty+"], state "+getStatusString()+", obj "+toHexString(objectHashCode())+"]";
diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java
index 4ef717a..b9f1fb1 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java
@@ -38,6 +38,7 @@ import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
+import javax.media.opengl.GLSharedContextSetter;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
@@ -62,6 +63,12 @@ import jogamp.opengl.GLDrawableImpl;
* <p>
* See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}.
* </p>
+ * <p>
+ * <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a>
+ * To share a {@link GLContext} see the following note in the documentation overview:
+ * <a href="../../../overview-summary.html#SHARING">context sharing</a>
+ * as well as {@link GLSharedContextSetter}.
+ * </p>
*/
public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable {
/**
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 83fceeb..a7749e1 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -101,7 +101,7 @@ public class GLRendererQuirks {
public static final int GLNonCompliant = 6;
/**
- * The OpenGL Context needs a <code>glFlush()</code> before releasing it, otherwise driver may freeze:
+ * The OpenGL context needs a <code>glFlush()</code> before releasing it, otherwise driver may freeze:
* <ul>
* <li>OSX < 10.7.3 - NVidia Driver. Bug 533 and Bug 548 @ https://jogamp.org/bugzilla/.</li>
* </ul>
@@ -139,7 +139,7 @@ public class GLRendererQuirks {
public static final int DontCloseX11Display = 8;
/**
- * Need current GL Context when calling new ARB <i>pixel format query</i> functions,
+ * Need current GL context when calling new ARB <i>pixel format query</i> functions,
* otherwise driver crashes the VM.
* <p>
* Drivers known exposing such bug:
@@ -155,7 +155,7 @@ public class GLRendererQuirks {
public static final int NeedCurrCtx4ARBPixFmtQueries = 9;
/**
- * Need current GL Context when calling new ARB <i>CreateContext</i> function,
+ * Need current GL context when calling new ARB <i>CreateContext</i> function,
* otherwise driver crashes the VM.
* <p>
* Drivers known exposing such bug:
@@ -191,7 +191,12 @@ public class GLRendererQuirks {
* <li>GL_RENDERER: <i>Gallium 0.4 on SVGA3D; build: RELEASE;</i> </li>
* </ul></li>
* </ul>
+ * <p>
+ * Also enabled via {@link #BuggyColorRenderbuffer}.
+ * </p>
+ * <p>
* Quirk can also be enabled via property: <code>jogl.fbo.force.min</code>.
+ * </p>
*/
public static final int NoFullFBOSupport = 11;
@@ -291,9 +296,9 @@ public class GLRendererQuirks {
public static final int SingletonEGLDisplayOnly = 16;
/**
- * With certain drivers no reliable MSAA / FSAA
- * {@link GLCapabilitiesImmutable#getSampleBuffers() multi}
- * {@link GLCapabilitiesImmutable#getNumSamples() sampling} is available, read <i>a crash</i> may occur.
+ * No reliable MSAA / FSAA {@link GLCapabilitiesImmutable#getSampleBuffers() multi}
+ * {@link GLCapabilitiesImmutable#getNumSamples() sampling} available,
+ * i.e. driver <i>may crash</i>.
* <p>
* Appears on:
* <ul>
@@ -312,16 +317,98 @@ public class GLRendererQuirks {
*/
public static final int NoMultiSamplingBuffers = 17;
- /** Number of quirks known. */
+ /**
+ * Buggy FBO color renderbuffer target,
+ * i.e. driver <i>may crash</i>.
+ * <p>
+ * Appears on:
+ * <ul>
+ * <li>GL_VENDOR Brian Paul</li>
+ * <li>GL_RENDERER Mesa X11</li>
+ * <li>GL_VERSION 2.1 Mesa 7.2</li>
+ * </ul>
+ * TODO: We have to determine the exact version range, i.e. not adding the quirk with fixed driver version!
+ * </p>
+ * <p>
+ * Note: Also enables {@link #NoFullFBOSupport}.
+ * </p>
+ * <p>
+ * Note: GLFBODrawable always uses texture attachments if set.
+ * </p>
+ * <p>
+ * Quirk can also be enabled via property: <code>jogl.fbo.force.nocolorrenderbuffer</code>.
+ * </p>
+ */
+ public static final int BuggyColorRenderbuffer = 18;
+
+ /**
+ * No pbuffer supporting accumulation buffers available,
+ * even if driver claims otherwise.
+ * <p>
+ * Some drivers wrongly claim to support pbuffers
+ * with accumulation buffers. However, the creation of such pbuffer fails:
+ * <pre>
+ * javax.media.opengl.GLException: pbuffer creation error: Couldn't find a suitable pixel format
+ * </pre>
+ * </p>
+ * <p>
+ * Appears on:
+ * <ul>
+ * <li>GL_VENDOR Intel</li>
+ * <li>GL_RENDERER Intel Bear Lake B</li>
+ * <li>GL_VERSION 1.4.0 - Build 8.14.10.1930</li>
+ * <li>Platform Windows</li>
+ * </ul>
+ * </p>
+ */
+ public static final int NoPBufferWithAccum = 19;
+
+ /**
+ * Need GL objects (VBO, ..) to be synchronized when utilized
+ * concurrently from multiple threads via a shared GL context,
+ * otherwise driver crashes the VM.
+ * <p>
+ * Usually synchronization should not be required, if the shared GL objects
+ * are created and immutable before concurrent usage.<br>
+ * However, using drivers exposing this issue always require the user to
+ * synchronize access of shared GL objects.
+ * </p>
+ * <p>
+ * Synchronization can be avoided if accessing the shared GL objects
+ * exclusively via a queue or {@link com.jogamp.common.util.Ringbuffer Ringbuffer}, see GLMediaPlayerImpl as an example.
+ * </p>
+ * <p>
+ * Appears on:
+ * <ul>
+ * <li>Platform OSX
+ * <ul>
+ * <li>detected on OSX 10.9.5 first</li>
+ * <li>any driver</li>
+ * <li>enabled for all OSX versions</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </p>
+ * <p>
+ * See Bug 1088 - https://jogamp.org/bugzilla/show_bug.cgi?id=1088
+ * </p>
+ */
+ public static final int NeedSharedObjectSync = 20;
+
+ /** @deprecated Use {@link #getCount()}, this value is no more valid! */
public static final int COUNT = 18;
+ /** Return the number of known quirks. */
+ public static final int getCount() { return 21; }
+
private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
"NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
"GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display",
"NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext",
"NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request",
"GLSharedContextBuggy", "GLES3ViaEGLES2Config", "SingletonEGLDisplayOnly",
- "NoMultiSamplingBuffers"
+ "NoMultiSamplingBuffers", "BuggyColorRenderbuffer", "NoPBufferWithAccum",
+ "NeedSharedObjectSync"
};
private static final IdentityHashMap<String, GLRendererQuirks> stickyDeviceQuirks = new IdentityHashMap<String, GLRendererQuirks>();
@@ -358,6 +445,17 @@ public class GLRendererQuirks {
}
/**
+ * {@link #addQuirk(int) Adding given quirk} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}.
+ * <p>
+ * Not thread safe.
+ * </p>
+ * @see #getStickyDeviceQuirks(AbstractGraphicsDevice)
+ */
+ public static void addStickyDeviceQuirk(final AbstractGraphicsDevice device, final int quirk) throws IllegalArgumentException {
+ final GLRendererQuirks sq = getStickyDeviceQuirks(device);
+ sq.addQuirk(quirk);
+ }
+ /**
* {@link #addQuirks(int[], int, int) Adding given quirks} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}.
* <p>
* Not thread safe.
@@ -419,6 +517,15 @@ public class GLRendererQuirks {
}
/**
+ * @param quirk valid quirk to be added
+ * @throws IllegalArgumentException if the quirk is out of range
+ */
+ public final void addQuirk(final int quirk) throws IllegalArgumentException {
+ validateQuirk(quirk);
+ _bitmask |= 1 << quirk;
+ }
+
+ /**
* @param quirks an array of valid quirks to be added
* @param offset offset in quirks array to start reading
* @param len number of quirks to read from offset within quirks array
@@ -460,7 +567,7 @@ public class GLRendererQuirks {
}
sb.append("[");
boolean first=true;
- for(int i=0; i<COUNT; i++) {
+ for(int i=0; i<getCount(); i++) {
final int testmask = 1 << i;
if( 0 != ( _bitmask & testmask ) ) {
if(!first) { sb.append(", "); }
@@ -482,8 +589,8 @@ public class GLRendererQuirks {
* @throws IllegalArgumentException if quirk is out of range
*/
public static void validateQuirk(final int quirk) throws IllegalArgumentException {
- if( !( 0 <= quirk && quirk < COUNT ) ) {
- throw new IllegalArgumentException("Quirks must be in range [0.."+COUNT+"[, but quirk: "+quirk);
+ if( !( 0 <= quirk && quirk < getCount() ) ) {
+ throw new IllegalArgumentException("Quirks must be in range [0.."+getCount()+"[, but quirk: "+quirk);
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
index 3a35686..1a8924c 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java
@@ -42,15 +42,15 @@ import com.jogamp.opengl.math.geom.AABBox;
* Implementation assumes linear matrix layout in column-major order
* matching OpenGL's implementation, illustration:
* <pre>
- Row-Major Column-Major (OpenGL):
-
- | 0 1 2 3 | | 0 4 8 12 |
- | | | |
- | 4 5 6 7 | | 1 5 9 13 |
- M = | | M = | |
- | 8 9 10 11 | | 2 6 10 14 |
- | | | |
- | 12 13 14 15 | | 3 7 11 15 |
+ Row-Major Column-Major (OpenGL):
+
+ | 0 1 2 3 | | 0 4 8 12 |
+ | | | |
+ | 4 5 6 7 | | 1 5 9 13 |
+ M = | | M = | |
+ | 8 9 10 11 | | 2 6 10 14 |
+ | | | |
+ | 12 13 14 15 | | 3 7 11 15 |
C R C R
m[0*4+3] = tx; m[0+4*3] = tx;
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Ray.java b/src/jogl/classes/com/jogamp/opengl/math/Ray.java
index 0daca25..4d651d1 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Ray.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Ray.java
@@ -41,7 +41,9 @@ import com.jogamp.opengl.math.geom.AABBox;
* </p>
* <p>
* A {@link Ray} maybe used for <i>picking</i>
- * using a {@link AABBox#getRayIntersection(Ray, float[]) bounding box}.
+ * using a {@link AABBox bounding box} via
+ * {@link AABBox#intersectsRay(Ray) fast probe} or
+ * {@link AABBox#getRayIntersection(float[], Ray, float, boolean, float[], float[], float[]) returning the intersection}.
* </p>
*/
public class Ray {
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
index 4caff95..29cc2b5 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java
@@ -440,12 +440,16 @@ public class AABBox {
* <li>Optimized code by Pierre Terdiman, 2000 (~20-30% faster on my Celeron 500)</li>
* <li>Epsilon value added by Klaus Hartmann.</li>
* </ul>
+ * </p>
+ * <p>
* Method is based on the requirements:
* <ul>
* <li>the integer representation of 0.0f is 0x00000000</li>
* <li>the sign bit of the float is the most significant one</li>
* </ul>
- * Report bugs: p.terdiman at codercorner.com
+ * </p>
+ * <p>
+ * Report bugs: p.terdiman at codercorner.com (original author)
* </p>
* <pre>
* [1] http://www.codercorner.com/RayAABB.cpp
diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
index f6d3c0d..b73bad6 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java
@@ -33,9 +33,17 @@ import com.jogamp.common.os.Platform;
/**
* Providing frustum {@link #getPlanes() planes} derived by different inputs
- * ({@link #updateByPMV(float[], int) P*MV}, ..)
- * used to {@link #classifySphere(float[], float) classify objects} and to test
- * whether they are {@link #isOutside(AABBox) outside}.
+ * ({@link #updateByPMV(float[], int) P*MV}, ..) used to classify objects
+ * <ul>
+ * <li> {@link #classifyPoint(float[]) point} </li>
+ * <li> {@link #classifySphere(float[], float) sphere} </li>
+ * </ul>
+ * and to test whether they are outside
+ * <ul>
+ * <li> {@link #isPointOutside(float[]) point} </li>
+ * <li> {@link #isSphereOutside(float[], float) sphere} </li>
+ * <li> {@link #isAABBoxOutside(AABBox) bounding-box} </li>
+ * </ul>
*
* <p>
* Extracting the world-frustum planes from the P*Mv:
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index e33ceee..28f572d 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -85,6 +85,12 @@ import com.jogamp.opengl.JoglVersion;
* <p>
* Implementation allows use of custom {@link GLCapabilities}.
* </p>
+ * <p>
+ * <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a>
+ * To share a {@link GLContext} see the following note in the documentation overview:
+ * <a href="../../../../overview-summary.html#SHARING">context sharing</a>
+ * as well as {@link GLSharedContextSetter}.
+ * </p>
*/
public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextSetter {
private static final boolean DEBUG = Debug.debug("GLCanvas");
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index d9a9571..e199dc0 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -58,13 +58,22 @@ import javax.media.opengl.GLException;
* </p>
*/
public class Animator extends AnimatorBase {
+ /** @deprecated no more used */
protected ThreadGroup threadGroup;
- private Runnable runnable;
- private boolean runAsFastAsPossible;
+ /** @deprecated no more used */
protected boolean isAnimating;
+ /** @deprecated no more used */
protected boolean pauseIssued;
+ /** @deprecated no more used */
protected volatile boolean stopIssued;
+ private ThreadGroup threadGroup2;
+ private Runnable runnable;
+ private boolean runAsFastAsPossible;
+ boolean isAnimating2;
+ volatile boolean pauseIssued2;
+ volatile boolean stopIssued2;
+
/**
* Creates a new, empty Animator.
*/
@@ -82,7 +91,7 @@ public class Animator extends AnimatorBase {
super();
setThreadGroup(tg);
if(DEBUG) {
- System.err.println("Animator created, ThreadGroup: "+threadGroup);
+ System.err.println("Animator created, ThreadGroup: "+threadGroup2);
}
}
@@ -105,7 +114,7 @@ public class Animator extends AnimatorBase {
setThreadGroup(tg);
add(drawable);
if(DEBUG) {
- System.err.println("Animator created, ThreadGroup: "+threadGroup+" and "+drawable);
+ System.err.println("Animator created, ThreadGroup: "+threadGroup2+" and "+drawable);
}
}
@@ -132,7 +141,8 @@ public class Animator extends AnimatorBase {
@Override
public void run() {
- UncaughtAnimatorException displayCaught = null;
+ ThreadDeath caughtThreadDeath = null;
+ UncaughtAnimatorException caughtException = null;
try {
synchronized (Animator.this) {
@@ -141,19 +151,19 @@ public class Animator extends AnimatorBase {
}
fpsCounter.resetFPSCounter();
animThread = Thread.currentThread();
- isAnimating = false;
+ isAnimating2 = false;
// 'waitForStartedCondition' wake-up is handled below!
}
- while (!stopIssued) {
+ while (!stopIssued2) {
synchronized (Animator.this) {
// Pause; Also don't consume CPU unless there is work to be done and not paused
boolean ectCleared = false;
- while (!stopIssued && (pauseIssued || drawablesEmpty)) {
+ while ( !stopIssued2 && ( pauseIssued2 || drawablesEmpty ) ) {
if( drawablesEmpty ) {
- pauseIssued = true;
+ pauseIssued2 = true;
}
- final boolean wasPaused = pauseIssued;
+ final boolean wasPaused = pauseIssued2;
if (DEBUG) {
System.err.println("Animator pause on " + animThread.getName() + ": " + toString());
}
@@ -163,13 +173,12 @@ public class Animator extends AnimatorBase {
try {
display(); // propagate exclusive context -> off!
} catch (final UncaughtAnimatorException dre) {
- displayCaught = dre;
- stopIssued = true;
- isAnimating = false;
+ caughtException = dre;
+ stopIssued2 = true;
break; // end pause loop
}
}
- isAnimating = false;
+ isAnimating2 = false;
Animator.this.notifyAll();
try {
Animator.this.wait();
@@ -183,78 +192,95 @@ public class Animator extends AnimatorBase {
}
}
}
- if (!stopIssued && !isAnimating) {
+ if (!stopIssued2 && !isAnimating2) {
// Wakes up 'waitForStartedCondition' sync
// - and -
// Resume from pause or drawablesEmpty,
// implies !pauseIssued and !drawablesEmpty
- isAnimating = true;
+ isAnimating2 = true;
setDrawablesExclCtxState(exclusiveContext); // may re-enable exclusive context
Animator.this.notifyAll();
}
} // sync Animator.this
- if (!stopIssued) {
+ if ( !pauseIssued2 && !stopIssued2 ) {
try {
display();
} catch (final UncaughtAnimatorException dre) {
- displayCaught = dre;
- stopIssued = true;
- isAnimating = false;
+ caughtException = dre;
+ stopIssued2 = true;
break; // end animation loop
}
- }
- if (!stopIssued && !runAsFastAsPossible) {
- // Avoid swamping the CPU
- Thread.yield();
+ if ( !runAsFastAsPossible ) {
+ // Avoid swamping the CPU
+ Thread.yield();
+ }
}
}
- } catch( final ThreadDeath td) {
+ } catch(final ThreadDeath td) {
if(DEBUG) {
System.err.println("Animator caught: "+td.getClass().getName()+": "+td.getMessage());
td.printStackTrace();
}
- } finally {
- if( exclusiveContext && !drawablesEmpty ) {
- setDrawablesExclCtxState(false);
- try {
- display(); // propagate exclusive context -> off!
- } catch (final UncaughtAnimatorException dre) {
- if( null == displayCaught ) {
- displayCaught = dre;
- } else {
- dre.printStackTrace();
- }
+ caughtThreadDeath = td;
+ }
+ if( exclusiveContext && !drawablesEmpty ) {
+ setDrawablesExclCtxState(false);
+ try {
+ display(); // propagate exclusive context -> off!
+ } catch (final UncaughtAnimatorException dre) {
+ if( null == caughtException ) {
+ caughtException = dre;
+ } else {
+ System.err.println("Animator.setExclusiveContextThread: caught: "+dre.getMessage());
+ dre.printStackTrace();
}
}
- synchronized (Animator.this) {
- if(DEBUG) {
- System.err.println("Animator stop on " + animThread.getName() + ": " + toString());
- if( null != displayCaught ) {
- System.err.println("Animator caught: "+displayCaught.getMessage());
- displayCaught.printStackTrace();
- }
+ }
+ boolean flushGLRunnables = false;
+ boolean throwCaughtException = false;
+ synchronized (Animator.this) {
+ if(DEBUG) {
+ System.err.println("Animator stop on " + animThread.getName() + ": " + toString());
+ if( null != caughtException ) {
+ System.err.println("Animator caught: "+caughtException.getMessage());
+ caughtException.printStackTrace();
}
- stopIssued = false;
- pauseIssued = false;
- isAnimating = false;
- if( null != displayCaught ) {
- handleUncaughtException(displayCaught);
+ }
+ stopIssued2 = false;
+ pauseIssued2 = false;
+ isAnimating2 = false;
+ if( null != caughtException ) {
+ flushGLRunnables = true;
+ if( null != uncaughtExceptionHandler ) {
+ handleUncaughtException(caughtException);
+ throwCaughtException = false;
+ } else {
+ throwCaughtException = true;
}
- animThread = null;
- Animator.this.notifyAll();
}
+ animThread = null;
+ Animator.this.notifyAll();
+ }
+ if( flushGLRunnables ) {
+ flushGLRunnables();
+ }
+ if( throwCaughtException ) {
+ throw caughtException;
+ }
+ if( null != caughtThreadDeath ) {
+ throw caughtThreadDeath;
}
}
}
@Override
public final synchronized boolean isAnimating() {
- return animThread != null && isAnimating ;
+ return animThread != null && isAnimating2 ;
}
@Override
public final synchronized boolean isPaused() {
- return animThread != null && pauseIssued ;
+ return animThread != null && pauseIssued2 ;
}
/**
@@ -267,7 +293,7 @@ public class Animator extends AnimatorBase {
if ( isStarted() ) {
throw new GLException("Animator already started.");
}
- threadGroup = tg;
+ threadGroup2 = tg;
}
@Override
@@ -281,10 +307,10 @@ public class Animator extends AnimatorBase {
fpsCounter.resetFPSCounter();
final String threadName = getThreadName()+"-"+baseName;
Thread thread;
- if(null==threadGroup) {
+ if(null==threadGroup2) {
thread = new Thread(runnable, threadName);
} else {
- thread = new Thread(threadGroup, runnable, threadName);
+ thread = new Thread(threadGroup2, runnable, threadName);
}
thread.setDaemon(false); // force to be non daemon, regardless of parent thread
if(DEBUG) {
@@ -297,7 +323,7 @@ public class Animator extends AnimatorBase {
private final Condition waitForStartedCondition = new Condition() {
@Override
public boolean eval() {
- return !isStarted() || (!drawablesEmpty && !isAnimating) ;
+ return !isStarted() || (!drawablesEmpty && !isAnimating2) ;
} };
@Override
@@ -305,7 +331,7 @@ public class Animator extends AnimatorBase {
if ( !isStarted() ) {
return false;
}
- stopIssued = true;
+ stopIssued2 = true;
return finishLifecycleAction(waitForStoppedCondition, 0);
}
private final Condition waitForStoppedCondition = new Condition() {
@@ -316,31 +342,31 @@ public class Animator extends AnimatorBase {
@Override
public final synchronized boolean pause() {
- if ( !isStarted() || pauseIssued ) {
+ if ( !isStarted() || pauseIssued2 ) {
return false;
}
- pauseIssued = true;
+ pauseIssued2 = true;
return finishLifecycleAction(waitForPausedCondition, 0);
}
private final Condition waitForPausedCondition = new Condition() {
@Override
public boolean eval() {
// end waiting if stopped as well
- return isStarted() && isAnimating;
+ return isStarted() && isAnimating2;
} };
@Override
public final synchronized boolean resume() {
- if ( !isStarted() || !pauseIssued ) {
+ if ( !isStarted() || !pauseIssued2 ) {
return false;
}
- pauseIssued = false;
+ pauseIssued2 = false;
return finishLifecycleAction(waitForResumeCondition, 0);
}
private final Condition waitForResumeCondition = new Condition() {
@Override
public boolean eval() {
// end waiting if stopped as well
- return isStarted() && ( !drawablesEmpty && !isAnimating || drawablesEmpty && !pauseIssued ) ;
+ return isStarted() && ( !drawablesEmpty && !isAnimating2 || drawablesEmpty && !pauseIssued2 ) ;
} };
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
index 8b4e125..2c058fc 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
@@ -85,10 +85,12 @@ public abstract class AnimatorBase implements GLAnimatorControl {
* @param printExceptions
* @throws UncaughtAnimatorException as caused by {@link GLAutoDrawable#display()}
*/
- void display(ArrayList<GLAutoDrawable> drawables, boolean ignoreExceptions, boolean printExceptions) throws UncaughtAnimatorException;
- boolean blockUntilDone(Thread thread);
+ void display(final ArrayList<GLAutoDrawable> drawables, final boolean ignoreExceptions, final boolean printExceptions) throws UncaughtAnimatorException;
+ boolean blockUntilDone(final Thread thread);
}
+ private static int seqInstanceNumber = 0;
+
protected int modeBits;
protected AnimatorImpl impl;
protected String baseName;
@@ -146,15 +148,16 @@ public abstract class AnimatorBase implements GLAnimatorControl {
*/
protected final synchronized void initImpl(final boolean force) {
if( force || null == impl ) {
+ final String seqSuffix = String.format("#%02d", seqInstanceNumber++);
if( useAWTAnimatorImpl( modeBits ) ) {
try {
impl = (AnimatorImpl) awtAnimatorImplClazz.newInstance();
- baseName = getBaseName("AWT");
+ baseName = getBaseName("AWT")+seqSuffix;
} catch (final Exception e) { e.printStackTrace(); }
}
if( null == impl ) {
impl = new DefaultAnimatorImpl();
- baseName = getBaseName("");
+ baseName = getBaseName("")+seqSuffix;
}
if(DEBUG) {
System.err.println("Animator.initImpl: baseName "+baseName+", implClazz "+impl.getClass().getName()+" - "+toString()+" - "+getThreadName());
@@ -524,25 +527,24 @@ public abstract class AnimatorBase implements GLAnimatorControl {
/**
* Should be called in case of an uncaught exception
- * from within the animator thread to flush all animator
+ * from within the animator thread, throws given exception if no handler has been installed.
*/
protected final synchronized void handleUncaughtException(final UncaughtAnimatorException ue) {
if( null != uncaughtExceptionHandler ) {
try {
uncaughtExceptionHandler.uncaughtException(this, ue.getGLAutoDrawable(), ue.getCause());
} catch (final Throwable t) { /* ignore intentionally */ }
- flushGLRunnables();
- } else {
- flushGLRunnables();
- throw ue;
}
}
/**
* Should be called in case of an uncaught exception
- * from within the animator thread to flush all animator
+ * from within the animator thread to flush all animator.
+ * <p>
+ * The animator instance shall not be locked when calling this method!
+ * </p>
*/
- protected final synchronized void flushGLRunnables() {
+ protected final void flushGLRunnables() {
for (int i=0; i<drawables.size(); i++) {
drawables.get(i).flushGLRunnables();
}
@@ -559,7 +561,8 @@ public abstract class AnimatorBase implements GLAnimatorControl {
* @param waitCondition method will wait until TO is reached or {@link Condition#eval() waitCondition.eval()} returns <code>false</code>.
* @param pollPeriod if <code>0</code>, method will wait until TO is reached or being notified.
* if > <code>0</code>, method will wait for the given <code>pollPeriod</code> in milliseconds.
- * @return <code>true</code> if {@link Condition#eval() waitCondition.eval()} returned <code>false</code>, otherwise <code>false</code>.
+ * @return <code>true</code> if {@link Condition#eval() waitCondition.eval()} returned <code>false</code>
+ * or if {@link AnimatorImpl#blockUntilDone(Thread) non-blocking}. Otherwise returns <code>false</code>.
*/
protected final synchronized boolean finishLifecycleAction(final Condition waitCondition, long pollPeriod) {
/**
@@ -572,6 +575,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
final boolean blocking;
long remaining;
boolean nok;
+
if( impl.blockUntilDone(animThread) ) {
blocking = true;
remaining = TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION;
@@ -605,12 +609,13 @@ public abstract class AnimatorBase implements GLAnimatorControl {
nok = waitCondition.eval();
}
}
+ final boolean res = !nok || !blocking;
if(DEBUG || blocking && nok) { // Info only if DEBUG or ( blocking && not-ok ) ; !blocking possible if AWT
if( blocking && remaining<=0 && nok ) {
System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + getThreadName());
}
System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+
- "- pollPeriod "+pollPeriod+", blocking "+blocking+
+ "- pollPeriod "+pollPeriod+", blocking "+blocking+" -> res "+res+
", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION +
" - " + getThreadName());
System.err.println(" - "+toString());
@@ -618,7 +623,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
Thread.dumpStack();
}
}
- return !nok;
+ return res;
}
@Override
diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
index 9ae8804..7abe987 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
@@ -60,9 +60,9 @@ public class FPSAnimator extends AnimatorBase {
private MainTask task = null;
private int fps;
private final boolean scheduleAtFixedRate;
- private boolean isAnimating; // MainTask feedback
- private volatile boolean shouldRun; // MainTask trigger
- private volatile boolean shouldStop; // MainTask trigger
+ private boolean isAnimating; // MainTask feedback
+ private volatile boolean pauseIssued; // MainTask trigger
+ private volatile boolean stopIssued; // MainTask trigger
@Override
protected String getBaseName(final String prefix) {
@@ -124,8 +124,9 @@ public class FPSAnimator extends AnimatorBase {
public void start(final Timer timer) {
fpsCounter.resetFPSCounter();
- shouldRun = true;
- shouldStop = false;
+ pauseIssued = false;
+ stopIssued = false;
+ isAnimating = false;
justStarted = true;
alreadyStopped = false;
@@ -143,12 +144,12 @@ public class FPSAnimator extends AnimatorBase {
@Override
public final String toString() {
- return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStarted()+", animating "+isAnimatingImpl()+", paused "+isPaused()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]";
+ return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" pauseIssued "+pauseIssued+", stopIssued "+stopIssued+" -- started "+isStarted()+", animating "+isAnimatingImpl()+", paused "+isPaused()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]";
}
@Override
public void run() {
- UncaughtAnimatorException displayCaught = null;
+ UncaughtAnimatorException caughtException = null;
if( justStarted ) {
justStarted = false;
@@ -159,26 +160,25 @@ public class FPSAnimator extends AnimatorBase {
}
isAnimating = true;
if( drawablesEmpty ) {
- shouldRun = false; // isAnimating:=false @ pause below
+ pauseIssued = true; // isAnimating:=false @ pause below
} else {
- shouldRun = true;
+ pauseIssued = false;
setDrawablesExclCtxState(exclusiveContext); // may re-enable exclusive context
- FPSAnimator.this.notifyAll();
}
+ FPSAnimator.this.notifyAll(); // Wakes up 'waitForStartedCondition' sync -and resume from pause or drawablesEmpty
if(DEBUG) {
System.err.println("FPSAnimator P1:" + Thread.currentThread() + ": " + toString());
}
}
}
- if( shouldRun && !shouldStop ) { // RUN
+ if( !pauseIssued && !stopIssued ) { // RUN
try {
display();
} catch (final UncaughtAnimatorException dre) {
- displayCaught = dre;
- shouldRun = false;
- shouldStop = true;
+ caughtException = dre;
+ stopIssued = true;
}
- } else if( !shouldRun && !shouldStop ) { // PAUSE
+ } else if( pauseIssued && !stopIssued ) { // PAUSE
if(DEBUG) {
System.err.println("FPSAnimator pausing: "+alreadyPaused+", "+ Thread.currentThread() + ": " + toString());
}
@@ -191,12 +191,11 @@ public class FPSAnimator extends AnimatorBase {
try {
display(); // propagate exclusive context -> off!
} catch (final UncaughtAnimatorException dre) {
- displayCaught = dre;
- shouldRun = false;
- shouldStop = true;
+ caughtException = dre;
+ stopIssued = true;
}
}
- if( null == displayCaught ) {
+ if( null == caughtException ) {
synchronized (FPSAnimator.this) {
if(DEBUG) {
System.err.println("FPSAnimator pause " + Thread.currentThread() + ": " + toString());
@@ -207,7 +206,7 @@ public class FPSAnimator extends AnimatorBase {
}
}
}
- if( shouldStop ) { // STOP
+ if( stopIssued ) { // STOP incl. immediate exception handling of 'displayCaught'
if(DEBUG) {
System.err.println("FPSAnimator stopping: "+alreadyStopped+", "+ Thread.currentThread() + ": " + toString());
}
@@ -220,28 +219,43 @@ public class FPSAnimator extends AnimatorBase {
try {
display(); // propagate exclusive context -> off!
} catch (final UncaughtAnimatorException dre) {
- if( null == displayCaught ) {
- displayCaught = dre;
+ if( null == caughtException ) {
+ caughtException = dre;
} else {
+ System.err.println("FPSAnimator.setExclusiveContextThread: caught: "+dre.getMessage());
dre.printStackTrace();
}
}
}
+ boolean flushGLRunnables = false;
+ boolean throwCaughtException = false;
synchronized (FPSAnimator.this) {
if(DEBUG) {
System.err.println("FPSAnimator stop " + Thread.currentThread() + ": " + toString());
- if( null != displayCaught ) {
- System.err.println("AnimatorBase.setExclusiveContextThread: caught: "+displayCaught.getMessage());
- displayCaught.printStackTrace();
+ if( null != caughtException ) {
+ System.err.println("Animator caught: "+caughtException.getMessage());
+ caughtException.printStackTrace();
}
}
isAnimating = false;
- if( null != displayCaught ) {
- handleUncaughtException(displayCaught);
+ if( null != caughtException ) {
+ flushGLRunnables = true;
+ if( null != uncaughtExceptionHandler ) {
+ handleUncaughtException(caughtException);
+ throwCaughtException = false;
+ } else {
+ throwCaughtException = true;
+ }
}
animThread = null;
FPSAnimator.this.notifyAll();
}
+ if( flushGLRunnables ) {
+ flushGLRunnables();
+ }
+ if( throwCaughtException ) {
+ throw caughtException;
+ }
}
}
}
@@ -256,7 +270,7 @@ public class FPSAnimator extends AnimatorBase {
@Override
public final synchronized boolean isPaused() {
- return animThread != null && ( !shouldRun && !shouldStop ) ;
+ return animThread != null && pauseIssued;
}
static int timerNo = 0;
@@ -311,8 +325,7 @@ public class FPSAnimator extends AnimatorBase {
// start/resume case w/ drawablesEmpty
res = true;
} else {
- shouldRun = false;
- shouldStop = true;
+ stopIssued = true;
res = finishLifecycleAction(waitForStoppedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION);
}
@@ -338,7 +351,7 @@ public class FPSAnimator extends AnimatorBase {
@Override
public final synchronized boolean pause() {
- if ( !isStarted() || ( null != task && isPaused() ) ) {
+ if ( !isStarted() || pauseIssued ) {
return false;
}
if(DEBUG) {
@@ -349,7 +362,7 @@ public class FPSAnimator extends AnimatorBase {
// start/resume case w/ drawablesEmpty
res = true;
} else {
- shouldRun = false;
+ pauseIssued = true;
res = finishLifecycleAction(waitForPausedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION);
}
@@ -366,12 +379,12 @@ public class FPSAnimator extends AnimatorBase {
@Override
public boolean eval() {
// end waiting if stopped as well
- return isAnimating && isStarted();
+ return isStarted() && isAnimating;
} };
@Override
public final synchronized boolean resume() {
- if ( null != task || !isStarted() || !isPaused() ) {
+ if ( !isStarted() || !pauseIssued ) {
return false;
}
if(DEBUG) {
@@ -381,6 +394,14 @@ public class FPSAnimator extends AnimatorBase {
if( drawablesEmpty ) {
res = true;
} else {
+ if( null != task ) {
+ if( DEBUG ) {
+ System.err.println("FPSAnimator.resume() Ops: !pauseIssued, but task != null: "+toString());
+ Thread.dumpStack();
+ }
+ task.cancel();
+ task = null;
+ }
task = new MainTask();
task.start(timer);
res = finishLifecycleAction(waitForResumeCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
index 44be299..d4ab4e4 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
@@ -46,6 +46,7 @@ import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2ES3;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLES2;
import javax.media.opengl.GLException;
@@ -372,25 +373,29 @@ public class GLBuffers extends Buffers {
if (pack) {
alignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT, tmp);
- if(gl.isGL2GL3()) {
+ if( gl.isGL2ES3() ) {
rowLength = glGetInteger(gl, GL2ES3.GL_PACK_ROW_LENGTH, tmp);
skipRows = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_ROWS, tmp);
skipPixels = glGetInteger(gl, GL2ES3.GL_PACK_SKIP_PIXELS, tmp);
- if (depth > 1) {
+ if (depth > 1 && gl.isGL2GL3() && gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 ) {
imageHeight = glGetInteger(gl, GL2GL3.GL_PACK_IMAGE_HEIGHT, tmp);
skipImages = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_IMAGES, tmp);
}
}
} else {
alignment = glGetInteger(gl, GL.GL_UNPACK_ALIGNMENT, tmp);
- if(gl.isGL2GL3 ()) {
+ if( gl.isGL2ES3() ) {
rowLength = glGetInteger(gl, GL2ES2.GL_UNPACK_ROW_LENGTH, tmp);
skipRows = glGetInteger(gl, GL2ES2.GL_UNPACK_SKIP_ROWS, tmp);
skipPixels = glGetInteger(gl, GL2ES2.GL_UNPACK_SKIP_PIXELS, tmp);
- if (depth > 1) {
+ if( depth > 1 &&
+ ( gl.isGL3ES3() ||
+ ( gl.isGL2GL3() && gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 )
+ )
+ ) {
imageHeight = glGetInteger(gl, GL2ES3.GL_UNPACK_IMAGE_HEIGHT, tmp);
skipImages = glGetInteger(gl, GL2ES3.GL_UNPACK_SKIP_IMAGES, tmp);
- }
+ }
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
index 956693c..634cfea 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java
@@ -150,7 +150,7 @@ public class GLDrawableUtil {
}
/**
- * Return a heuristic value whether switching the {@link GLContext} is safe between {@lin GLAutoDrawable}s,
+ * Return a heuristic value whether switching the {@link GLContext} is safe between {@link GLAutoDrawable}s,
* i.e. via {@link #swapGLContext(GLAutoDrawable, GLAutoDrawable)} or {@link #swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable)}.
* <p>
* Method currently returns <code>false</code> if:
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
index 52612d2..f347dc0 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
@@ -33,6 +33,7 @@ import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2ES3;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
/**
@@ -171,7 +172,7 @@ public class GLPixelStorageModes {
*/
public final void resetPack(final GL gl) {
// Compared w/ ES2, ES3 and GL3-core spec
- gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4); // es2, es3, gl3
+ gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 4); // es2, es3, gl3
if( gl.isGL2ES3() ) {
gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, 0); // es3, gl3
gl.glPixelStorei(GL2ES3.GL_PACK_SKIP_ROWS, 0); // es3, gl3
@@ -179,8 +180,10 @@ public class GLPixelStorageModes {
if( gl.isGL2GL3() ) {
gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, GL.GL_FALSE); // gl3
gl.glPixelStorei(GL2GL3.GL_PACK_LSB_FIRST, GL.GL_FALSE); // gl3
- gl.glPixelStorei(GL2GL3.GL_PACK_IMAGE_HEIGHT, 0); // gl3
- gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_IMAGES, 0); // gl3
+ if( gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 ) {
+ gl.glPixelStorei(GL2GL3.GL_PACK_IMAGE_HEIGHT, 0); // gl3, GL_VERSION_1_2
+ gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_IMAGES, 0); // gl3, GL_VERSION_1_2
+ }
}
}
}
@@ -242,16 +245,21 @@ public class GLPixelStorageModes {
*/
public final void resetUnpack(final GL gl) {
// Compared w/ ES2, ES3 and GL3-core spec
- gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 4); // es2, es3, gl3
+ gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 4); // es2, es3, gl3
if( gl.isGL2ES3() ) {
gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, 0); // es3, gl3
gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_ROWS, 0); // es3, gl3
gl.glPixelStorei(GL2ES2.GL_UNPACK_SKIP_PIXELS, 0); // es3, gl3
- gl.glPixelStorei(GL2ES3.GL_UNPACK_IMAGE_HEIGHT, 0); // es3, gl3
- gl.glPixelStorei(GL2ES3.GL_UNPACK_SKIP_IMAGES, 0); // es3, gl3
if( gl.isGL2GL3() ) {
+ if( gl.getContext().getGLVersionNumber().compareTo(GLContext.Version120) >= 0 ) {
+ gl.glPixelStorei(GL2ES3.GL_UNPACK_IMAGE_HEIGHT, 0); // es3, gl3, GL_VERSION_1_2
+ gl.glPixelStorei(GL2ES3.GL_UNPACK_SKIP_IMAGES, 0); // es3, gl3, GL_VERSION_1_2
+ }
gl.glPixelStorei(GL2GL3.GL_UNPACK_SWAP_BYTES, GL.GL_FALSE); // gl3
gl.glPixelStorei(GL2GL3.GL_UNPACK_LSB_FIRST, GL.GL_FALSE); // gl3
+ } else {
+ gl.glPixelStorei(GL2ES3.GL_UNPACK_IMAGE_HEIGHT, 0); // es3, gl3, GL_VERSION_1_2
+ gl.glPixelStorei(GL2ES3.GL_UNPACK_SKIP_IMAGES, 0); // es3, gl3, GL_VERSION_1_2
}
}
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
index 574fc42..f56ac32 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -46,6 +46,7 @@ import java.util.Set;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL3;
+import javax.media.opengl.GL4;
import javax.media.opengl.GLES2;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
@@ -63,33 +64,62 @@ import com.jogamp.common.util.VersionNumber;
* {@link #create(GL2ES2, int, Class, String, String, String, boolean) here} and
* {@link #create(GL2ES2, int, int, Class, String, String[], String, String) here}.
* </p>
+ * <p>
+ * Support for {@link GL4#GL_TESS_CONTROL_SHADER} and {@link GL4#GL_TESS_EVALUATION_SHADER}
+ * was added since 2.2.1.
+ * </p>
*/
public class ShaderCode {
public static final boolean DEBUG_CODE = Debug.isPropertyDefined("jogl.debug.GLSLCode", true);
- /** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in source code: <code>vp</code> */
+ /** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in source code: <code>{@value}</code> */
public static final String SUFFIX_VERTEX_SOURCE = "vp" ;
- /** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in binary: <code>bvp</code> */
+ /** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in binary: <code>{@value}</code> */
public static final String SUFFIX_VERTEX_BINARY = "bvp" ;
- /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in source code: <code>gp</code> */
+ /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in source code: <code>{@value}</code> */
public static final String SUFFIX_GEOMETRY_SOURCE = "gp" ;
- /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in binary: <code>bgp</code> */
+ /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in binary: <code>{@value}</code> */
public static final String SUFFIX_GEOMETRY_BINARY = "bgp" ;
- /** Unique resource suffix for {@link GL2ES2#GL_FRAGMENT_SHADER} in source code: <code>fp</code> */
+ /**
+ * Unique resource suffix for {@link GL4#GL_TESS_CONTROL_SHADER} in source code: <code>{@value}</code>
+ * @since 2.2.1
+ */
+ public static final String SUFFIX_TESS_CONTROL_SOURCE = "tcp" ;
+
+ /**
+ * Unique resource suffix for {@link GL4#GL_TESS_CONTROL_SHADER} in binary: <code>{@value}</code>
+ * @since 2.2.1
+ */
+ public static final String SUFFIX_TESS_CONTROL_BINARY = "btcp" ;
+
+ /**
+ * Unique resource suffix for {@link GL4#GL_TESS_EVALUATION_SHADER} in source code: <code>{@value}</code>
+ * @since 2.2.1
+ */
+ public static final String SUFFIX_TESS_EVALUATION_SOURCE = "tep" ;
+
+ /**
+ * Unique resource suffix for {@link GL4#GL_TESS_EVALUATION_SHADER} in binary: <code>{@value}</code>
+ * @since 2.2.1
+ */
+ public static final String SUFFIX_TESS_EVALUATION_BINARY = "btep" ;
+
+ /** Unique resource suffix for {@link GL2ES2#GL_FRAGMENT_SHADER} in source code: <code>{@value}</code> */
public static final String SUFFIX_FRAGMENT_SOURCE = "fp" ;
- /** Unique resource suffix for {@link GL2ES2#GL_FRAGMENT_SHADER} in binary: <code>bfp</code> */
+ /** Unique resource suffix for {@link GL2ES2#GL_FRAGMENT_SHADER} in binary: <code>{@value}</code> */
public static final String SUFFIX_FRAGMENT_BINARY = "bfp" ;
- /** Unique relative path for binary shader resources for {@link GLES2#GL_NVIDIA_PLATFORM_BINARY_NV NVIDIA}: <code>nvidia</code> */
+ /** Unique relative path for binary shader resources for {@link GLES2#GL_NVIDIA_PLATFORM_BINARY_NV NVIDIA}: <code>{@value}</code> */
public static final String SUB_PATH_NVIDIA = "nvidia" ;
/**
- * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER}
+ * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER}, {@link GL3#GL_GEOMETRY_SHADER},
+ * {@link GL4#GL_TESS_CONTROL_SHADER} or {@link GL4#GL_TESS_EVALUATION_SHADER}.
* @param count number of shaders
* @param source CharSequence array containing the shader sources, organized as <code>source[count][strings-per-shader]</code>.
* May be either an immutable <code>String</code> - or mutable <code>StringBuilder</code> array.
@@ -104,6 +134,8 @@ public class ShaderCode {
case GL2ES2.GL_VERTEX_SHADER:
case GL2ES2.GL_FRAGMENT_SHADER:
case GL3.GL_GEOMETRY_SHADER:
+ case GL4.GL_TESS_CONTROL_SHADER:
+ case GL4.GL_TESS_EVALUATION_SHADER:
break;
default:
throw new GLException("Unknown shader type: "+type);
@@ -122,7 +154,8 @@ public class ShaderCode {
}
/**
- * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER}
+ * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER}, {@link GL3#GL_GEOMETRY_SHADER},
+ * {@link GL4#GL_TESS_CONTROL_SHADER} or {@link GL4#GL_TESS_EVALUATION_SHADER}.
* @param count number of shaders
* @param binary binary buffer containing the shader binaries,
*/
@@ -131,6 +164,8 @@ public class ShaderCode {
case GL2ES2.GL_VERTEX_SHADER:
case GL2ES2.GL_FRAGMENT_SHADER:
case GL3.GL_GEOMETRY_SHADER:
+ case GL4.GL_TESS_CONTROL_SHADER:
+ case GL4.GL_TESS_EVALUATION_SHADER:
break;
default:
throw new GLException("Unknown shader type: "+type);
@@ -148,7 +183,8 @@ public class ShaderCode {
* which location is resolved using the <code>context</code> class, see {@link #readShaderSource(Class, String)}.
*
* @param gl current GL object to determine whether a shader compiler is available. If null, no validation is performed.
- * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER}
+ * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER}, {@link GL3#GL_GEOMETRY_SHADER},
+ * {@link GL4#GL_TESS_CONTROL_SHADER} or {@link GL4#GL_TESS_EVALUATION_SHADER}.
* @param count number of shaders
* @param context class used to help resolving the source location
* @param sourceFiles array of source locations, organized as <code>sourceFiles[count]</code>
@@ -192,7 +228,8 @@ public class ShaderCode {
* Creates a complete {@link ShaderCode} object while reading the shader binary of <code>binaryFile</code>,
* which location is resolved using the <code>context</code> class, see {@link #readShaderBinary(Class, String)}.
*
- * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER}
+ * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER}, {@link GL3#GL_GEOMETRY_SHADER},
+ * {@link GL4#GL_TESS_CONTROL_SHADER} or {@link GL4#GL_TESS_EVALUATION_SHADER}.
* @param count number of shaders
* @param context class used to help resolving the source location
* @param binFormat a valid native binary format as they can be queried by {@link ShaderUtil#getShaderBinaryFormats(GL)}.
@@ -225,14 +262,21 @@ public class ShaderCode {
* <li>Source<ul>
* <li>{@link GL2ES2#GL_VERTEX_SHADER vertex}: {@link #SUFFIX_VERTEX_SOURCE}</li>
* <li>{@link GL2ES2#GL_FRAGMENT_SHADER fragment}: {@link #SUFFIX_FRAGMENT_SOURCE}</li>
- * <li>{@link GL3#GL_GEOMETRY_SHADER geometry}: {@link #SUFFIX_GEOMETRY_SOURCE}</li></ul></li>
+ * <li>{@link GL3#GL_GEOMETRY_SHADER geometry}: {@link #SUFFIX_GEOMETRY_SOURCE}</li>
+ * <li>{@link GL4#GL_TESS_CONTROL_SHADER tess-ctrl}: {@link #SUFFIX_TESS_CONTROL_SOURCE}</li>
+ * <li>{@link GL4#GL_TESS_EVALUATION_SHADER tess-eval}: {@link #SUFFIX_TESS_EVALUATION_SOURCE}</li>
+ * </ul></li>
* <li>Binary<ul>
* <li>{@link GL2ES2#GL_VERTEX_SHADER vertex}: {@link #SUFFIX_VERTEX_BINARY}</li>
* <li>{@link GL2ES2#GL_FRAGMENT_SHADER fragment}: {@link #SUFFIX_FRAGMENT_BINARY}</li>
- * <li>{@link GL3#GL_GEOMETRY_SHADER geometry}: {@link #SUFFIX_GEOMETRY_BINARY}</li></ul></li>
+ * <li>{@link GL3#GL_GEOMETRY_SHADER geometry}: {@link #SUFFIX_GEOMETRY_BINARY}</li>
+ * <li>{@link GL4#GL_TESS_CONTROL_SHADER tess-ctrl}: {@link #SUFFIX_TESS_CONTROL_BINARY}</li>
+ * <li>{@link GL4#GL_TESS_EVALUATION_SHADER tess-eval}: {@link #SUFFIX_TESS_EVALUATION_BINARY}</li>
+ * </ul></li>
* </ul>
* @param binary true for a binary resource, false for a source resource
- * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER}
+ * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER}, {@link GL3#GL_GEOMETRY_SHADER},
+ * {@link GL4#GL_TESS_CONTROL_SHADER} or {@link GL4#GL_TESS_EVALUATION_SHADER}.
*
* @throws GLException if <code>type</code> is not supported
*
@@ -246,6 +290,10 @@ public class ShaderCode {
return binary?SUFFIX_FRAGMENT_BINARY:SUFFIX_FRAGMENT_SOURCE;
case GL3.GL_GEOMETRY_SHADER:
return binary?SUFFIX_GEOMETRY_BINARY:SUFFIX_GEOMETRY_SOURCE;
+ case GL4.GL_TESS_CONTROL_SHADER:
+ return binary?SUFFIX_TESS_CONTROL_BINARY:SUFFIX_TESS_CONTROL_SOURCE;
+ case GL4.GL_TESS_EVALUATION_SHADER:
+ return binary?SUFFIX_TESS_EVALUATION_BINARY:SUFFIX_TESS_EVALUATION_SOURCE;
default:
throw new GLException("illegal shader type: "+type);
}
@@ -324,7 +372,8 @@ public class ShaderCode {
*
* @param gl current GL object to determine whether a shader compiler is available (if <code>source</code> is used),
* or to determine the shader binary format (if <code>binary</code> is used).
- * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER}
+ * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER}, {@link GL3#GL_GEOMETRY_SHADER},
+ * {@link GL4#GL_TESS_CONTROL_SHADER} or {@link GL4#GL_TESS_EVALUATION_SHADER}.
* @param count number of shaders
* @param context class used to help resolving the source and binary location
* @param srcRoot relative <i>root</i> path for <code>srcBasenames</code> optional
@@ -394,9 +443,8 @@ public class ShaderCode {
}
/**
- * Simplified variation of {@link #create(GL2ES2, int, int, Class, String, String[], String, String)}.
- * <br>
- *
+ * Simplified variation of {@link #create(GL2ES2, int, int, Class, String, String[], String, String, boolean)}.
+ * <p>
* Example:
* <pre>
* Your std JVM layout (plain or within a JAR):
@@ -427,10 +475,12 @@ public class ShaderCode {
* sp0.add(gl, fp0, System.err);
* st.attachShaderProgram(gl, sp0, true);
* </pre>
+ * </p>
*
* @param gl current GL object to determine whether a shader compiler is available (if <code>source</code> is used),
* or to determine the shader binary format (if <code>binary</code> is used).
- * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER}
+ * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER}, {@link GL3#GL_GEOMETRY_SHADER},
+ * {@link GL4#GL_TESS_CONTROL_SHADER} or {@link GL4#GL_TESS_EVALUATION_SHADER}.
* @param context class used to help resolving the source and binary location
* @param srcRoot relative <i>root</i> path for <code>basename</code> optional
* @param binRoot relative <i>root</i> path for <code>basename</code>
@@ -468,6 +518,10 @@ public class ShaderCode {
return "FRAGMENT_SHADER";
case GL3.GL_GEOMETRY_SHADER:
return "GEOMETRY_SHADER";
+ case GL4.GL_TESS_CONTROL_SHADER:
+ return "TESS_CONTROL_SHADER";
+ case GL4.GL_TESS_EVALUATION_SHADER:
+ return "TESS_EVALUATION_SHADER";
}
return "UNKNOWN_SHADER";
}
@@ -960,6 +1014,8 @@ public class ShaderCode {
switch ( shaderType ) {
case GL2ES2.GL_VERTEX_SHADER:
case GL3.GL_GEOMETRY_SHADER:
+ case GL4.GL_TESS_CONTROL_SHADER:
+ case GL4.GL_TESS_EVALUATION_SHADER:
defaultPrecision = gl3_default_precision_vp_gp; break;
case GL2ES2.GL_FRAGMENT_SHADER:
defaultPrecision = gl3_default_precision_fp; break;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java
index f113be2..1d62913 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java
@@ -109,8 +109,7 @@ public abstract class CompileShader {
tmpFile.getAbsolutePath(),
outputFile.getAbsolutePath()
}); // , null, processorDir);
- new StreamMonitor(process.getInputStream());
- new StreamMonitor(process.getErrorStream());
+ new IOUtil.StreamMonitor( new InputStream[] { process.getInputStream(), process.getErrorStream() }, System.out, null );
process.waitFor();
// Delete the temporary file
// tmpFile.delete();
@@ -153,35 +152,4 @@ public abstract class CompileShader {
e.printStackTrace();
}
}
-
- private static class StreamMonitor implements Runnable {
- private final InputStream istream;
- public StreamMonitor(final InputStream stream) {
- istream = stream;
- new Thread(this, "Output Reader Thread").start();
- }
-
- @Override
- public void run()
- {
- final byte[] buffer = new byte[4096];
- try {
- int numRead = 0;
- do {
- numRead = istream.read(buffer);
- if (numRead > 0) {
- System.out.write(buffer, 0, numRead);
- System.out.flush();
- }
- } while (numRead >= 0);
- }
- catch (final IOException e) {
- try {
- istream.close();
- } catch (final IOException e2) {
- }
- // Should allow clean exit when process shuts down
- }
- }
- }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java
index c9445b7..f70ebf9 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/stereo/StereoClientRenderer.java
@@ -87,8 +87,7 @@ public class StereoClientRenderer implements GLEventListener {
private void initFBOs(final GL gl, final DimensionImmutable size) {
for(int i=0; i<fbos.length; i++) {
- fbos[i].detachAllColorbuffer(gl);
- fbos[i].reset(gl, size.getWidth(), size.getHeight(), numSamples, false);
+ fbos[i].init(gl, size.getWidth(), size.getHeight(), numSamples);
if( i>0 && fbos[i-1].getNumSamples() != fbos[i].getNumSamples()) {
throw new InternalError("sample size mismatch: \n\t0: "+fbos[i-1]+"\n\t1: "+fbos[i]);
}
@@ -96,19 +95,19 @@ public class StereoClientRenderer implements GLEventListener {
if(numSamples>0) {
fbos[i].attachColorbuffer(gl, 0, true); // MSAA requires alpha
- fbos[i].attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbos[i].attachRenderbuffer(gl, Type.DEPTH, FBObject.DEFAULT_BITS);
final FBObject ssink = new FBObject();
{
- ssink.reset(gl, size.getWidth(), size.getHeight());
+ ssink.init(gl, size.getWidth(), size.getHeight(), 0);
ssink.attachTexture2D(gl, 0, false, magFilter, minFilter, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
- ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
}
fbos[i].setSamplingSink(ssink);
fbos[i].resetSamplingSink(gl); // validate
fboTexs[i] = fbos[i].getSamplingSink().getTextureAttachment();
} else {
fboTexs[i] = fbos[i].attachTexture2D(gl, 0, false, magFilter, minFilter, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
- fbos[i].attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbos[i].attachRenderbuffer(gl, Type.DEPTH, FBObject.DEFAULT_BITS);
}
fbos[i].unbind(gl);
System.err.println("FBO["+i+"]: "+fbos[i]);
@@ -119,7 +118,7 @@ public class StereoClientRenderer implements GLEventListener {
@SuppressWarnings("unused")
private void resetFBOs(final GL gl, final DimensionImmutable size) {
for(int i=0; i<fbos.length; i++) {
- fbos[i].reset(gl, size.getWidth(), size.getHeight(), numSamples, true);
+ fbos[i].reset(gl, size.getWidth(), size.getHeight(), numSamples);
if( i>0 && fbos[i-1].getNumSamples() != fbos[i].getNumSamples()) {
throw new InternalError("sample size mismatch: \n\t0: "+fbos[i-1]+"\n\t1: "+fbos[i]);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
index 19f2fc0..1f5b261 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
@@ -575,6 +575,10 @@ public class TextureIO {
* when it is written to disk, regardless of whether the underlying
* file format supports multiple mipmaps in a given file.
*
+ * <p>
+ * Method required a {@link GL2GL3} {@link GLProfile#GL2GL3 profile}.
+ * </p>
+ *
* @throws IOException if an error occurred during writing or no
* suitable writer was found
* @throws GLException if no OpenGL context was current or an
@@ -590,7 +594,7 @@ public class TextureIO {
if (!_gl.isGL2GL3()) {
throw new GLException("Implementation only supports GL2GL3 (Use GLReadBufferUtil and the TextureData variant), have: " + _gl);
}
- final GL2GL3 gl = _gl.getGL2();
+ final GL2GL3 gl = _gl.getGL2GL3();
texture.bind(gl);
final int internalFormat = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2GL3.GL_TEXTURE_INTERNAL_FORMAT);
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 863eb1a..e2498e6 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -108,6 +108,7 @@ public abstract class GLContext {
protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true);
protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true);
+ protected static final boolean FORCE_NO_COLOR_RENDERBUFFER = Debug.isPropertyDefined("jogl.fbo.force.nocolorrenderbuffer", true);
/** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */
public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true);
@@ -148,6 +149,8 @@ public abstract class GLContext {
protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0);
+ private static final String S_EMPTY = "";
+
//
// Cached keys, bits [0..15]
//
@@ -205,7 +208,7 @@ public abstract class GLContext {
private final HashMap<String, Object> attachedObjects = new HashMap<String, Object>();
// RecursiveLock maintains a queue of waiting Threads, ensuring the longest waiting thread will be notified at unlock.
- protected final RecursiveLock lock = LockFactory.createRecursiveLock();
+ protected final RecursiveLock lock = LockFactory.createRecursiveLock(); // FIXME: Move to GLContextImpl when incr. minor version (incompatible change)
/** The underlying native OpenGL context */
protected volatile long contextHandle; // volatile: avoid locking for read-only access
@@ -250,6 +253,17 @@ public abstract class GLContext {
return GLContextShareSet.isShared(this);
}
+ /**
+ * Returns the shared master GLContext of this GLContext if shared, otherwise return <code>null</code>.
+ * <p>
+ * Returns this GLContext, if it is a shared master.
+ * </p>
+ * @since 2.2.1
+ */
+ public final GLContext getSharedMaster() {
+ return GLContextShareSet.getSharedMaster(this);
+ }
+
/** Returns a new list of created GLContext shared with this GLContext. */
public final List<GLContext> getCreatedShares() {
return GLContextShareSet.getCreatedShares(this);
@@ -326,6 +340,9 @@ public abstract class GLContext {
* If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
* it equals to the write-drawable (default).
* </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
* @see #setGLDrawable(GLDrawable, boolean)
* @see #setGLReadDrawable(GLDrawable)
*/
@@ -364,6 +381,9 @@ public abstract class GLContext {
* If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)},
* it equals to the write-drawable (default).
* </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
* @see #isGLReadDrawableAvailable()
* @see #setGLReadDrawable(GLDrawable)
* @see #getGLReadDrawable()
@@ -802,8 +822,8 @@ public abstract class GLContext {
* <pre>
* #version 110
* ..
- * #version 150
- * #version 330
+ * #version 150 core
+ * #version 330 compatibility
* ...
* </pre>
* And for ES:
@@ -819,11 +839,20 @@ public abstract class GLContext {
*/
public final String getGLSLVersionString() {
if( ctxGLSLVersion.isZero() ) {
- return "";
+ return S_EMPTY;
}
final int minor = ctxGLSLVersion.getMinor();
- final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : "";
- return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + esSuffix + "\n" ;
+ final String profileOpt;
+ if( isGLES() ) {
+ profileOpt = ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : S_EMPTY;
+ } else if( isGLCoreProfile() ) {
+ profileOpt = ctxGLSLVersion.compareTo(Version150) >= 0 ? " core" : S_EMPTY;
+ } else if( isGLCompatibilityProfile() ) {
+ profileOpt = ctxGLSLVersion.compareTo(Version150) >= 0 ? " compatibility" : S_EMPTY;
+ } else {
+ throw new InternalError("Neither ES, Core nor Compat: "+this); // see validateProfileBits(..)
+ }
+ return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + profileOpt + "\n" ;
}
protected static final VersionNumber getStaticGLSLVersionNumber(final int glMajorVersion, final int glMinorVersion, final int ctxOptions) {
@@ -1262,6 +1291,9 @@ public abstract class GLContext {
/**
* Return the framebuffer name bound to this context,
* see {@link GL#glBindFramebuffer(int, int)}.
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
*/
public abstract int getBoundFramebuffer(int target);
@@ -1272,6 +1304,9 @@ public abstract class GLContext {
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
* is being used.
* </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
*/
public abstract int getDefaultDrawFramebuffer();
@@ -1282,6 +1317,9 @@ public abstract class GLContext {
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
* is being used.
* </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
*/
public abstract int getDefaultReadFramebuffer();
@@ -1306,13 +1344,26 @@ public abstract class GLContext {
* Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
* for read-pixels and swap-buffers implications.
* </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
*/
public abstract int getDefaultReadBuffer();
- /** Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */
+ /**
+ * Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
+ */
public abstract int getDefaultPixelDataType();
- /** Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */
+ /**
+ * Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}.
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
+ */
public abstract int getDefaultPixelDataFormat();
/**
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
index 7ed057e..5c881ab 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java
@@ -60,8 +60,9 @@ public interface GLDrawable extends NativeSurfaceHolder {
* The GLContext <code>share</code> need not be associated with this
* GLDrawable and may be null if sharing of display lists and other
* objects is not desired. See the note in the overview
- * documentation on
- * <a href="../../../spec-overview.html#SHARING">context sharing</a>.
+ * documentation
+ * <a href="../../../overview-summary.html#SHARING">context sharing</a>
+ * as well as {@link GLSharedContextSetter}.
* </p>
*/
public GLContext createContext(GLContext shareWith);
diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
index f423e0e..a90a40e 100644
--- a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java
@@ -34,6 +34,7 @@ import com.jogamp.opengl.FBObject;
import com.jogamp.opengl.FBObject.Colorbuffer;
import com.jogamp.opengl.FBObject.ColorAttachment;
import com.jogamp.opengl.FBObject.TextureAttachment;
+import com.jogamp.opengl.GLRendererQuirks;
/**
* Platform-independent {@link GLDrawable} specialization,
@@ -77,12 +78,16 @@ import com.jogamp.opengl.FBObject.TextureAttachment;
public interface GLFBODrawable extends GLDrawable {
// public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
- /** FBO Mode Bit: Use a {@link TextureAttachment} for the {@link #getColorbuffer(int) render colorbuffer} ({@link #FBOMODE_DEFAULT default}), see {@link #setFBOMode(int)}. */
+ /** FBO Mode Bit: Use a {@link TextureAttachment} for the {@link #getColorbuffer(int) render colorbuffer}, see {@link #setFBOMode(int)}. */
public static final int FBOMODE_USE_TEXTURE = 1 << 0;
- /** FBO Mode Bit: Use a depth renderbuffer ({@link #FBOMODE_DEFAULT default}), see {@link #setFBOMode(int)}. */
+ /**
+ * @deprecated Use {@link GLCapabilities#setDepthBits(int)}, this bit is w/o function now.
+ */
public static final int FBOMODE_USE_DEPTH = 1 << 1;
- /** FBO Default Mode Bit: {@link #FBOMODE_USE_TEXTURE} | {@link #FBOMODE_USE_DEPTH}. */
+ /**
+ * @deprecated Use dedicated values, e.g. {@link #FBOMODE_USE_TEXTURE}.
+ */
public static final int FBOMODE_DEFAULT = FBOMODE_USE_TEXTURE | FBOMODE_USE_DEPTH;
/**
@@ -93,11 +98,15 @@ public interface GLFBODrawable extends GLDrawable {
/**
* Set the FBO mode bits used for FBO creation.
* <p>
- * See {@link #FBOMODE_DEFAULT} values.
+ * See {@link #FBOMODE_USE_TEXTURE}.
+ * </p>
+ * <p>
+ * If {@link GLRendererQuirks#BuggyColorRenderbuffer} is set,
+ * {@link #FBOMODE_USE_TEXTURE} is always added at initialization.
* </p>
*
- * @param modeBits custom FBO mode bits like {@link #FBOMODE_USE_TEXTURE} and {@link #FBOMODE_USE_DEPTH}.
- * @throws IllegalStateException if the underlying FBO is already {@link #isInitialized()}.
+ * @param modeBits custom FBO mode bits like {@link #FBOMODE_USE_TEXTURE}.
+ * @throws IllegalStateException if already initialized, see {@link #isInitialized()}.
*/
void setFBOMode(final int modeBits) throws IllegalStateException;
@@ -150,9 +159,9 @@ public interface GLFBODrawable extends GLDrawable {
* Must be called before {@link #isInitialized() initialization}, otherwise an exception is thrown.
* </p>
* @return the new number of buffers (FBO) used, maybe different than the requested <code>bufferCount</code> (see above)
- * @throws GLException if already initialized, see {@link #isInitialized()}.
+ * @throws IllegalStateException if already initialized, see {@link #isInitialized()}.
*/
- int setNumBuffers(final int bufferCount) throws GLException;
+ int setNumBuffers(final int bufferCount) throws /* IllegalStateException, */ GLException;
/**
* @return the number of buffers (FBO) being used. 1 if not using {@link GLCapabilities#getDoubleBuffered() double buffering},
@@ -198,8 +207,9 @@ public interface GLFBODrawable extends GLDrawable {
* </p>
* <p>
* Depending on the {@link #setFBOMode(int) fbo mode} the resulting {@link Colorbuffer}
- * is either a {@link TextureAttachment} ({@link #FBOMODE_DEFAULT default}) or a {@link ColorAttachment},
- * see {@link Colorbuffer#isTextureAttachment()}.
+ * is either a {@link TextureAttachment} if {@link #FBOMODE_USE_TEXTURE} is set,
+ * otherwise a {@link ColorAttachment}.
+ * See {@link Colorbuffer#isTextureAttachment()}.
* </p>
* @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names
* @return the named {@link Colorbuffer}
diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
index a694802..62d10d4 100644
--- a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java
@@ -39,6 +39,12 @@ import com.jogamp.opengl.FBObject;
* This class distinguishes itself from {@link GLAutoDrawable}
* with it's {@link #setSurfaceSize(int, int)} functionality.
* </p>
+ * <p>
+ * <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a>
+ * To share a {@link GLContext} see the following note in the documentation overview:
+ * <a href="../../../overview-summary.html#SHARING">context sharing</a>
+ * as well as {@link GLSharedContextSetter}.
+ * </p>
*/
public interface GLOffscreenAutoDrawable extends GLAutoDrawable, GLSharedContextSetter {
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index d39d0f1..c7aaca5 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -128,6 +128,21 @@ public class GLProfile {
}
/**
+ * @return <code>true</code> if JOGL has been initialized, i.e. manually via {@link #initSingleton()} or implicit,
+ * otherwise returns <code>false</code>.
+ *
+ * @since 2.2.1
+ */
+ public static boolean isInitialized() {
+ initLock.lock();
+ try {
+ return initialized;
+ } finally {
+ initLock.unlock();
+ }
+ }
+
+ /**
* Static initialization of JOGL.
*
* <p>
@@ -470,7 +485,7 @@ public class GLProfile {
if(null != map) {
for (final Map.Entry<String,GLProfile> entry : map.entrySet()) {
- if( !GL_DEFAULT.equals(entry.getKey()) ) {
+ if( GL_DEFAULT != entry.getKey() ) {
if(useIndent) {
doIndent(sb.append(Platform.getNewline()), indent, indentCount);
}
@@ -513,44 +528,46 @@ public class GLProfile {
/** The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.<br>
<code>bc</code> stands for backward compatibility. */
- public static final String GL4bc = "GL4bc";
+ public static final String GL4bc = "GL4bc"; // Implicitly intern(), see Bug 1059
/** The desktop OpenGL core profile 4.x, with x >= 0 */
- public static final String GL4 = "GL4";
+ public static final String GL4 = "GL4"; // Implicitly intern(), see Bug 1059
/** The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.<br>
<code>bc</code> stands for backward compatibility. */
- public static final String GL3bc = "GL3bc";
+ public static final String GL3bc = "GL3bc"; // Implicitly intern(), see Bug 1059
/** The desktop OpenGL core profile 3.x, with x >= 1 */
- public static final String GL3 = "GL3";
+ public static final String GL3 = "GL3"; // Implicitly intern(), see Bug 1059
/** The desktop OpenGL profile 1.x up to 3.0 */
- public static final String GL2 = "GL2";
+ public static final String GL2 = "GL2"; // Implicitly intern(), see Bug 1059
/** The embedded OpenGL profile ES 1.x, with x >= 0 */
- public static final String GLES1 = "GLES1";
+ public static final String GLES1 = "GLES1"; // Implicitly intern(), see Bug 1059
/** The embedded OpenGL profile ES 2.x, with x >= 0 */
- public static final String GLES2 = "GLES2";
+ public static final String GLES2 = "GLES2"; // Implicitly intern(), see Bug 1059
/** The embedded OpenGL profile ES 3.x, with x >= 0 */
- public static final String GLES3 = "GLES3";
+ public static final String GLES3 = "GLES3"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL2 and embedded ES1 profile */
- public static final String GL2ES1 = "GL2ES1";
+ public static final String GL2ES1 = "GL2ES1"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL3, GL2 and embedded ES2 profile */
- public static final String GL2ES2 = "GL2ES2";
+ public static final String GL2ES2 = "GL2ES2"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL3 and GL2 profile */
- public static final String GL2GL3 = "GL2GL3";
+ public static final String GL2GL3 = "GL2GL3"; // Implicitly intern(), see Bug 1059
/** The intersection of the desktop GL4 and ES3 profile, available only if either ES3 or GL4 w/ <code>GL_ARB_ES3_compatibility</code> is available. */
- public static final String GL4ES3 = "GL4ES3";
+ public static final String GL4ES3 = "GL4ES3"; // Implicitly intern(), see Bug 1059
/** The default profile, used for the device default profile map */
- private static final String GL_DEFAULT = "GL_DEFAULT";
+ private static final String GL_DEFAULT = "GL_DEFAULT"; // Implicitly intern(), see Bug 1059
+ /** The default profile, used for the device default profile map */
+ private static final String GL_GL = "GL"; // Implicitly intern(), see Bug 1059
/**
* All GL Profiles in the order of default detection.
@@ -936,7 +953,7 @@ public class GLProfile {
public static GLProfile get(final AbstractGraphicsDevice device, String profile)
throws GLException
{
- if(null==profile || profile.equals("GL")) {
+ if(null==profile || profile == GL_GL) {
profile = GL_DEFAULT;
}
final HashMap<String /*GLProfile_name*/, GLProfile> glpMap = getProfileMap(device, true);
@@ -1008,21 +1025,21 @@ public class GLProfile {
* This requires an EGL interface.
*/
public static boolean usesNativeGLES1(final String profileImpl) {
- return GLES1.equals(profileImpl);
+ return GLES1 == profileImpl;
}
/** Indicates whether the native OpenGL ES3 or ES2 profile is in use.
* This requires an EGL, ES3 or ES2 compatible interface.
*/
public static boolean usesNativeGLES2(final String profileImpl) {
- return GLES3.equals(profileImpl) || GLES2.equals(profileImpl);
+ return GLES3 == profileImpl || GLES2 == profileImpl;
}
/** Indicates whether the native OpenGL ES2 profile is in use.
* This requires an EGL, ES3 compatible interface.
*/
public static boolean usesNativeGLES3(final String profileImpl) {
- return GLES3.equals(profileImpl);
+ return GLES3 == profileImpl;
}
/** Indicates whether either of the native OpenGL ES profiles are in use. */
@@ -2039,99 +2056,116 @@ public class GLProfile {
* Returns the profile implementation
*/
private static String computeProfileImpl(final AbstractGraphicsDevice device, final String profile, final boolean desktopCtxUndef, final boolean esCtxUndef, final boolean isHardwareRasterizer[]) {
- if (GL2ES1.equals(profile)) {
- final boolean es1HardwareRasterizer[] = new boolean[1];
- final boolean gles1Available = hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, es1HardwareRasterizer) );
- final boolean gles1HWAvailable = gles1Available && es1HardwareRasterizer[0] ;
+ final boolean hardwareRasterizer[] = new boolean[1];
+ if ( GL2ES1 == profile ) {
+ final boolean gles1Available;
+ final boolean gles1HWAvailable;
+ if( hasGLES1Impl ) {
+ gles1Available = esCtxUndef || GLContext.isGLES1Available(device, hardwareRasterizer);
+ gles1HWAvailable = gles1Available && hardwareRasterizer[0] ;
+ } else {
+ gles1Available = false;
+ gles1HWAvailable = false;
+ }
if(hasGL234Impl) {
- if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
- if(!gles1HWAvailable || isHardwareRasterizer[0]) {
- return GL4bc;
- }
+ final boolean gl3bcAvailable = GLContext.isGL3bcAvailable(device, hardwareRasterizer);
+ final boolean gl3bcHWAvailable = gl3bcAvailable && hardwareRasterizer[0] ;
+ final boolean gl2Available = GLContext.isGL2Available(device, hardwareRasterizer);
+ final boolean gl2HWAvailable = gl2Available && hardwareRasterizer[0] ;
+ final boolean glAnyHWAvailable = gl3bcHWAvailable || gl2HWAvailable ||
+ gles1HWAvailable ;
+
+ if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer) &&
+ ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
+ return GL4bc;
}
- if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
- if(!gles1HWAvailable || isHardwareRasterizer[0]) {
- return GL3bc;
- }
+ if( gl3bcAvailable && ( gl3bcHWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl3bcHWAvailable;
+ return GL3bc;
}
- if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) {
- if(!gles1HWAvailable || isHardwareRasterizer[0]) {
- return GL2;
- }
+ if( ( desktopCtxUndef || gl2Available ) && ( gl2HWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl2HWAvailable;
+ return GL2;
}
}
- if(gles1Available) {
- isHardwareRasterizer[0] = es1HardwareRasterizer[0];
+ if( gles1Available ) {
+ isHardwareRasterizer[0] = gles1HWAvailable;
return GLES1;
}
- } else if (GL2ES2.equals(profile)) {
- final boolean es2HardwareRasterizer[] = new boolean[1];
- final boolean gles2Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, es2HardwareRasterizer) );
- final boolean gles2HWAvailable = gles2Available && es2HardwareRasterizer[0] ;
- final boolean es3HardwareRasterizer[] = new boolean[1];
- final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) );
- final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ;
- if(hasGL234Impl) {
- if(GLContext.isGL4Available(device, isHardwareRasterizer)) {
- if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) {
- return GL4;
- }
+ } else if ( GL2ES2 == profile ) {
+ final boolean gles2Available, gles3Available;
+ final boolean gles2HWAvailable, gles3HWAvailable;
+ if( hasGLES3Impl ) {
+ gles2Available = esCtxUndef || GLContext.isGLES2Available(device, hardwareRasterizer);
+ gles2HWAvailable = gles2Available && hardwareRasterizer[0] ;
+ gles3Available = esCtxUndef || GLContext.isGLES3Available(device, hardwareRasterizer);
+ gles3HWAvailable = gles3Available && hardwareRasterizer[0] ;
+ } else {
+ gles2Available = false;
+ gles2HWAvailable = false;
+ gles3Available = false;
+ gles3HWAvailable = false;
+ }
+ if( hasGL234Impl ) {
+ final boolean gl4bcAvailable = GLContext.isGL4bcAvailable(device, hardwareRasterizer);
+ final boolean gl4bcHWAvailable = gl4bcAvailable && hardwareRasterizer[0] ;
+ final boolean gl3Available = GLContext.isGL3Available(device, hardwareRasterizer);
+ final boolean gl3HWAvailable = gl3Available && hardwareRasterizer[0] ;
+ final boolean gl3bcAvailable = GLContext.isGL3bcAvailable(device, hardwareRasterizer);
+ final boolean gl3bcHWAvailable = gl3bcAvailable && hardwareRasterizer[0] ;
+ final boolean gl2Available = GLContext.isGL2Available(device, hardwareRasterizer);
+ final boolean gl2HWAvailable = gl2Available && hardwareRasterizer[0] ;
+ final boolean glAnyHWAvailable = gl4bcHWAvailable || gl3HWAvailable || gl3bcHWAvailable || gl2HWAvailable ||
+ gles3HWAvailable || gles2HWAvailable ;
+
+ if( GLContext.isGL4Available(device, isHardwareRasterizer) &&
+ ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
+ return GL4;
}
- if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
- if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) {
- return GL4bc;
- }
+ if( gl4bcAvailable && ( gl4bcHWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl4bcHWAvailable;
+ return GL4bc;
}
- if(GLContext.isGL3Available(device, isHardwareRasterizer)) {
- if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) {
- return GL3;
- }
+ if( gl3Available && ( gl3HWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl3HWAvailable;
+ return GL3;
}
- if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
- if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) {
- return GL3bc;
- }
+ if( gl3bcAvailable && ( gl3bcHWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl3bcHWAvailable;
+ return GL3bc;
}
- if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) {
- if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) {
- return GL2;
- }
+ if( ( desktopCtxUndef || gl2Available ) && ( gl2HWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl2HWAvailable;
+ return GL2;
}
}
- if(gles3Available && ( !gles2HWAvailable || gles3HWAvailable ) ) {
- isHardwareRasterizer[0] = es3HardwareRasterizer[0];
+ if( gles3Available && ( gles3HWAvailable || !gles2HWAvailable ) ) {
+ isHardwareRasterizer[0] = gles3HWAvailable;
return GLES3;
}
- if(gles2Available) {
- isHardwareRasterizer[0] = es2HardwareRasterizer[0];
+ if( gles2Available ) {
+ isHardwareRasterizer[0] = gles2HWAvailable;
return GLES2;
}
- } else if (GL4ES3.equals(profile)) {
+ } else if (GL4ES3 == profile) {
final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(device);
if( desktopCtxUndef || esCtxUndef || gles3CompatAvail ) {
final boolean es3HardwareRasterizer[] = new boolean[1];
final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) );
final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ;
- if(hasGL234Impl) {
- if(GLContext.isGL4Available(device, isHardwareRasterizer)) {
- if(!gles3HWAvailable || isHardwareRasterizer[0]) {
- return GL4;
- }
- }
- if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
- if(!gles3HWAvailable || isHardwareRasterizer[0]) {
- return GL4bc;
- }
- }
- if(GLContext.isGL3Available(device, isHardwareRasterizer)) {
- if(!gles3HWAvailable || isHardwareRasterizer[0]) {
- return GL3;
- }
+ if( hasGL234Impl ) {
+ final boolean gl4bcAvailable = GLContext.isGL4bcAvailable(device, hardwareRasterizer);
+ final boolean gl4bcHWAvailable = gl4bcAvailable && hardwareRasterizer[0] ;
+ final boolean glAnyHWAvailable = gl4bcHWAvailable ||
+ gles3HWAvailable;
+
+ if( GLContext.isGL4Available(device, isHardwareRasterizer) &&
+ ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
+ return GL4;
}
- if( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
- if(!gles3HWAvailable || isHardwareRasterizer[0]) {
- return GL3bc;
- }
+ if( ( desktopCtxUndef || gl4bcAvailable ) && ( gl4bcHWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl4bcHWAvailable;
+ return GL4bc;
}
}
if(gles3Available) {
@@ -2139,35 +2173,54 @@ public class GLProfile {
return GLES3;
}
}
- } else if(GL2GL3.equals(profile)) {
+ } else if(GL2GL3 == profile) {
if(hasGL234Impl) {
- if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) {
+ final boolean gl4Available = GLContext.isGL4Available(device, hardwareRasterizer);
+ final boolean gl4HWAvailable = gl4Available && hardwareRasterizer[0] ;
+ final boolean gl3Available = GLContext.isGL3Available(device, hardwareRasterizer);
+ final boolean gl3HWAvailable = gl3Available && hardwareRasterizer[0] ;
+ final boolean gl3bcAvailable = GLContext.isGL3bcAvailable(device, hardwareRasterizer);
+ final boolean gl3bcHWAvailable = gl3bcAvailable && hardwareRasterizer[0] ;
+ final boolean gl2Available = GLContext.isGL2Available(device, hardwareRasterizer);
+ final boolean gl2HWAvailable = gl2Available && hardwareRasterizer[0] ;
+ final boolean glAnyHWAvailable = gl4HWAvailable || gl3HWAvailable || gl3bcHWAvailable || gl2HWAvailable;
+
+ if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer) &&
+ ( isHardwareRasterizer[0] || !glAnyHWAvailable ) ) {
return GL4bc;
- } else if( GLContext.isGL4Available(device, isHardwareRasterizer)) {
+ }
+ if( gl4Available && ( gl4HWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl4HWAvailable;
return GL4;
- } else if( GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) {
+ }
+ if( gl3bcAvailable && ( gl3bcHWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl3bcHWAvailable;
return GL3bc;
- } else if( GLContext.isGL3Available(device, isHardwareRasterizer)) {
+ }
+ if( gl3Available && ( gl3HWAvailable || !glAnyHWAvailable ) ) {
+ isHardwareRasterizer[0] = gl3HWAvailable;
return GL3;
- } else if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) {
+ }
+ if( desktopCtxUndef || gl2Available ) {
+ isHardwareRasterizer[0] = gl2HWAvailable;
return GL2;
}
}
- } else if(GL4bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) {
+ } else if(GL4bc == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL4bc : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_COMPAT);
- } else if(GL4.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) {
+ } else if(GL4 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL4 : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_CORE);
- } else if(GL3bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) {
+ } else if(GL3bc == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL3bc : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_COMPAT);
- } else if(GL3.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) {
+ } else if(GL3 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_CORE);
- } else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) {
+ } else if(GL2 == profile && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) {
return desktopCtxUndef ? GL2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_COMPAT);
- } else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) {
+ } else if(GLES3 == profile && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) {
return esCtxUndef ? GLES3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_ES);
- } else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) {
+ } else if(GLES2 == profile && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) {
return esCtxUndef ? GLES2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_ES);
- } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) {
+ } else if(GLES1 == profile && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) {
return esCtxUndef ? GLES1 : GLContext.getAvailableGLProfileName(device, 1, GLContext.CTX_PROFILE_ES);
}
return null;
diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
index 679898d..b8aef12 100644
--- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
+++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java
@@ -28,6 +28,8 @@
package javax.media.opengl;
+import com.jogamp.opengl.GLRendererQuirks;
+
/**
* Adds capabilities to set a shared {@link GLContext} directly or via an {@link GLAutoDrawable}.
* <p>
@@ -35,9 +37,12 @@ package javax.media.opengl;
* and textures among OpenGL contexts is supported with this interface.
* </p>
* <p>
- * A <i>master</i> {@link GLContext} is the {@link GLContext} which is created first,
- * shared {@link GLContext} w/ this master are referred as slave {@link GLContext}
- * and controls the shared object's lifecycle, i.e. their construction and destruction.
+ * A <i>master</i> {@link GLContext} is the {@link GLContext} which is created first.
+ * Subsequent shared {@link GLContext} w/ the <i>master</i> are referred as <i>slave</i> {@link GLContext}.
+ * </p>
+ * <p>
+ * Implementations of this interface control the <i>slave's</i> {@link GLContext} and {@link GLAutoDrawable} realization,
+ * i.e. the <i>slave</i> {@link GLAutoDrawable} will not be realized before their associated <i>master</i>.
* </p>
* <p>
* Using the nearest or same {@link GLCapabilitiesImmutable#getVisualID(javax.media.nativewindow.VisualIDHolder.VIDType) visual ID}
@@ -50,12 +55,17 @@ package javax.media.opengl;
* At least this has been experienced w/ OSX 10.9.
* </p>
* <p>
- * Be aware that the <i>master</i> {@link GLContext} and related resources
- * <i>shall not</i> be destroyed before it's <i>slave</i> {@link GLContext} instances <i>while they are using them</i>.<br>
- * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV, since using already destroyed resources,
- * e.g. OpenGL buffer objects, may not be validated by the driver!<br>
+ * In general, destroying a <i>master</i> {@link GLContext} before their shared <i>slaves</i>
+ * shall be permissible, i.e. the OpenGL driver needs to handle pending destruction of shared resources.
+ * This is confirmed to work properly on most platform/driver combinations,
+ * see unit test <code>com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3</code> and similar.
* </p>
* <p>
+ * However, to avoid scenarios with buggy drivers, users <i>may not</i> destroy the
+ * <i>master</i> {@link GLContext} before its shared <i>slave</i> {@link GLContext} instances
+ * <i>as long as they are using them</i>.<br>
+ * Otherwise the OpenGL driver may crash w/ SIGSEGV, due to using already destroyed shared resources,
+ * if not handling the pending destruction of the latter!<br>
* Either proper lifecycle synchronization is implemented, e.g. by notifying the <i>slaves</i> about the loss of the shared resources,
* <i>or</i> the <i>slaves</i> validate whether the resources are still valid.
* </p>
@@ -80,6 +90,20 @@ package javax.media.opengl;
glad.setVisible(true); // GLWindow creation ..
* </pre>
* </p>
+ * <h5><a name="synchronization">GL Object Synchronization</a></h5>
+ * <p>
+ * Usually synchronization of shared GL objects should not be required, if the shared GL objects
+ * are created and immutable before concurrent usage.
+ * </p>
+ * <p>
+ * However, using drivers exposing {@link GLRendererQuirks#NeedSharedObjectSync} always
+ * require the user to synchronize access of shared GL objects.
+ * </p>
+ * <p>
+ * Synchronization can be avoided if accessing the shared GL objects
+ * exclusively via a queue or {@link com.jogamp.common.util.Ringbuffer Ringbuffer}, see GLMediaPlayerImpl as an example.
+ * </p>
+ * </p>
* <h5><a name="driverissues">Known Driver Issues</a></h5>
* <h7><a name="intelmesa">Intel's Mesa >= 9.1.2 Backend for [Sandybridge/Ivybridge] on GNU/Linux</a></h7>
* <p>
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index dba1dbc..a648e3b 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -82,6 +82,7 @@ import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
import javax.media.opengl.GLSharedContextSetter;
@@ -156,10 +157,12 @@ import jogamp.opengl.awt.AWTTilePainter;
* <li><pre>sun.awt.noerasebackground=true</pre></li>
* </ul>
*
+ * <p>
* <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a>
* To share a {@link GLContext} see the following note in the documentation overview:
- * <a href="../../../spec-overview.html#SHARING">context sharing</a>
+ * <a href="../../../../overview-summary.html#SHARING">context sharing</a>
* as well as {@link GLSharedContextSetter}.
+ * </p>
*/
@SuppressWarnings("serial")
@@ -840,68 +843,85 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
private final Runnable setupPrintOnEDT = new Runnable() {
@Override
public void run() {
- if( !validateGLDrawable() ) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet");
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ if( !validateGLDrawable() ) {
+ if(DEBUG) {
+ System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet");
+ }
+ printActive = false;
+ return; // not yet available ..
}
- printActive = false;
- return; // not yet available ..
- }
- if( !isVisible() ) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, canvas not visible");
+ if( !isVisible() ) {
+ if(DEBUG) {
+ System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, canvas not visible");
+ }
+ printActive = false;
+ return; // not yet available ..
}
- printActive = false;
- return; // not yet available ..
- }
- sendReshape = false; // clear reshape flag
- printAnimator = helper.getAnimator();
- if( null != printAnimator ) {
- printAnimator.remove(GLCanvas.this);
- }
- printGLAD = GLCanvas.this; // _not_ default, shall be replaced by offscreen GLAD
- final GLCapabilitiesImmutable gladCaps = getChosenGLCapabilities();
- final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
- GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
- final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
- final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
- printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
- final boolean reqNewGLADOnscrn = gladCaps.isOnscreen();
-
- final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
- newGLADCaps.setDoubleBuffered(false);
- newGLADCaps.setOnscreen(false);
- if( printNumSamples != newGLADCaps.getNumSamples() ) {
- newGLADCaps.setSampleBuffers(0 < printNumSamples);
- newGLADCaps.setNumSamples(printNumSamples);
- }
- final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(getRequestedGLCapabilities(), gladCaps, newGLADCaps);
+ sendReshape = false; // clear reshape flag
+ printAnimator = helper.getAnimator();
+ if( null != printAnimator ) {
+ printAnimator.remove(GLCanvas.this);
+ }
+ printGLAD = GLCanvas.this; // _not_ default, shall be replaced by offscreen GLAD
+ final GLCapabilitiesImmutable gladCaps = getChosenGLCapabilities();
+ final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
+ GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
+ final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
+ final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
+ printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
+ final boolean reqNewGLADOnscrn = gladCaps.isOnscreen();
+
+ final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
+ newGLADCaps.setDoubleBuffered(false);
+ newGLADCaps.setOnscreen(false);
+ if( printNumSamples != newGLADCaps.getNumSamples() ) {
+ newGLADCaps.setSampleBuffers(0 < printNumSamples);
+ newGLADCaps.setNumSamples(printNumSamples);
+ }
+ final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(getRequestedGLCapabilities(), gladCaps, newGLADCaps);
- final boolean reqNewGLAD = ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
+ final boolean reqNewGLAD = ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
- if( DEBUG ) {
- System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
- ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
- ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
- ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
- ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
- }
- if( reqNewGLAD ) {
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
- printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
- printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
- GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD);
- printDrawable = printGLAD.getDelegatedDrawable();
- }
- printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented());
- printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);
- printAWTTiles.renderer.attachAutoDrawable(printGLAD);
- if( DEBUG ) {
- System.err.println("AWT print.setup "+printAWTTiles);
- System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
- System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
- System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
+ if( DEBUG ) {
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
+ ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
+ }
+ if( reqNewGLAD ) {
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
+ GLOffscreenAutoDrawable offGLAD = null;
+ try {
+ offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
+ } catch (final GLException gle) {
+ if( DEBUG ) {
+ System.err.println("Caught: "+gle.getMessage());
+ gle.printStackTrace();
+ }
+ }
+ if( null != offGLAD ) {
+ printGLAD = offGLAD;
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
+ }
+ }
+ printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented());
+ printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);
+ printAWTTiles.renderer.attachAutoDrawable(printGLAD);
+ if( DEBUG ) {
+ System.err.println("AWT print.setup "+printAWTTiles);
+ System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
+ System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
+ System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
+ }
+ } finally {
+ _lock.unlock();
}
}
};
@@ -917,23 +937,29 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
private final Runnable releasePrintOnEDT = new Runnable() {
@Override
public void run() {
- if( DEBUG ) {
- System.err.println("AWT print.release "+printAWTTiles);
- }
- printAWTTiles.dispose();
- printAWTTiles= null;
- if( printGLAD != GLCanvas.this ) {
- GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLCanvas.this);
- printGLAD.destroy();
- }
- printGLAD = null;
- if( null != printAnimator ) {
- printAnimator.add(GLCanvas.this);
- printAnimator = null;
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ if( DEBUG ) {
+ System.err.println("AWT print.release "+printAWTTiles);
+ }
+ printAWTTiles.dispose();
+ printAWTTiles= null;
+ if( printGLAD != GLCanvas.this ) {
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLCanvas.this);
+ printGLAD.destroy();
+ }
+ printGLAD = null;
+ if( null != printAnimator ) {
+ printAnimator.add(GLCanvas.this);
+ printAnimator = null;
+ }
+ sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
+ printActive = false;
+ display();
+ } finally {
+ _lock.unlock();
}
- sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
- printActive = false;
- display();
}
};
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 1682c6d..a096449 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -78,6 +78,7 @@ import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLFBODrawable;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
import javax.media.opengl.GLSharedContextSetter;
@@ -173,10 +174,12 @@ import com.jogamp.opengl.util.texture.TextureState;
It is recommended to reset those states to default when leaving the {@link GLEventListener#display(GLAutoDrawable)} method!
We may change this behavior in the future, i.e. preserve all influencing states.
</p>
+ <p>
<a name="contextSharing"><h5>OpenGL Context Sharing</h5></a>
To share a {@link GLContext} see the following note in the documentation overview:
- <a href="../../../spec-overview.html#SHARING">context sharing</a>
+ <a href="../../../../overview-summary.html#SHARING">context sharing</a>
as well as {@link GLSharedContextSetter}.
+ </p>
*/
@SuppressWarnings("serial")
@@ -237,7 +240,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return singleAWTGLPixelBufferProvider;
}
- /** Currently not used internally, exist merely to satisfy {@link #getUpstreamLock()}. */
private final RecursiveLock lock = LockFactory.createRecursiveLock();
private final GLDrawableHelper helper;
@@ -250,9 +252,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
//
private AWTGLPixelBufferProvider customPixelBufferProvider = null;
/** Requested single buffered offscreen caps */
- private final GLCapabilitiesImmutable reqOffscreenCaps;
- private final GLProfile glProfile;
- private final GLDrawableFactoryImpl factory;
+ private volatile GLCapabilitiesImmutable reqOffscreenCaps;
+ private volatile GLDrawableFactoryImpl factory;
private final GLCapabilitiesChooser chooser;
private int additionalCtxCreationFlags = 0;
@@ -359,8 +360,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
caps.setDoubleBuffered(false);
reqOffscreenCaps = caps;
}
- this.glProfile = reqOffscreenCaps.getGLProfile();
- this.factory = GLDrawableFactoryImpl.getFactoryImpl(glProfile);
+ this.factory = GLDrawableFactoryImpl.getFactoryImpl( reqOffscreenCaps.getGLProfile() ); // pre-fetch, reqOffscreenCaps may changed
this.chooser = chooser;
helper = new GLDrawableHelper();
@@ -463,17 +463,25 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
}
+ /**
+ * @deprecated Use {@link #dispose(Runnable)}.
+ */
protected void dispose() {
+ dispose(null);
+ }
+ protected void dispose(final Runnable post) {
if(DEBUG) {
System.err.println(getThreadName()+": GLJPanel.dispose() - start");
// Thread.dumpStack();
}
if (backend != null && backend.getContext() != null) {
- boolean animatorPaused = false;
+ final boolean animatorPaused;
final GLAnimatorControl animator = getAnimator();
if(null!=animator) {
animatorPaused = animator.pause();
+ } else {
+ animatorPaused = false;
}
if(backend.getContext().isCreated()) {
@@ -484,15 +492,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
backend.destroy();
isInitialized = false;
}
+ if( null != post ) {
+ post.run();
+ }
- if(animatorPaused) {
+ if( animatorPaused ) {
animator.resume();
}
}
- hasPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- hasPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
- nativePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
- nativePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
if(DEBUG) {
System.err.println(getThreadName()+": GLJPanel.dispose() - stop");
@@ -536,28 +543,34 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return;
}
- if( !isInitialized ) {
- initializeBackendImpl();
- }
-
- if (!isInitialized || printActive) {
- return;
- }
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ if( !isInitialized ) {
+ initializeBackendImpl();
+ }
- // NOTE: must do this when the context is not current as it may
- // involve destroying the pbuffer (current context) and
- // re-creating it -- tricky to do properly while the context is
- // current
- if( !printActive ) {
- if (handleReshape) {
- handleReshape = false;
- sendReshape = handleReshape();
+ if (!isInitialized || printActive) {
+ return;
}
- if( isShowing ) {
- updater.setGraphics(g);
- backend.doPaintComponent(g);
+ // NOTE: must do this when the context is not current as it may
+ // involve destroying the pbuffer (current context) and
+ // re-creating it -- tricky to do properly while the context is
+ // current
+ if( !printActive ) {
+ if ( handleReshape ) {
+ handleReshape = false;
+ sendReshape = handleReshape();
+ }
+
+ if( isShowing ) {
+ updater.setGraphics(g);
+ backend.doPaintComponent(g);
+ }
}
+ } finally {
+ _lock.unlock();
}
}
@@ -636,7 +649,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
public void removeNotify() {
awtWindowClosingProtocol.removeClosingListener();
- dispose();
+ dispose(null);
+ hasPixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
+ hasPixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
+ nativePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
+ nativePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;
+
super.removeNotify();
}
@@ -657,18 +675,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private void reshapeImpl(final int width, final int height) {
final int scaledWidth = width * hasPixelScale[0];
final int scaledHeight = height * hasPixelScale[1];
- if( DEBUG ) {
- System.err.println(getThreadName()+": GLJPanel.reshape.0 "+this.getName()+" resize"+(printActive?"WithinPrint":"")+
- " [ this "+getWidth()+"x"+getHeight()+", pixelScale "+getPixelScaleStr()+
- ", panel "+panelWidth+"x"+panelHeight +
- ", reshape: " +reshapeWidth+"x"+reshapeHeight +
- "] -> "+(printActive?"[skipped] ":"") + width+"x"+height+" * "+getPixelScaleStr()+" -> "+scaledWidth+"x"+scaledHeight);
- }
- if( !printActive ) {
+ if( !printActive && ( handleReshape || scaledWidth != panelWidth || scaledHeight != panelHeight ) ) {
reshapeWidth = scaledWidth;
reshapeHeight = scaledHeight;
handleReshape = true;
}
+ if( DEBUG ) {
+ System.err.println(getThreadName()+": GLJPanel.reshape.0 "+this.getName()+" resize ["+(printActive?"printing":"paint")+
+ "] [ this "+getWidth()+"x"+getHeight()+", pixelScale "+getPixelScaleStr()+
+ ", panel "+panelWidth+"x"+panelHeight +
+ "] -> "+(handleReshape?"":"[skipped] ") + width+"x"+height+" * "+getPixelScaleStr()+
+ " -> "+scaledWidth+"x"+scaledHeight+", reshapeSize "+reshapeWidth+"x"+reshapeHeight);
+ }
}
private volatile boolean printActive = false;
@@ -679,6 +697,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public void setupPrint(final double scaleMatX, final double scaleMatY, final int numSamples, final int tileWidth, final int tileHeight) {
printActive = true;
+ if( DEBUG ) {
+ System.err.printf(getThreadName()+": GLJPanel.setupPrint: scale %f / %f, samples %d, tileSz %d x %d%n", scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight);
+ }
final int componentCount = isOpaque() ? 3 : 4;
final TileRenderer printRenderer = new TileRenderer();
printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG);
@@ -687,72 +708,89 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private final Runnable setupPrintOnEDT = new Runnable() {
@Override
public void run() {
- if( !isInitialized ) {
- initializeBackendImpl();
- }
- if (!isInitialized) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet");
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ if( !isInitialized ) {
+ initializeBackendImpl();
}
- printActive = false;
- return; // not yet available ..
- }
- if( !isVisible() ) {
- if(DEBUG) {
- System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, panel not visible");
+ if (!isInitialized) {
+ if(DEBUG) {
+ System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet");
+ }
+ printActive = false;
+ return; // not yet available ..
+ }
+ if( !isVisible() ) {
+ if(DEBUG) {
+ System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, panel not visible");
+ }
+ printActive = false;
+ return; // not yet available ..
+ }
+ sendReshape = false; // clear reshape flag
+ handleReshape = false; // ditto
+ printAnimator = helper.getAnimator();
+ if( null != printAnimator ) {
+ printAnimator.remove(GLJPanel.this);
}
- printActive = false;
- return; // not yet available ..
- }
- sendReshape = false; // clear reshape flag
- handleReshape = false; // ditto
- printAnimator = helper.getAnimator();
- if( null != printAnimator ) {
- printAnimator.remove(GLJPanel.this);
- }
- printGLAD = GLJPanel.this; // default: re-use
- final GLCapabilitiesImmutable gladCaps = getChosenGLCapabilities();
- final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
- GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
- final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
- final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
- printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
-
- final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
- newGLADCaps.setDoubleBuffered(false);
- newGLADCaps.setOnscreen(false);
- if( printNumSamples != newGLADCaps.getNumSamples() ) {
- newGLADCaps.setSampleBuffers(0 < printNumSamples);
- newGLADCaps.setNumSamples(printNumSamples);
- }
- final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(getRequestedGLCapabilities(), gladCaps, newGLADCaps);
+ printGLAD = GLJPanel.this; // default: re-use
+ final GLCapabilitiesImmutable gladCaps = getChosenGLCapabilities();
+ final int printNumSamples = printAWTTiles.getNumSamples(gladCaps);
+ GLDrawable printDrawable = printGLAD.getDelegatedDrawable();
+ final boolean reqNewGLADSamples = printNumSamples != gladCaps.getNumSamples();
+ final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getSurfaceWidth() ||
+ printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getSurfaceHeight();
+
+ final GLCapabilities newGLADCaps = (GLCapabilities)gladCaps.cloneMutable();
+ newGLADCaps.setDoubleBuffered(false);
+ newGLADCaps.setOnscreen(false);
+ if( printNumSamples != newGLADCaps.getNumSamples() ) {
+ newGLADCaps.setSampleBuffers(0 < printNumSamples);
+ newGLADCaps.setNumSamples(printNumSamples);
+ }
+ final boolean reqNewGLADSafe = GLDrawableUtil.isSwapGLContextSafe(getRequestedGLCapabilities(), gladCaps, newGLADCaps);
- final boolean reqNewGLAD = ( reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
+ final boolean reqNewGLAD = ( reqNewGLADSamples || reqNewGLADSize ) && reqNewGLADSafe;
- if( DEBUG ) {
- System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
- ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
- ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
- ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
- ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
- }
- if( reqNewGLAD ) {
- final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
- printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
- printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
- GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
- printDrawable = printGLAD.getDelegatedDrawable();
- }
- printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() );
- printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);
- printAWTTiles.renderer.attachAutoDrawable(printGLAD);
- if( DEBUG ) {
- System.err.println("AWT print.setup "+printAWTTiles);
- System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
- System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
- System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
+ if( DEBUG ) {
+ System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+", safe "+reqNewGLADSafe+"], "+
+ ", drawableSize "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+
+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+
+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+
+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator);
+ }
+ if( reqNewGLAD ) {
+ final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
+ GLOffscreenAutoDrawable offGLAD = null;
+ try {
+ offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
+ } catch (final GLException gle) {
+ if( DEBUG ) {
+ System.err.println("Caught: "+gle.getMessage());
+ gle.printStackTrace();
+ }
+ }
+ if( null != offGLAD ) {
+ printGLAD = offGLAD;
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
+ }
+ }
+ printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() );
+ printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);
+ printAWTTiles.renderer.attachAutoDrawable(printGLAD);
+ if( DEBUG ) {
+ System.err.println("AWT print.setup "+printAWTTiles);
+ System.err.println("AWT print.setup AA "+printNumSamples+", "+newGLADCaps);
+ System.err.println("AWT print.setup printGLAD: "+printGLAD.getSurfaceWidth()+"x"+printGLAD.getSurfaceHeight()+", "+printGLAD);
+ System.err.println("AWT print.setup printDraw: "+printDrawable.getSurfaceWidth()+"x"+printDrawable.getSurfaceHeight()+", "+printDrawable);
+ }
+ } finally {
+ _lock.unlock();
}
}
};
@@ -770,43 +808,49 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private final Runnable releasePrintOnEDT = new Runnable() {
@Override
public void run() {
- if( DEBUG ) {
- System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0 "+printAWTTiles);
- }
- printAWTTiles.dispose();
- printAWTTiles= null;
- if( printGLAD != GLJPanel.this ) {
- GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLJPanel.this);
- printGLAD.destroy();
- }
- printGLAD = null;
- if( null != printAnimator ) {
- printAnimator.add(GLJPanel.this);
- printAnimator = null;
- }
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ if( DEBUG ) {
+ System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0 "+printAWTTiles);
+ }
+ printAWTTiles.dispose();
+ printAWTTiles= null;
+ if( printGLAD != GLJPanel.this ) {
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLJPanel.this);
+ printGLAD.destroy();
+ }
+ printGLAD = null;
+ if( null != printAnimator ) {
+ printAnimator.add(GLJPanel.this);
+ printAnimator = null;
+ }
- // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
- final int awtWidth = GLJPanel.this.getWidth();
- final int awtHeight= GLJPanel.this.getHeight();
- final int scaledAWTWidth = awtWidth * hasPixelScale[0];
- final int scaledAWTHeight= awtHeight * hasPixelScale[1];
- final GLDrawable drawable = GLJPanel.this.getDelegatedDrawable();
- if( scaledAWTWidth != panelWidth || scaledAWTHeight != panelHeight ||
- drawable.getSurfaceWidth() != panelWidth || drawable.getSurfaceHeight() != panelHeight ) {
- // -> !( awtSize == panelSize == drawableSize )
- if ( DEBUG ) {
- System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: resizeWithinPrint panel " +panelWidth+"x"+panelHeight + " @ scale "+getPixelScaleStr()+
- ", draw "+drawable.getSurfaceWidth()+"x"+drawable.getSurfaceHeight()+
- " -> " + awtWidth+"x"+awtHeight+" * "+getPixelScaleStr()+" -> "+scaledAWTWidth+"x"+scaledAWTHeight);
+ // trigger reshape, i.e. gl-viewport and -listener - this component might got resized!
+ final int awtWidth = GLJPanel.this.getWidth();
+ final int awtHeight= GLJPanel.this.getHeight();
+ final int scaledAWTWidth = awtWidth * hasPixelScale[0];
+ final int scaledAWTHeight= awtHeight * hasPixelScale[1];
+ final GLDrawable drawable = GLJPanel.this.getDelegatedDrawable();
+ if( scaledAWTWidth != panelWidth || scaledAWTHeight != panelHeight ||
+ drawable.getSurfaceWidth() != panelWidth || drawable.getSurfaceHeight() != panelHeight ) {
+ // -> !( awtSize == panelSize == drawableSize )
+ if ( DEBUG ) {
+ System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: resize [printing] panel " +panelWidth+"x"+panelHeight + " @ scale "+getPixelScaleStr()+
+ ", draw "+drawable.getSurfaceWidth()+"x"+drawable.getSurfaceHeight()+
+ " -> " + awtWidth+"x"+awtHeight+" * "+getPixelScaleStr()+" -> "+scaledAWTWidth+"x"+scaledAWTHeight);
+ }
+ reshapeWidth = scaledAWTWidth;
+ reshapeHeight = scaledAWTHeight;
+ sendReshape = handleReshape(); // reshapeSize -> panelSize, backend reshape w/ GL reshape
+ } else {
+ sendReshape = true; // only GL reshape
}
- reshapeWidth = scaledAWTWidth;
- reshapeHeight = scaledAWTHeight;
- sendReshape = handleReshape(); // reshapeSize -> panelSize, backend reshape w/ GL reshape
- } else {
- sendReshape = true; // only GL reshape
+ printActive = false;
+ display();
+ } finally {
+ _lock.unlock();
}
- printActive = false;
- display();
}
};
@@ -964,11 +1008,17 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public GLContext createContext(final GLContext shareWith) {
- final Backend b = backend;
- if ( null == b ) {
- return null;
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ final Backend b = backend;
+ if ( null == b ) {
+ return null;
+ }
+ return b.createContext(shareWith);
+ } finally {
+ _lock.unlock();
}
- return b.createContext(shareWith);
}
@Override
@@ -982,14 +1032,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public GLContext setContext(final GLContext newCtx, final boolean destroyPrevCtx) {
- final Backend b = backend;
- if ( null == b ) {
- return null;
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ final Backend b = backend;
+ if ( null == b ) {
+ return null;
+ }
+ final GLContext oldCtx = b.getContext();
+ GLDrawableHelper.switchContext(b.getDrawable(), oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags);
+ b.setContext(newCtx);
+ return oldCtx;
+ } finally {
+ _lock.unlock();
}
- final GLContext oldCtx = b.getContext();
- GLDrawableHelper.switchContext(b.getDrawable(), oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags);
- b.setContext(newCtx);
- return oldCtx;
}
@@ -1088,12 +1144,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public int getSurfaceWidth() {
- return panelWidth; // FIXME HiDPI: Accurate or: getWidth() * hasPixelScale[0];
+ return panelWidth; // scaled surface width in pixel units, current as-from reshape
}
@Override
public int getSurfaceHeight() {
- return panelHeight; // FIXME HiDPI: Accurate or: getHeight() * hasPixelScale[1];
+ return panelHeight; // scaled surface height in pixel units, current as-from reshape
}
/**
@@ -1147,9 +1203,41 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
return reqOffscreenCaps;
}
+ /**
+ * Set a new requested {@link GLCapabilitiesImmutable} for this GLJPanel
+ * allowing reconfiguration.
+ * <p>
+ * Method shall be invoked from the {@link #isThreadGLCapable() AWT-EDT thread}.
+ * In case it is not invoked on the AWT-EDT thread, an attempt is made to do so.
+ * </p>
+ * <p>
+ * Method will dispose a previous {@link #isRealized() realized} GLContext and offscreen backend!
+ * </p>
+ * @param caps new capabilities.
+ */
+ public final void setRequestedGLCapabilities(final GLCapabilitiesImmutable caps) {
+ if( null == caps ) {
+ throw new IllegalArgumentException("null caps");
+ }
+ Threading.invoke(true,
+ new Runnable() {
+ @Override
+ public void run() {
+ dispose( new Runnable() {
+ @Override
+ public void run() {
+ // switch to new caps and re-init backend
+ // after actual dispose, but before resume animator
+ reqOffscreenCaps = caps;
+ initializeBackendImpl();
+ } } );
+ }
+ }, getTreeLock());
+ }
+
@Override
public final GLProfile getGLProfile() {
- return glProfile;
+ return reqOffscreenCaps.getGLProfile();
}
@Override
@@ -1217,35 +1305,37 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private boolean initializeBackendImpl() {
synchronized(initSync) {
if( !isInitialized ) {
- if ( 0 >= panelWidth || 0 >= panelHeight ) {
- // See whether we have a non-zero size yet and can go ahead with
- // initialization
- if (0 >= reshapeWidth || 0 >= reshapeHeight ) {
- return false;
- }
-
+ if( handleReshape ) {
if (DEBUG) {
- System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend: " +
+ System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend.1: ["+(printActive?"printing":"paint")+"] "+
panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr() + " -> " +
reshapeWidth+"x"+reshapeHeight+" @ scale "+getPixelScaleStr());
}
- // Pull down reshapeWidth and reshapeHeight into panelWidth and
- // panelHeight eagerly in order to complete initialization, and
- // force a reshape later
panelWidth = reshapeWidth;
panelHeight = reshapeHeight;
+ handleReshape = false;
+ } else {
+ if (DEBUG) {
+ System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend.0: ["+(printActive?"printing":"paint")+"] "+
+ panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr());
+ }
+ }
+
+ if ( 0 >= panelWidth || 0 >= panelHeight ) {
+ return false;
}
if ( null == backend ) {
if ( oglPipelineUsable() ) {
backend = new J2DOGLBackend();
} else {
- backend = new OffscreenBackend(glProfile, customPixelBufferProvider);
+ backend = new OffscreenBackend(customPixelBufferProvider);
}
isInitialized = false;
}
if (!isInitialized) {
+ this.factory = GLDrawableFactoryImpl.getFactoryImpl( reqOffscreenCaps.getGLProfile() ); // reqOffscreenCaps may have changed
backend.initialize();
}
return isInitialized;
@@ -1340,36 +1430,42 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private final Runnable disposeAction = new Runnable() {
@Override
public void run() {
- if ( null != backend ) {
- final GLContext _context = backend.getContext();
- final boolean backendDestroy = !backend.isUsingOwnLifecycle();
-
- GLException exceptionOnDisposeGL = null;
- if( null != _context && _context.isCreated() ) {
- try {
- helper.disposeGL(GLJPanel.this, _context, !backendDestroy);
- } catch (final GLException gle) {
- exceptionOnDisposeGL = gle;
+ final RecursiveLock _lock = lock;
+ _lock.lock();
+ try {
+ if ( null != backend ) {
+ final GLContext _context = backend.getContext();
+ final boolean backendDestroy = !backend.isUsingOwnLifecycle();
+
+ GLException exceptionOnDisposeGL = null;
+ if( null != _context && _context.isCreated() ) {
+ try {
+ helper.disposeGL(GLJPanel.this, _context, !backendDestroy);
+ } catch (final GLException gle) {
+ exceptionOnDisposeGL = gle;
+ }
}
- }
- Throwable exceptionBackendDestroy = null;
- if ( backendDestroy ) {
- try {
- backend.destroy();
- } catch( final Throwable re ) {
- exceptionBackendDestroy = re;
+ Throwable exceptionBackendDestroy = null;
+ if ( backendDestroy ) {
+ try {
+ backend.destroy();
+ } catch( final Throwable re ) {
+ exceptionBackendDestroy = re;
+ }
+ backend = null;
+ isInitialized = false;
}
- backend = null;
- isInitialized = false;
- }
- // throw exception in order of occurrence ..
- if( null != exceptionOnDisposeGL ) {
- throw exceptionOnDisposeGL;
- }
- if( null != exceptionBackendDestroy ) {
- throw GLException.newGLException(exceptionBackendDestroy);
+ // throw exception in order of occurrence ..
+ if( null != exceptionOnDisposeGL ) {
+ throw exceptionOnDisposeGL;
+ }
+ if( null != exceptionBackendDestroy ) {
+ throw GLException.newGLException(exceptionBackendDestroy);
+ }
}
+ } finally {
+ _lock.unlock();
}
}
};
@@ -1539,7 +1635,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// For saving/restoring of OpenGL state during ReadPixels
private final GLPixelStorageModes psm = new GLPixelStorageModes();
- OffscreenBackend(final GLProfile glp, final AWTGLPixelBufferProvider custom) {
+ OffscreenBackend(final AWTGLPixelBufferProvider custom) {
if(null == custom) {
pixelBufferProvider = getSingleAWTGLPixelBufferProvider();
} else {
@@ -1589,7 +1685,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
final boolean useGLSLFlip_pre = flipVertical && offscreenIsFBO && reqOffscreenCaps.getGLProfile().isGL2ES2() && USE_GLSL_TEXTURE_RASTERIZER;
if( offscreenIsFBO && !useGLSLFlip_pre ) {
// Texture attachment only required for GLSL vertical flip, hence simply use a color-renderbuffer attachment.
- ((GLFBODrawable)offscreenDrawable).setFBOMode(GLFBODrawable.FBOMODE_USE_DEPTH);
+ ((GLFBODrawable)offscreenDrawable).setFBOMode(0);
}
offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith[0]);
@@ -1599,6 +1695,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
helper.setAutoSwapBufferMode(false); // we handle swap-buffers, see handlesSwapBuffer()
final GL gl = offscreenContext.getGL();
+ // Remedy for Bug 1020, i.e. OSX/Nvidia's FBO needs to be cleared before blitting,
+ // otherwise first MSAA frame lacks antialiasing.
+ // Clearing of FBO is performed within GLFBODrawableImpl.initialize(..):
+ // gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities();
final boolean glslCompliant = !offscreenContext.hasRendererQuirk(GLRendererQuirks.GLSLNonCompliant);
final boolean useGLSLFlip = useGLSLFlip_pre && gl.isGL2ES2() && glslCompliant;
@@ -1613,12 +1714,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
fboDrawable.setTextureUnit( GLJPanel.this.requestedTextureUnit );
try {
fboFlipped = new FBObject();
- fboFlipped.reset(gl, fboDrawable.getSurfaceWidth(), fboDrawable.getSurfaceHeight(), 0, false);
+ fboFlipped.init(gl, panelWidth, panelHeight, 0);
fboFlipped.attachColorbuffer(gl, 0, chosenCaps.getAlphaBits()>0);
// fboFlipped.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT); // Bug 1020 (see above), cannot do in FBObject due to unknown 'first bind' state.
glslTextureRaster = new GLSLTextureRaster(fboDrawable.getTextureUnit(), true);
glslTextureRaster.init(gl.getGL2ES2());
- glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, fboDrawable.getSurfaceWidth(), fboDrawable.getSurfaceHeight());
+ glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, panelWidth, panelHeight);
} catch (final Exception ex) {
ex.printStackTrace();
if(null != glslTextureRaster) {
@@ -1848,14 +1950,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
final int[] usrViewport = new int[] { 0, 0, 0, 0 };
gl.glGetIntegerv(GL.GL_VIEWPORT, usrViewport, 0);
viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] ||
- offscreenDrawable.getSurfaceWidth() != usrViewport[2] || offscreenDrawable.getSurfaceHeight() != usrViewport[3];
+ panelWidth != usrViewport[2] || panelHeight != usrViewport[3];
if( DEBUG_VIEWPORT ) {
System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: "+GLJPanel.this.getName()+" Viewport: change "+viewportChange+
", "+usrViewport[0]+"/"+usrViewport[1]+" "+usrViewport[2]+"x"+usrViewport[3]+
- " -> 0/0 "+offscreenDrawable.getSurfaceWidth()+"x"+offscreenDrawable.getSurfaceHeight());
+ " -> 0/0 "+panelWidth+"x"+panelHeight);
}
if( viewportChange ) {
- gl.glViewport(0, 0, offscreenDrawable.getSurfaceWidth(), offscreenDrawable.getSurfaceHeight());
+ gl.glViewport(0, 0, panelWidth, panelHeight);
}
// perform vert-flipping via OpenGL/FBO
@@ -1958,8 +2060,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) {
try {
final GL gl = offscreenContext.getGL();
- fboFlipped.reset(gl, _drawable.getSurfaceWidth(), _drawable.getSurfaceHeight(), 0, false);
- glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, _drawable.getSurfaceWidth(), _drawable.getSurfaceHeight());
+ fboFlipped.reset(gl, panelWidth, panelHeight, 0);
+ glslTextureRaster.reshape(gl.getGL2ES2(), 0, 0, panelWidth, panelHeight);
} finally {
offscreenContext.release();
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index ca50b5d..fbd40eb 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -454,22 +454,22 @@ public class VBORegion2PMSAAES2 extends GLRegion {
fboWidth = targetFboWidth;
fboHeight = targetFboHeight;
fbo = new FBObject();
- fbo.reset(gl, fboWidth, fboHeight, sampleCount[0], false);
+ fbo.init(gl, fboWidth, fboHeight, sampleCount[0]);
sampleCount[0] = fbo.getNumSamples();
fbo.attachColorbuffer(gl, 0, true);
if( !blendingEnabled ) {
// no depth-buffer w/ blending
- fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
}
final FBObject ssink = new FBObject();
{
- ssink.reset(gl, fboWidth, fboHeight);
+ ssink.init(gl, fboWidth, fboHeight, 0);
// FIXME: shall not use bilinear (GL_LINEAR), due to MSAA ???
// ssink.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
ssink.attachTexture2D(gl, 0, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
if( !blendingEnabled ) {
// no depth-buffer w/ blending
- ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
}
}
fbo.setSamplingSink(ssink);
@@ -478,7 +478,7 @@ public class VBORegion2PMSAAES2 extends GLRegion {
System.err.printf("XXX.createFBO: blending %b, %dx%d%n%s%n", blendingEnabled, fboWidth, fboHeight, fbo.toString());
}
} else if( targetFboWidth != fboWidth || targetFboHeight != fboHeight || fbo.getNumSamples() != sampleCount[0] ) {
- fbo.reset(gl, targetFboWidth, targetFboHeight, sampleCount[0], true /* resetSamplingSink */);
+ fbo.reset(gl, targetFboWidth, targetFboHeight, sampleCount[0]);
sampleCount[0] = fbo.getNumSamples();
if( DEBUG_FBO_1 ) {
System.err.printf("XXX.resetFBO: %dx%d -> %dx%d%n%s%n", fboWidth, fboHeight, targetFboWidth, targetFboHeight, fbo );
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index 24fa090..8f1de91 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -573,20 +573,20 @@ public class VBORegion2PVBAAES2 extends GLRegion {
fboTexSize.put(1, fboHeight);
}
fbo = new FBObject();
- fbo.reset(gl, fboWidth, fboHeight);
+ fbo.init(gl, fboWidth, fboHeight, 0);
// Shall not use bilinear (GL_LINEAR), due to own VBAA. Result is smooth w/o it now!
// FIXME: FXAA requires bilinear filtering!
// texA = fbo.attachTexture2D(gl, 0, true, GL.GL_LINEAR, GL.GL_LINEAR, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
texA = fbo.attachTexture2D(gl, 0, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
if( !blendingEnabled ) {
// no depth-buffer w/ blending
- fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
+ fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, FBObject.DEFAULT_BITS);
}
if( DEBUG_FBO_1 ) {
System.err.printf("XXX.createFBO: %dx%d%n%s%n", fboWidth, fboHeight, fbo.toString());
}
} else if( newFboWidth != fboWidth || newFboHeight != fboHeight ) {
- fbo.reset(gl, newFboWidth, newFboHeight);
+ fbo.reset(gl, newFboWidth, newFboHeight, 0);
fbo.bind(gl);
if( DEBUG_FBO_1 ) {
System.err.printf("XXX.resetFBO: %dx%d -> %dx%d, target %dx%d%n", fboWidth, fboHeight, newFboWidth, newFboHeight, targetFboWidth, targetFboHeight);
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
index 5bd49dc..97570d6 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
@@ -32,8 +32,8 @@ import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.font.Font;
import com.jogamp.opengl.math.geom.AABBox;
-public class TypecastGlyph implements Font.Glyph {
- public static class Advance
+public final class TypecastGlyph implements Font.Glyph {
+ public static final class Advance
{
private final Font font;
private final float advance;
@@ -46,40 +46,42 @@ public class TypecastGlyph implements Font.Glyph {
size2advanceI.setKeyNotFoundValue(0);
}
- public void reset() {
+ public final void reset() {
size2advanceI.clear();
}
- public float getScale(final float pixelSize)
+ public final Font getFont() { return font; }
+
+ public final float getScale(final float pixelSize)
{
return this.font.getMetrics().getScale(pixelSize);
}
- public void add(final float advance, final float size)
+ public final void add(final float advance, final float size)
{
size2advanceI.put(Float.floatToIntBits(size), Float.floatToIntBits(advance));
}
- public float get(final float size, final boolean useFrationalMetrics)
+ public final float get(final float pixelSize, final boolean useFrationalMetrics)
{
- final int sI = Float.floatToIntBits(size);
+ final int sI = Float.floatToIntBits(pixelSize);
final int aI = size2advanceI.get(sI);
if( 0 != aI ) {
return Float.intBitsToFloat(aI);
}
final float a;
if ( useFrationalMetrics ) {
- a = this.advance * getScale(size);
+ a = this.advance * getScale(pixelSize);
} else {
- // a = Math.ceil(this.advance * getScale(size));
- a = Math.round(this.advance * getScale(size)); // TODO: check whether ceil should be used instead?
+ // a = Math.ceil(this.advance * getScale(pixelSize));
+ a = Math.round(this.advance * getScale(pixelSize)); // TODO: check whether ceil should be used instead?
}
size2advanceI.put(sI, Float.floatToIntBits(a));
return a;
}
@Override
- public String toString()
+ public final String toString()
{
return "\nAdvance:"+
"\n advance: "+this.advance+
@@ -87,7 +89,7 @@ public class TypecastGlyph implements Font.Glyph {
}
}
- public static class Metrics
+ public static final class Metrics
{
private final AABBox bbox;
private final Advance advance;
@@ -98,32 +100,34 @@ public class TypecastGlyph implements Font.Glyph {
this.advance = new Advance(font, advance);
}
- public void reset() {
+ public final void reset() {
advance.reset();
}
- public float getScale(final float pixelSize)
+ public final Font getFont() { return advance.getFont(); }
+
+ public final float getScale(final float pixelSize)
{
return this.advance.getScale(pixelSize);
}
- public AABBox getBBox()
+ public final AABBox getBBox()
{
return this.bbox;
}
- public void addAdvance(final float advance, final float size)
+ public final void addAdvance(final float advance, final float size)
{
this.advance.add(advance, size);
}
- public float getAdvance(final float size, final boolean useFrationalMetrics)
+ public final float getAdvance(final float pixelSize, final boolean useFrationalMetrics)
{
- return this.advance.get(size, useFrationalMetrics);
+ return this.advance.get(pixelSize, useFrationalMetrics);
}
@Override
- public String toString()
+ public final String toString()
{
return "\nMetrics:"+
"\n bbox: "+this.bbox+
@@ -134,31 +138,21 @@ public class TypecastGlyph implements Font.Glyph {
public static final short INVALID_ID = (short)((1 << 16) - 1);
public static final short MAX_ID = (short)((1 << 16) - 2);
- private final Font font;
private final char symbol;
private final OutlineShape shape; // in EM units
private final short id;
- private final int advance;
private final Metrics metrics;
protected TypecastGlyph(final Font font, final char symbol, final short id, final AABBox bbox, final int advance, final OutlineShape shape) {
- this.font = font;
this.symbol = symbol;
this.shape = shape;
this.id = id;
- this.advance = advance;
- this.metrics = new Metrics(this.font, bbox, this.advance);
+ this.metrics = new Metrics(font, bbox, advance);
}
- /**
- public void reset(Path2D path) {
- this.path = path;
- this.metrics.reset();
- } */
-
@Override
public final Font getFont() {
- return this.font;
+ return this.metrics.getFont();
}
@Override
@@ -211,7 +205,7 @@ public class TypecastGlyph implements Font.Glyph {
@Override
public final int hashCode() {
// 31 * x == (x << 5) - x
- final int hash = 31 + font.getName(Font.NAME_UNIQUNAME).hashCode();
+ final int hash = 31 + getFont().getName(Font.NAME_UNIQUNAME).hashCode();
return ((hash << 5) - hash) + id;
}
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java
index 7bfffd5..8ed4503 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java
@@ -65,10 +65,10 @@ import com.jogamp.opengl.math.geom.AABBox;
* @version $Id: Glyph.java,v 1.3 2007-02-21 12:23:54 davidsch Exp $
* @author <a href="mailto:davidsch at dev.java.net">David Schweinsberg</a>, Sven Gothel
*/
-public class OTGlyph {
+public final class OTGlyph {
- protected short _leftSideBearing;
- protected int _advanceWidth;
+ private final short _leftSideBearing;
+ private final int _advanceWidth;
private Point[] _points;
AABBox _bbox;
@@ -102,33 +102,32 @@ public class OTGlyph {
}
}
- public void clearPointData() {
+ public final void clearPointData() {
_points = null;
}
- public AABBox getBBox() {
+ public final AABBox getBBox() {
return _bbox;
}
- public int getAdvanceWidth() {
+ public final int getAdvanceWidth() {
return _advanceWidth;
}
- public short getLeftSideBearing() {
+ public final short getLeftSideBearing() {
return _leftSideBearing;
}
- public Point getPoint(final int i) {
+ public final Point getPoint(final int i) {
return _points[i];
}
- public int getPointCount() {
+ public final int getPointCount() {
return null != _points ? _points.length : 0;
}
/**
* @param factor a 16.16 fixed value
- */
public void scale(final int factor) {
for (int i = 0; i < _points.length; i++) {
//points[i].x = ( points[i].x * factor ) >> 6;
@@ -139,11 +138,12 @@ public class OTGlyph {
_leftSideBearing = (short)(( _leftSideBearing * factor) >> 6);
_advanceWidth = (_advanceWidth * factor) >> 6;
}
+ */
/**
* Set the points of a glyph from the GlyphDescription
*/
- private void describe(final GlyphDescription gd) {
+ private final void describe(final GlyphDescription gd) {
int endPtIndex = 0;
_points = new Point[gd.getPointCount() /* + 2 */ ];
for (int i = 0; i < gd.getPointCount(); i++) {
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index be0088f..45a4f24 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -108,10 +108,17 @@ public abstract class GLContextImpl extends GLContext {
private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read }
private int defaultVAO = 0;
+ /**
+ * <ul>
+ * <li>[GLAutoDrawable.upstreamLock].lock()</li>
+ * <li>drawable.surface.lock()</li>
+ * <li>contextLock.lock()</li>
+ * </ul>
+ */
protected GLDrawableImpl drawable;
protected GLDrawableImpl drawableRead;
- private volatile boolean pixelDataEvaluated;
+ private boolean pixelDataEvaluated;
private int /* pixelDataInternalFormat, */ pixelDataFormat, pixelDataType;
protected GL gl;
@@ -137,11 +144,16 @@ public abstract class GLContextImpl extends GLContext {
public GLContextImpl(final GLDrawableImpl drawable, final GLContext shareWith) {
super();
+ if( null == drawable ) {
+ throw new IllegalArgumentException("Null drawable");
+ }
bufferStateTracker = new GLBufferStateTracker();
if ( null != shareWith ) {
GLContextShareSet.registerSharing(this, shareWith);
bufferObjectTracker = ((GLContextImpl)shareWith).getBufferObjectTracker();
- assert (bufferObjectTracker != null) : "shared context hash null GLBufferObjectTracker: "+shareWith;
+ if( null == bufferObjectTracker ) {
+ throw new InternalError("shared-master context hash null GLBufferObjectTracker: "+toHexString(shareWith.hashCode()));
+ }
} else {
bufferObjectTracker = new GLBufferObjectTracker();
}
@@ -189,21 +201,28 @@ public abstract class GLContextImpl extends GLContext {
@Override
public final GLDrawable setGLReadDrawable(final GLDrawable read) {
- if(!isGLReadDrawableAvailable()) {
- throw new GLException("Setting read drawable feature not available");
- }
- final boolean lockHeld = lock.isOwner(Thread.currentThread());
- if(lockHeld) {
- release();
- } else if(lock.isLockedByOtherThread()) { // still could glitch ..
- throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed.");
- }
- final GLDrawable old = drawableRead;
- drawableRead = ( null != read ) ? (GLDrawableImpl) read : drawable;
- if(lockHeld) {
- makeCurrent();
- }
- return old;
+ // Validate constraints first!
+ if(!isGLReadDrawableAvailable()) {
+ throw new GLException("Setting read drawable feature not available");
+ }
+ final Thread currentThread = Thread.currentThread();
+ if( lock.isLockedByOtherThread() ) {
+ throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
+ }
+ final boolean lockHeld = lock.isOwner(currentThread);
+ if( lockHeld && lock.getHoldCount() > 1 ) {
+ // would need to makeCurrent * holdCount
+ throw new GLException("GLContext is recursively locked - unsupported for setGLDrawable(..)");
+ }
+ if(lockHeld) {
+ release(false);
+ }
+ final GLDrawable old = drawableRead;
+ drawableRead = ( null != read ) ? (GLDrawableImpl) read : drawable;
+ if(lockHeld) {
+ makeCurrent();
+ }
+ return old;
}
@Override
@@ -213,45 +232,46 @@ public abstract class GLContextImpl extends GLContext {
@Override
public final GLDrawable setGLDrawable(final GLDrawable readWrite, final boolean setWriteOnly) {
- if( drawable == readWrite && ( setWriteOnly || drawableRead == readWrite ) ) {
- return drawable; // no change.
- }
- final Thread currentThread = Thread.currentThread();
- if( lock.isLockedByOtherThread() ) {
- throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
- }
- final boolean lockHeld = lock.isOwner(currentThread);
- if( lockHeld && lock.getHoldCount() > 1 ) {
- // would need to makeCurrent * holdCount
- throw new GLException("GLContext is recursively locked - unsupported for setGLDrawable(..)");
- }
- final GLDrawableImpl old = drawable;
- if( isCreated() && null != old && old.isRealized() ) {
- if(!lockHeld) {
- makeCurrent();
- }
- // sync GL ctx w/ drawable's framebuffer before de-association
- gl.glFinish();
- associateDrawable(false);
- if(!lockHeld) {
- release();
- }
- }
- if(lockHeld) {
- release();
- }
- if( !setWriteOnly || drawableRead == drawable ) { // if !setWriteOnly || !explicitReadDrawable
- drawableRead = (GLDrawableImpl) readWrite;
- }
- drawableRetargeted |= null != drawable && readWrite != drawable;
- drawable = (GLDrawableImpl) readWrite ;
- if( isCreated() && null != drawable && drawable.isRealized() ) {
- makeCurrent(true); // implicit: associateDrawable(true)
- if( !lockHeld ) {
- release();
- }
- }
- return old;
+ // Validate constraints first!
+ final Thread currentThread = Thread.currentThread();
+ if( lock.isLockedByOtherThread() ) {
+ throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName());
+ }
+ final boolean lockHeld = lock.isOwner(currentThread);
+ if( lockHeld && lock.getHoldCount() > 1 ) {
+ // would need to makeCurrent * holdCount
+ throw new GLException("GLContext is recursively locked - unsupported for setGLDrawable(..)");
+ }
+ if( drawable == readWrite && ( setWriteOnly || drawableRead == readWrite ) ) {
+ return drawable; // no change.
+ }
+ final GLDrawableImpl old = drawable;
+ if( isCreated() && null != old && old.isRealized() ) {
+ if(!lockHeld) {
+ makeCurrent();
+ }
+ // sync GL ctx w/ drawable's framebuffer before de-association
+ gl.glFinish();
+ associateDrawable(false);
+ if(!lockHeld) {
+ release(false);
+ }
+ }
+ if(lockHeld) {
+ release(false);
+ }
+ if( !setWriteOnly || drawableRead == drawable ) { // if !setWriteOnly || !explicitReadDrawable
+ drawableRead = (GLDrawableImpl) readWrite;
+ }
+ drawableRetargeted |= null != drawable && readWrite != drawable;
+ drawable = (GLDrawableImpl) readWrite ;
+ if( isCreated() && null != drawable && drawable.isRealized() ) {
+ makeCurrent(true); // implicit: associateDrawable(true)
+ if( !lockHeld ) {
+ release(false);
+ }
+ }
+ return old;
}
@Override
@@ -260,7 +280,7 @@ public abstract class GLContextImpl extends GLContext {
}
public final GLDrawableImpl getDrawableImpl() {
- return (GLDrawableImpl) getGLDrawable();
+ return drawable;
}
@Override
@@ -316,57 +336,60 @@ public abstract class GLContextImpl extends GLContext {
public void release() throws GLException {
release(false);
}
+ private String getTraceSwitchMsg() {
+ final long drawH = null != drawable ? drawable.getHandle() : 0;
+ return "obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", isShared "+GLContextShareSet.isShared(this)+", surf "+(null!=drawable)+" "+toHexString(drawH)+", "+lock;
+ }
private void release(final boolean inDestruction) throws GLException {
- if( TRACE_SWITCH ) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch[release.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+", inDestruction: "+inDestruction+", "+lock);
- }
- if ( !lock.isOwner(Thread.currentThread()) ) {
- final String msg = getThreadName() +": Context not current on thread, obj " + toHexString(hashCode())+", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+", inDestruction: "+inDestruction+", "+lock;
- if( DEBUG_TRACE_SWITCH ) {
- System.err.println(msg);
- if( null != lastCtxReleaseStack ) {
- System.err.print("Last release call: ");
- lastCtxReleaseStack.printStackTrace();
- } else {
- System.err.println("Last release call: NONE");
- }
- }
- throw new GLException(msg);
- }
-
- Throwable drawableContextMadeCurrentException = null;
- final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle;
- try {
- if( actualRelease ) {
- if( !inDestruction ) {
- try {
- contextMadeCurrent(false);
- } catch (final Throwable t) {
- drawableContextMadeCurrentException = t;
- }
- }
- releaseImpl();
- }
- } finally {
- // exception prone ..
- if( actualRelease ) {
- setCurrent(null);
+ if( TRACE_SWITCH ) {
+ System.err.println(getThreadName() +": GLContext.ContextSwitch[release.0, inDestruction: "+inDestruction+"]: "+getTraceSwitchMsg());
}
- drawable.unlockSurface();
- lock.unlock();
- if( DEBUG_TRACE_SWITCH ) {
- final String msg = getThreadName() +": GLContext.ContextSwitch[release.X]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+(actualRelease?"switch":"keep ")+" - "+lock;
- lastCtxReleaseStack = new Throwable(msg);
- if( TRACE_SWITCH ) {
+ if ( !lock.isOwner(Thread.currentThread()) ) {
+ final String msg = getThreadName() +": Context not current on thread, inDestruction: "+inDestruction+", "+getTraceSwitchMsg();
+ if( DEBUG_TRACE_SWITCH ) {
System.err.println(msg);
- // Thread.dumpStack();
+ if( null != lastCtxReleaseStack ) {
+ System.err.print("Last release call: ");
+ lastCtxReleaseStack.printStackTrace();
+ } else {
+ System.err.println("Last release call: NONE");
+ }
}
+ throw new GLException(msg);
}
- }
- if(null != drawableContextMadeCurrentException) {
- throw new GLException("GLContext.release(false) during GLDrawableImpl.contextMadeCurrent(this, false)", drawableContextMadeCurrentException);
- }
+ Throwable drawableContextMadeCurrentException = null;
+ final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle;
+ try {
+ if( actualRelease ) {
+ if( !inDestruction ) {
+ try {
+ contextMadeCurrent(false);
+ } catch (final Throwable t) {
+ drawableContextMadeCurrentException = t;
+ }
+ }
+ releaseImpl();
+ }
+ } finally {
+ // exception prone ..
+ if( actualRelease ) {
+ setCurrent(null);
+ }
+ lock.unlock();
+ drawable.unlockSurface();
+ if( DEBUG_TRACE_SWITCH ) {
+ final String msg = getThreadName() +": GLContext.ContextSwitch[release.X]: "+(actualRelease?"switch":"keep ")+" - "+getTraceSwitchMsg();
+ lastCtxReleaseStack = new Throwable(msg);
+ if( TRACE_SWITCH ) {
+ System.err.println(msg);
+ // Thread.dumpStack();
+ }
+ }
+ }
+ if(null != drawableContextMadeCurrentException) {
+ throw new GLException("GLContext.release(false) during GLDrawableImpl.contextMadeCurrent(this, false)", drawableContextMadeCurrentException);
+ }
}
private Throwable lastCtxReleaseStack = null;
protected abstract void releaseImpl() throws GLException;
@@ -374,9 +397,7 @@ public abstract class GLContextImpl extends GLContext {
@Override
public final void destroy() {
if ( DEBUG_TRACE_SWITCH ) {
- final long drawH = null != drawable ? drawable.getHandle() : 0;
- System.err.println(getThreadName() + ": GLContextImpl.destroy.0: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) +
- ", surf "+toHexString(drawH)+", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
+ System.err.println(getThreadName() + ": GLContextImpl.destroy.0: "+getTraceSwitchMsg());
}
if ( 0 != contextHandle ) { // isCreated() ?
if ( null == drawable ) {
@@ -395,10 +416,9 @@ public abstract class GLContextImpl extends GLContext {
// Must hold the lock around the destroy operation to make sure we
// don't destroy the context while another thread renders to it.
lock.lock(); // holdCount++ -> 1 - n (1: not locked, 2-n: destroy while rendering)
- if ( lock.getHoldCount() > 2 ) {
- final String msg = getThreadName() + ": GLContextImpl.destroy: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle);
- if ( DEBUG_TRACE_SWITCH ) {
- System.err.println(msg+" - Lock was hold more than once - makeCurrent/release imbalance: "+lock);
+ if ( DEBUG_TRACE_SWITCH ) {
+ if ( lock.getHoldCount() > 2 ) {
+ System.err.println(getThreadName() + ": GLContextImpl.destroy: Lock was hold more than once - makeCurrent/release imbalance: "+getTraceSwitchMsg());
Thread.dumpStack();
}
}
@@ -437,8 +457,7 @@ public abstract class GLContextImpl extends GLContext {
} finally {
lock.unlock();
if ( DEBUG_TRACE_SWITCH ) {
- System.err.println(getThreadName() + ": GLContextImpl.destroy.X: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) +
- ", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
+ System.err.println(getThreadName() + ": GLContextImpl.destroy.X: "+getTraceSwitchMsg());
}
}
} finally {
@@ -521,15 +540,22 @@ public abstract class GLContextImpl extends GLContext {
}
protected final int makeCurrent(boolean forceDrawableAssociation) throws GLException {
+ final boolean hasDrawable = null != drawable;
if( TRACE_SWITCH ) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: "+getTraceSwitchMsg());
+ }
+ if( !hasDrawable ) {
+ if( DEBUG_TRACE_SWITCH ) {
+ System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X0]: NULL Drawable - CONTEXT_NOT_CURRENT - "+getTraceSwitchMsg());
+ }
+ return CONTEXT_NOT_CURRENT;
}
// Note: the surface is locked within [makeCurrent .. swap .. release]
final int lockRes = drawable.lockSurface();
if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
if( DEBUG_TRACE_SWITCH ) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: Surface Not Ready - CONTEXT_NOT_CURRENT - "+getTraceSwitchMsg());
}
return CONTEXT_NOT_CURRENT;
}
@@ -553,7 +579,7 @@ public abstract class GLContextImpl extends GLContext {
drawableUpdatedNotify();
unlockResources = false; // success
if( TRACE_SWITCH ) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: KEEP - CONTEXT_CURRENT - "+getTraceSwitchMsg());
}
return CONTEXT_CURRENT;
} else {
@@ -571,15 +597,15 @@ public abstract class GLContextImpl extends GLContext {
}
*/
} catch (final RuntimeException e) {
- unlockResources = true;
- throw e;
+ unlockResources = true;
+ throw e;
} finally {
- if (unlockResources) {
- if( DEBUG_TRACE_SWITCH ) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.1]: Context lock.unlock() due to error, res "+makeCurrentResultToString(res)+", "+lock);
+ if (unlockResources) {
+ if( DEBUG_TRACE_SWITCH ) {
+ System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.1]: Context lock.unlock() due to error, res "+makeCurrentResultToString(res)+", "+lock);
+ }
+ lock.unlock();
}
- lock.unlock();
- }
}
} /* if ( drawable.isRealized() ) */
} catch (final RuntimeException e) {
@@ -591,12 +617,12 @@ public abstract class GLContextImpl extends GLContext {
}
}
- if (res != CONTEXT_NOT_CURRENT) {
+ if (res != CONTEXT_NOT_CURRENT) { // still locked!
setCurrent(this);
if(res == CONTEXT_CURRENT_NEW) {
// check if the drawable's and the GL's GLProfile are equal
// throws an GLException if not
- getGLDrawable().getGLProfile().verifyEquality(gl.getGLProfile());
+ drawable.getGLProfile().verifyEquality(gl.getGLProfile());
glDebugHandler.init( isGL2GL3() && isGLDebugEnabled() );
@@ -629,16 +655,20 @@ public abstract class GLContextImpl extends GLContext {
*/
}
if( TRACE_SWITCH ) {
- System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - stateTracker.on "+glStateTracker.isEnabled()+" - "+lock);
+ System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: SWITCH - "+makeCurrentResultToString(res)+" - stateTracker.on "+glStateTracker.isEnabled()+" - "+getTraceSwitchMsg());
}
return res;
}
+ private final GLContextImpl getOtherSharedMaster() {
+ final GLContextImpl sharedMaster = (GLContextImpl) GLContextShareSet.getSharedMaster(this);
+ return this != sharedMaster ? sharedMaster : null;
+ }
private final int makeCurrentWithinLock(final int surfaceLockRes) throws GLException {
if (!isCreated()) {
if( 0 >= drawable.getSurfaceWidth() || 0 >= drawable.getSurfaceHeight() ) {
if ( DEBUG_TRACE_SWITCH ) {
- System.err.println(getThreadName() + ": Create GL context REJECTED (zero surface size) obj " + toHexString(hashCode()) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName());
+ System.err.println(getThreadName() + ": Create GL context REJECTED (zero surface size) for " + getClass().getName()+" - "+getTraceSwitchMsg());
System.err.println(drawable.toString());
}
return CONTEXT_NOT_CURRENT;
@@ -648,20 +678,23 @@ public abstract class GLContextImpl extends GLContext {
additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG ;
}
- final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getCreatedShare(this);
- final long shareWithHandle;
- if (null != shareWith) {
- shareWith.getDrawableImpl().lockSurface();
- shareWithHandle = shareWith.getHandle();
- if (0 == shareWithHandle) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context: "+this);
+ final boolean created;
+ final GLContextImpl sharedMaster = getOtherSharedMaster();
+ if ( null != sharedMaster ) {
+ if ( NativeSurface.LOCK_SURFACE_NOT_READY >= sharedMaster.drawable.lockSurface() ) {
+ throw new GLException("GLContextShareSet could not lock sharedMaster surface: "+sharedMaster.drawable);
}
- } else {
- shareWithHandle = 0;
}
- final boolean created;
try {
- created = createImpl(shareWithHandle); // may throws exception if fails
+ if ( null != sharedMaster ) {
+ final long sharedMasterHandle = sharedMaster.getHandle();
+ if ( 0 == sharedMasterHandle ) {
+ throw new GLException("GLContextShareSet returned an invalid sharedMaster context: "+sharedMaster);
+ }
+ created = createImpl(sharedMasterHandle); // may throws exception if fails
+ } else {
+ created = createImpl(0); // may throws exception if fails
+ }
if( created && hasNoDefaultVAO() ) {
final int[] tmp = new int[1];
final GL rootGL = gl.getRootGL();
@@ -673,17 +706,13 @@ public abstract class GLContextImpl extends GLContext {
}
}
} finally {
- if (null != shareWith) {
- shareWith.getDrawableImpl().unlockSurface();
+ if ( null != sharedMaster ) {
+ sharedMaster.drawable.unlockSurface();
}
}
if ( DEBUG_TRACE_SWITCH ) {
- if(created) {
- System.err.println(getThreadName() + ": Create GL context OK: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName()+" - "+getGLVersion());
- // Thread.dumpStack();
- } else {
- System.err.println(getThreadName() + ": Create GL context FAILED obj " + toHexString(hashCode()) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName());
- }
+ System.err.println(getThreadName() + ": Create GL context "+(created?"OK":"FAILED")+": For " + getClass().getName()+" - "+getGLVersion()+" - "+getTraceSwitchMsg());
+ // Thread.dumpStack();
}
if(!created) {
return CONTEXT_NOT_CURRENT;
@@ -770,8 +799,8 @@ public abstract class GLContextImpl extends GLContext {
*
* The implementation <b>must</b> leave the context current.<br>
*
- * @param share the shared context or null
- * @return the valid and current context if successful, or null
+ * @param sharedWithHandle the shared context handle or 0
+ * @return true if successful, or false
* @throws GLException
*/
protected abstract boolean createImpl(long sharedWithHandle) throws GLException ;
@@ -1398,7 +1427,7 @@ public abstract class GLContextImpl extends GLContext {
}
if(null==this.gl || !verifyInstance(gl.getGLProfile(), "Impl", this.gl)) {
- setGL( createGL( getGLDrawable().getGLProfile() ) );
+ setGL( createGL( drawable.getGLProfile() ) );
}
updateGLXProcAddressTable();
@@ -1571,6 +1600,10 @@ public abstract class GLContextImpl extends GLContext {
ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_ES3_COMPAT ) ;
}
+ if(!isCurrentContextHardwareRasterizer()) {
+ ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT;
+ }
+
final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion);
setRendererQuirks(adevice, getDrawableImpl().getFactoryImpl(),
@@ -1584,10 +1617,6 @@ public abstract class GLContextImpl extends GLContext {
return false;
}
- if(!isCurrentContextHardwareRasterizer()) {
- ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT;
- }
-
contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits);
if (DEBUG) {
System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 validated FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion));
@@ -1695,9 +1724,6 @@ public abstract class GLContextImpl extends GLContext {
final int reqMajor, final int reqMinor, final int reqCTP,
final int major, final int minor, final int ctp, final VersionNumberString vendorVersion,
final boolean withinGLVersionsMapping) {
- final int[] quirks = new int[GLRendererQuirks.COUNT + 1]; // + 1 ( NoFullFBOSupport )
- int i = 0;
-
final String MesaSP = "Mesa ";
// final String MesaRendererAMDsp = " AMD ";
final String MesaRendererIntelsp = "Intel(R)";
@@ -1707,8 +1733,21 @@ public abstract class GLContextImpl extends GLContext {
final boolean isX11 = NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true);
final boolean isWindows = Platform.getOSType() == Platform.OSType.WINDOWS;
final boolean isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium ");
- final boolean isDriverATICatalyst = !isDriverMesa && ( glVendor.contains("ATI Technologies") || glRenderer.startsWith("ATI ") );
- final boolean isDriverNVIDIAGeForce = !isDriverMesa && ( glVendor.contains("NVIDIA Corporation") || glRenderer.contains("NVIDIA ") );
+
+ final boolean isDriverATICatalyst;
+ final boolean isDriverNVIDIAGeForce;
+ final boolean isDriverIntel;
+ if( !isDriverMesa ) {
+ isDriverATICatalyst = glVendor.contains("ATI Technologies") || glRenderer.startsWith("ATI ");
+ isDriverNVIDIAGeForce = glVendor.contains("NVIDIA Corporation") || glRenderer.contains("NVIDIA ");
+ isDriverIntel = glVendor.startsWith("Intel");
+ } else {
+ isDriverATICatalyst = false;
+ isDriverNVIDIAGeForce = false;
+ isDriverIntel = false;
+ }
+
+ final GLRendererQuirks quirks = new GLRendererQuirks();
//
// General Quirks
@@ -1719,14 +1758,14 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: ES req "+reqMajor+" and 2 < "+major);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
if( withinGLVersionsMapping ) {
// Thread safe due to single threaded initialization!
- GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1);
+ GLRendererQuirks.addStickyDeviceQuirk(adevice, quirk);
} else {
// FIXME: Remove when moving EGL/ES to ARB ctx creation
synchronized(GLContextImpl.class) {
- GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1);
+ GLRendererQuirks.addStickyDeviceQuirk(adevice, quirk);
}
}
}
@@ -1744,17 +1783,24 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType());
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
+ }
+ {
+ final int quirk = GLRendererQuirks.NeedSharedObjectSync;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType());
+ }
+ quirks.addQuirk( quirk );
}
if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 && 3==reqMajor && 4==major ) {
final int quirk = GLRendererQuirks.GL4NeedsGL3Request;
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", req "+reqMajor+"."+reqMinor);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
if( withinGLVersionsMapping ) {
// Thread safe due to single threaded initialization!
- GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1);
+ GLRendererQuirks.addStickyDeviceQuirk(adevice, quirk);
}
}
if( isDriverNVIDIAGeForce ) {
@@ -1764,14 +1810,14 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Lion) < 0 ) { // < OSX 10.7.0 w/ NV has unstable GLSL
final int quirk = GLRendererQuirks.GLSLNonCompliant;
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
}
} else if( isWindows ) {
@@ -1783,7 +1829,7 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType());
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
if( isDriverATICatalyst ) {
@@ -1795,7 +1841,7 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", [Vendor "+glVendor+" or Renderer "+glRenderer+"], driverVersion "+vendorVersion);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
if( Platform.getOSVersionNumber().compareTo(winXPVersionNumber) <= 0 ) {
@@ -1803,8 +1849,14 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS-Version "+Platform.getOSType()+" "+Platform.getOSVersionNumber()+", [Vendor "+glVendor+" or Renderer "+glRenderer+"]");
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
+ } else if( isDriverIntel && glRenderer.equals("Intel Bear Lake B") ) {
+ final int quirk = GLRendererQuirks.NoPBufferWithAccum;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", [Vendor "+glVendor+" and Renderer "+glRenderer+"]");
+ }
+ quirks.addQuirk( quirk );
}
} else if( Platform.OSType.ANDROID == Platform.getOSType() ) {
//
@@ -1816,14 +1868,14 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + ", Renderer " + glRenderer);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
if( glRenderer.contains("Immersion.16") ) {
- final int quirk = GLRendererQuirks.GLSharedContextBuggy;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + ", Renderer " + glRenderer);
- }
- quirks[i++] = quirk;
+ final int quirk = GLRendererQuirks.GLSharedContextBuggy;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + ", Renderer " + glRenderer);
+ }
+ quirks.addQuirk( quirk );
}
}
@@ -1844,21 +1896,21 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 Renderer=" + glRenderer + ", Version=[vendor " + vendorVersion + ", GL " + glVersion+"]");
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
} else if( isDriverATICatalyst ) {
{
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 Renderer=" + glRenderer);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
} else if( jogamp.nativewindow.x11.X11Util.getMarkAllDisplaysUnclosable() ) {
{
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11Util Downstream");
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
}
}
@@ -1869,6 +1921,7 @@ public abstract class GLContextImpl extends GLContext {
// RENDERER related quirks
//
if( isDriverMesa ) {
+ final VersionNumber mesaSafeFBOVersion = new VersionNumber(8, 0, 0);
final VersionNumber mesaIntelBuggySharedCtx921 = new VersionNumber(9, 2, 1);
{
@@ -1876,88 +1929,103 @@ public abstract class GLContextImpl extends GLContext {
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
}
- if( hwAccel /* glRenderer.contains( MesaRendererIntelsp ) || glRenderer.contains( MesaRendererAMDsp ) */ )
- {
+ if( hwAccel ) {
+ // hardware-acceleration
final int quirk = GLRendererQuirks.NoDoubleBufferedPBuffer;
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
+ } else {
+ // software
+ if( vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) { // FIXME: Is it fixed in >= 8.0.0 ?
+ final int quirk = GLRendererQuirks.BuggyColorRenderbuffer;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer + " / Mesa-Version "+vendorVersion);
+ }
+ quirks.addQuirk( quirk );
+ }
}
if (compatCtx && (major > 3 || (major == 3 && minor >= 1))) {
- // FIXME: Apply vendor version constraints!
- final int quirk = GLRendererQuirks.GLNonCompliant;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
- }
- quirks[i++] = quirk;
+ // FIXME: Apply vendor version constraints!
+ final int quirk = GLRendererQuirks.GLNonCompliant;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
+ }
+ quirks.addQuirk( quirk );
}
if( glRenderer.contains( MesaRendererIntelsp ) &&
vendorVersion.compareTo(mesaIntelBuggySharedCtx921) >= 0 && isX11 ) { // FIXME: When is it fixed ?
- final int quirk = GLRendererQuirks.GLSharedContextBuggy;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 / Renderer " + glRenderer + " / Mesa-Version "+vendorVersion);
- }
- quirks[i++] = quirk;
+ final int quirk = GLRendererQuirks.GLSharedContextBuggy;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 / Renderer " + glRenderer + " / Mesa-Version "+vendorVersion);
+ }
+ quirks.addQuirk( quirk );
}
if( glVendor.contains( "nouveau" )
// FIXME: && vendorVersion.compareTo(nouveauBuggyMSAAFixed) < 0
) {
- final int quirk = GLRendererQuirks.NoMultiSamplingBuffers;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 / Renderer " + glRenderer + " / Vendor "+glVendor);
- }
- quirks[i++] = quirk;
- if( withinGLVersionsMapping ) {
- // Thread safe due to single threaded initialization!
- GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1);
- }
+ final int quirk = GLRendererQuirks.NoMultiSamplingBuffers;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 / Renderer " + glRenderer + " / Vendor "+glVendor);
+ }
+ quirks.addQuirk( quirk );
+ if( withinGLVersionsMapping ) {
+ // Thread safe due to single threaded initialization!
+ GLRendererQuirks.addStickyDeviceQuirk(adevice, quirk);
+ }
}
- if( isWindows && glRenderer.contains("SVGA3D") ) {
- final VersionNumber mesaSafeFBOVersion = new VersionNumber(8, 0, 0);
- if ( vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) { // includes: vendorVersion.isZero()
- final int quirk = GLRendererQuirks.NoFullFBOSupport;
- if(DEBUG) {
- System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer + " / Mesa-Version "+vendorVersion);
- }
- quirks[i++] = quirk;
+ if( isWindows && glRenderer.contains("SVGA3D") && vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) {
+ final int quirk = GLRendererQuirks.NoFullFBOSupport;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer + " / Mesa-Version "+vendorVersion);
}
+ quirks.addQuirk( quirk );
}
}
//
// Property related quirks
//
- if( FORCE_MIN_FBO_SUPPORT ) {
- final int quirk = GLRendererQuirks.NoFullFBOSupport;
+ if( FORCE_NO_COLOR_RENDERBUFFER ) {
+ final int quirk = GLRendererQuirks.BuggyColorRenderbuffer;
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: property");
}
- quirks[i++] = quirk;
+ quirks.addQuirk( quirk );
+ }
+ if( FORCE_MIN_FBO_SUPPORT || quirks.exist(GLRendererQuirks.BuggyColorRenderbuffer) ) {
+ final int quirk = GLRendererQuirks.NoFullFBOSupport;
+ if(DEBUG) {
+ final String causeProps = FORCE_MIN_FBO_SUPPORT ? "property, " : "";
+ final String causeQuirk = quirks.exist(GLRendererQuirks.BuggyColorRenderbuffer) ? "BuggyColorRenderbuffer" : "";
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: "+causeProps+causeQuirk);
+ }
+ quirks.addQuirk( quirk );
}
- glRendererQuirks = new GLRendererQuirks(quirks, 0, i);
if(DEBUG) {
- System.err.println("Quirks local.0: "+glRendererQuirks);
+ System.err.println("Quirks local.0: "+quirks);
}
{
// Merge sticky quirks, thread safe due to single threaded initialization!
- GLRendererQuirks.pushStickyDeviceQuirks(adevice, glRendererQuirks);
+ GLRendererQuirks.pushStickyDeviceQuirks(adevice, quirks);
final AbstractGraphicsDevice factoryDefaultDevice = factory.getDefaultDevice();
if( !GLRendererQuirks.areSameStickyDevice(factoryDefaultDevice, adevice) ) {
- GLRendererQuirks.pushStickyDeviceQuirks(factoryDefaultDevice, glRendererQuirks);
+ GLRendererQuirks.pushStickyDeviceQuirks(factoryDefaultDevice, quirks);
}
if( esCtx ) {
final AbstractGraphicsDevice eglFactoryDefaultDevice = GLDrawableFactory.getEGLFactory().getDefaultDevice();
if( !GLRendererQuirks.areSameStickyDevice(eglFactoryDefaultDevice, adevice) &&
!GLRendererQuirks.areSameStickyDevice(eglFactoryDefaultDevice, factoryDefaultDevice) ) {
- GLRendererQuirks.pushStickyDeviceQuirks(eglFactoryDefaultDevice, glRendererQuirks);
+ GLRendererQuirks.pushStickyDeviceQuirks(eglFactoryDefaultDevice, quirks);
}
}
}
+ glRendererQuirks = quirks;
if(DEBUG) {
System.err.println("Quirks local.X: "+glRendererQuirks);
System.err.println("Quirks sticky on "+adevice+": "+GLRendererQuirks.getStickyDeviceQuirks(adevice));
@@ -2132,35 +2200,31 @@ public abstract class GLContextImpl extends GLContext {
}
private final void evalPixelDataType() {
- if(!pixelDataEvaluated) {
- synchronized(this) {
- if(!pixelDataEvaluated) {
- boolean ok = false;
- /* if(isGL2GL3() && 3 == components) {
- pixelDataInternalFormat=GL.GL_RGB;
- pixelDataFormat=GL.GL_RGB;
- pixelDataType = GL.GL_UNSIGNED_BYTE;
- ok = true;
- } else */ if( isGLES2Compatible() || isExtensionAvailable(GLExtensions.OES_read_format) ) {
- final int[] glImplColorReadVals = new int[] { 0, 0 };
- gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_FORMAT, glImplColorReadVals, 0);
- gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1);
- // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB;
- pixelDataFormat = glImplColorReadVals[0];
- pixelDataType = glImplColorReadVals[1];
- ok = 0 != pixelDataFormat && 0 != pixelDataType;
- }
- if( !ok ) {
- // RGBA read is safe for all GL profiles
- // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB;
- pixelDataFormat=GL.GL_RGBA;
- pixelDataType = GL.GL_UNSIGNED_BYTE;
- }
- // TODO: Consider:
- // return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1;
- pixelDataEvaluated = true;
- }
- }
+ if(!pixelDataEvaluated) { // only valid while context is made current
+ boolean ok = false;
+ /* if(isGL2GL3() && 3 == components) {
+ pixelDataInternalFormat=GL.GL_RGB;
+ pixelDataFormat=GL.GL_RGB;
+ pixelDataType = GL.GL_UNSIGNED_BYTE;
+ ok = true;
+ } else */ if( isGLES2Compatible() || isExtensionAvailable(GLExtensions.OES_read_format) ) {
+ final int[] glImplColorReadVals = new int[] { 0, 0 };
+ gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_FORMAT, glImplColorReadVals, 0);
+ gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1);
+ // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB;
+ pixelDataFormat = glImplColorReadVals[0];
+ pixelDataType = glImplColorReadVals[1];
+ ok = 0 != pixelDataFormat && 0 != pixelDataType;
+ }
+ if( !ok ) {
+ // RGBA read is safe for all GL profiles
+ // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB;
+ pixelDataFormat=GL.GL_RGBA;
+ pixelDataType = GL.GL_UNSIGNED_BYTE;
+ }
+ // TODO: Consider:
+ // return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1;
+ pixelDataEvaluated = true;
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
index 209707f..aed611e 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java
@@ -61,21 +61,33 @@ public class GLContextShareSet {
// to a share set, containing all shared contexts itself.
private static final Map<GLContext, ShareSet> shareMap = new IdentityHashMap<GLContext, ShareSet>();
- private static final Object dummyValue = new Object();
private static class ShareSet {
- private final Map<GLContext, Object> allShares = new IdentityHashMap<GLContext, Object>();
- private final Map<GLContext, Object> createdShares = new IdentityHashMap<GLContext, Object>();
- private final Map<GLContext, Object> destroyedShares = new IdentityHashMap<GLContext, Object>();
+ private final Map<GLContext, GLContext> createdShares = new IdentityHashMap<GLContext, GLContext>();
+ private final Map<GLContext, GLContext> destroyedShares = new IdentityHashMap<GLContext, GLContext>();
- public void add(final GLContext ctx) {
- if (allShares.put(ctx, dummyValue) == null) {
- if (ctx.isCreated()) {
- createdShares.put(ctx, dummyValue);
+ public final void addNew(final GLContext slave, final GLContext master) {
+ final GLContext preMaster;
+ if ( slave.isCreated() ) {
+ preMaster = createdShares.put(slave, master);
} else {
- destroyedShares.put(ctx, dummyValue);
+ preMaster= destroyedShares.put(slave, master);
+ }
+ if( null != preMaster ) {
+ throw new InternalError("State of ShareSet corrupted: Slave "+toHexString(slave.hashCode())+
+ " is not new w/ master "+toHexString(preMaster.hashCode()));
+ }
+ }
+ public final void addIfNew(final GLContext slave, final GLContext master) {
+ final GLContext preMaster = getMaster(master);
+ if( null == preMaster ) {
+ addNew(slave, master);
}
- }
+ }
+
+ public final GLContext getMaster(final GLContext ctx) {
+ final GLContext c = createdShares.get(ctx);
+ return null != c ? c : destroyedShares.get(ctx);
}
public Set<GLContext> getCreatedShares() {
@@ -86,57 +98,55 @@ public class GLContextShareSet {
return destroyedShares.keySet();
}
- public GLContext getCreatedShare(final GLContext ignore) {
- for (final Iterator<GLContext> iter = createdShares.keySet().iterator(); iter.hasNext(); ) {
- final GLContext ctx = iter.next();
- if (ctx != ignore) {
- return ctx;
- }
- }
- return null;
- }
-
public void contextCreated(final GLContext ctx) {
- final Object res = destroyedShares.remove(ctx);
- assert res != null : "State of ShareSet corrupted; thought context " +
- ctx + " should have been in destroyed set but wasn't";
- final Object res2 = createdShares.put(ctx, dummyValue);
- assert res2 == null : "State of ShareSet corrupted; thought context " +
- ctx + " shouldn't have been in created set but was";
+ final GLContext ctxMaster = destroyedShares.remove(ctx);
+ if( null == ctxMaster ) {
+ throw new InternalError("State of ShareSet corrupted: Context "+toHexString(ctx.hashCode())+
+ " should have been in destroyed-set");
+ }
+ final GLContext delMaster = createdShares.put(ctx, ctxMaster);
+ if( null != delMaster ) {
+ throw new InternalError("State of ShareSet corrupted: Context "+toHexString(ctx.hashCode())+
+ " shouldn't have been in created-set");
+ }
}
public void contextDestroyed(final GLContext ctx) {
- final Object res = createdShares.remove(ctx);
- assert res != null : "State of ShareSet corrupted; thought context " +
- ctx + " should have been in created set but wasn't";
- final Object res2 = destroyedShares.put(ctx, dummyValue);
- assert res2 == null : "State of ShareSet corrupted; thought context " +
- ctx + " shouldn't have been in destroyed set but was";
+ final GLContext ctxMaster = createdShares.remove(ctx);
+ if( null == ctxMaster ) {
+ throw new InternalError("State of ShareSet corrupted: Context "+toHexString(ctx.hashCode())+
+ " should have been in created-set");
+ }
+ final GLContext delMaster = destroyedShares.put(ctx, ctxMaster);
+ if( null != delMaster ) {
+ throw new InternalError("State of ShareSet corrupted: Context "+toHexString(ctx.hashCode())+
+ " shouldn't have been in destroyed-set");
+ }
}
}
- /** Indicate that contexts <code>share1</code> and
- <code>share2</code> will share textures and display lists. Both
+ /** Indicate that contexts <code>slave</code> and
+ <code>master</code> will share textures and display lists. Both
must be non-null. */
- public static synchronized void registerSharing(final GLContext share1, final GLContext share2) {
- if (share1 == null || share2 == null) {
- throw new IllegalArgumentException("Both share1 and share2 must be non-null");
- }
- ShareSet share = entryFor(share1);
- if (share == null) {
- share = entryFor(share2);
- }
- if (share == null) {
- share = new ShareSet();
- }
- share.add(share1);
- share.add(share2);
- addEntry(share1, share);
- addEntry(share2, share);
- if (DEBUG) {
- System.err.println("GLContextShareSet: registereSharing: 1: " +
- toHexString(share1.getHandle()) + ", 2: " + toHexString(share2.getHandle()));
- }
+ public static synchronized void registerSharing(final GLContext slave, final GLContext master) {
+ if (slave == null || master == null) {
+ throw new IllegalArgumentException("Both slave and master must be non-null");
+ }
+ ShareSet share = entryFor(slave);
+ if ( null == share ) {
+ share = entryFor(master);
+ }
+ if ( null == share ) {
+ share = new ShareSet();
+ }
+ share.addNew(slave, master);
+ share.addIfNew(master, master); // this master could have a different master shared registered earlier!
+ addEntry(slave, share);
+ addEntry(master, share);
+ if (DEBUG) {
+ System.err.println("GLContextShareSet: registereSharing: 1: " +
+ toHexString(slave.hashCode()) + ", 2: " + toHexString(master.hashCode()));
+ }
}
public static synchronized void unregisterSharing(final GLContext lastContext) {
@@ -157,7 +167,7 @@ public class GLContextShareSet {
}
if (DEBUG) {
System.err.println("GLContextShareSet: unregisterSharing: " +
- toHexString(lastContext.getHandle())+", entries: "+s.size());
+ toHexString(lastContext.hashCode())+", entries: "+s.size());
}
for(final Iterator<GLContext> iter = s.iterator() ; iter.hasNext() ; ) {
final GLContext ctx = iter.next();
@@ -176,13 +186,18 @@ public class GLContextShareSet {
return share != null;
}
- /** Returns one created GLContext shared with the given <code>context</code>, otherwise return <code>null</code>. */
- public static synchronized GLContext getCreatedShare(final GLContext context) {
+ /**
+ * Returns the shared master GLContext of the given <code>context</code> if shared, otherwise return <code>null</code>.
+ * <p>
+ * Returns the given <code>context</code>, if it is a shared master.
+ * </p>
+ */
+ public static synchronized GLContext getSharedMaster(final GLContext context) {
final ShareSet share = entryFor(context);
if (share == null) {
return null;
}
- return share.getCreatedShare(context);
+ return share.getMaster(context);
}
private static synchronized Set<GLContext> getCreatedSharesImpl(final GLContext context) {
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 8d65f16..b51f290 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -275,7 +275,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
final GLCapabilitiesChooser chooser,
final int width, final int height) {
final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height );
- drawable.setRealized(true);
+ try {
+ drawable.setRealized(true);
+ } catch( final GLException gle) {
+ try {
+ drawable.setRealized(false);
+ } catch( final GLException gle2) { /* ignore */ }
+ throw gle;
+ }
if(drawable instanceof GLFBODrawableImpl) {
return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, null, null, null );
}
@@ -285,7 +292,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
@Override
public final GLAutoDrawable createDummyAutoDrawable(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser) {
final GLDrawable drawable = createDummyDrawable(deviceReq, createNewDevice, capsRequested, chooser);
- drawable.setRealized(true);
+ try {
+ drawable.setRealized(true);
+ } catch( final GLException gle) {
+ try {
+ drawable.setRealized(false);
+ } catch( final GLException gle2) { /* ignore */ }
+ throw gle;
+ }
final GLAutoDrawable sharedDrawable = new GLAutoDrawableDelegate(drawable, null, null, true /*ownDevice*/, null) { };
return sharedDrawable;
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index f91e1bd..c58fdbf 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -78,7 +78,8 @@ public class GLDrawableHelper {
private final ArrayList<GLEventListener> listeners = new ArrayList<GLEventListener>();
private final HashSet<GLEventListener> listenersToBeInit = new HashSet<GLEventListener>();
private final Object glRunnablesLock = new Object();
- private volatile ArrayList<GLRunnableTask> glRunnables = new ArrayList<GLRunnableTask>();
+ private ArrayList<GLRunnableTask> glRunnables = new ArrayList<GLRunnableTask>();
+ private volatile int glRunnableCount = 0;
private boolean autoSwapBufferMode;
private volatile Thread exclusiveContextThread;
/** -1 release, 0 nop, 1 claim */
@@ -103,6 +104,7 @@ public class GLDrawableHelper {
exclusiveContextThread = null;
exclusiveContextSwitch = 0;
synchronized(glRunnablesLock) {
+ glRunnableCount = 0;
glRunnables.clear();
}
animatorCtrl = null;
@@ -282,7 +284,6 @@ public class GLDrawableHelper {
if( currentContext != context ) {
context.makeCurrent();
}
- context.getGL().glFinish();
context.setGLDrawable(null, true); // dis-associate
}
@@ -300,7 +301,7 @@ public class GLDrawableHelper {
}
if(null != context) {
- context.setGLDrawable(drawable, true); // re-association
+ context.setGLDrawable(drawable, true); // re-association, implicit glFinish() ctx/drawable sync
}
if( null != currentContext ) {
@@ -670,7 +671,7 @@ public class GLDrawableHelper {
public final void display(final GLAutoDrawable drawable) {
displayImpl(drawable);
// runForAllGLEventListener(drawable, displayAction);
- if( glRunnables.size()>0 && !execGLRunnables(drawable) ) { // glRunnables volatile OK; execGL.. only executed if size > 0
+ if( glRunnableCount > 0 && !execGLRunnables(drawable) ) { // glRunnableCount volatile OK; execGL.. only executed if size > 0
displayImpl(drawable);
// runForAllGLEventListener(drawable, displayAction);
}
@@ -750,43 +751,29 @@ public class GLDrawableHelper {
}
private final boolean execGLRunnables(final GLAutoDrawable drawable) { // glRunnables.size()>0
- boolean res = true;
// swap one-shot list asap
final ArrayList<GLRunnableTask> _glRunnables;
synchronized(glRunnablesLock) {
- if(glRunnables.size()>0) {
+ if( glRunnables.size() > 0 ) {
+ glRunnableCount = 0;
_glRunnables = glRunnables;
glRunnables = new ArrayList<GLRunnableTask>();
} else {
- _glRunnables = null;
+ return true;
}
}
-
- if(null!=_glRunnables) {
- for (int i=0; i < _glRunnables.size(); i++) {
- res = _glRunnables.get(i).run(drawable) && res;
- }
+ boolean res = true;
+ for (int i=0; i < _glRunnables.size(); i++) {
+ res = _glRunnables.get(i).run(drawable) && res;
}
return res;
}
public final void flushGLRunnables() {
- if(glRunnables.size()>0) { // volatile OK
- // swap one-shot list asap
- final ArrayList<GLRunnableTask> _glRunnables;
- synchronized(glRunnablesLock) {
- if(glRunnables.size()>0) {
- _glRunnables = glRunnables;
- glRunnables = new ArrayList<GLRunnableTask>();
- } else {
- _glRunnables = null;
- }
- }
-
- if(null!=_glRunnables) {
- for (int i=0; i < _glRunnables.size(); i++) {
- _glRunnables.get(i).flush();
- }
+ synchronized(glRunnablesLock) {
+ glRunnableCount = 0;
+ while( glRunnables.size() > 0 ) {
+ glRunnables.remove(0).flush();
}
}
}
@@ -900,6 +887,7 @@ public class GLDrawableHelper {
if( isGLThread ) {
// Run immediately, don't defer since locked by this thread, but isGLThread
deferredHere = false;
+ wait = false;
} else {
// Locked by this thread, but _not_ isGLThread -> ERROR
throw new IllegalStateException("Deferred, wait, isLocked on current and not GL-Thread: thread "+Thread.currentThread());
@@ -915,6 +903,7 @@ public class GLDrawableHelper {
rTask = new GLRunnableTask(glRunnable,
wait ? rTaskLock : null,
wait /* catch Exceptions if waiting for result */);
+ glRunnableCount++;
glRunnables.add(rTask);
}
if( !deferredHere ) {
@@ -965,6 +954,7 @@ public class GLDrawableHelper {
if( isGLThread ) {
// Run immediately, don't defer since locked by this thread, but isGLThread
deferredHere = false;
+ wait = false;
} else {
// Locked by this thread, but _not_ isGLThread -> ERROR
throw new IllegalStateException("Deferred, wait, isLocked on current and not GL-Thread: thread "+Thread.currentThread());
@@ -978,11 +968,13 @@ public class GLDrawableHelper {
wait = false; // don't wait if exec immediately
}
for(int i=0; i<count-1; i++) {
+ glRunnableCount++;
glRunnables.add( new GLRunnableTask(newGLRunnables.get(i), null, false) );
}
rTask = new GLRunnableTask(newGLRunnables.get(count-1),
wait ? rTaskLock : null,
wait /* catch Exceptions if waiting for result */);
+ glRunnableCount++;
glRunnables.add(rTask);
}
if( !deferredHere ) {
@@ -1009,6 +1001,7 @@ public class GLDrawableHelper {
return;
}
synchronized(glRunnablesLock) {
+ glRunnableCount++;
glRunnables.add( new GLRunnableTask(glRunnable, null, false) );
}
}
diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
index a779fed..cc8ebca 100644
--- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
@@ -15,6 +15,7 @@ import com.jogamp.common.util.PropertyAccess;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
import com.jogamp.opengl.FBObject;
+import com.jogamp.opengl.GLRendererQuirks;
import com.jogamp.opengl.FBObject.Attachment;
import com.jogamp.opengl.FBObject.Colorbuffer;
import com.jogamp.opengl.FBObject.TextureAttachment;
@@ -44,7 +45,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
static {
Debug.initSingleton();
DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject");
- DEBUG_SWAP = DEBUG || PropertyAccess.isPropertyDefined("jogl.debug.FBObject.Swap", true);
+ DEBUG_SWAP = PropertyAccess.isPropertyDefined("jogl.debug.FBObject.Swap", true);
}
private final GLDrawableImpl parent;
@@ -60,9 +61,9 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
private int fboIBack; // points to GL_BACK buffer
private int fboIFront; // points to GL_FRONT buffer
private int pendingFBOReset = -1;
- /** Indicated whether the FBO is bound. */
+ /** Indicates whether the FBO is bound. */
private boolean fboBound;
- /** Indicated whether the FBO is swapped, resets to false after makeCurrent -> contextMadeCurrent. */
+ /** Indicates whether the FBO is swapped, resets to false after makeCurrent -> contextMadeCurrent. */
private boolean fboSwapped;
/** dump fboResetQuirk info only once pre ClassLoader and only in DEBUG mode */
@@ -90,18 +91,79 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
final GLCapabilitiesImmutable fboCaps, final int textureUnit) {
super(factory, surface, fboCaps, false);
this.initialized = false;
- this.fboModeBits = FBOMODE_USE_TEXTURE | FBOMODE_USE_DEPTH;
+ this.fboModeBits = FBOMODE_USE_TEXTURE;
this.parent = parent;
this.origParentChosenCaps = getChosenGLCapabilities(); // just to avoid null, will be reset at initialize(..)
this.texUnit = textureUnit;
this.samples = fboCaps.getNumSamples();
- fboResetQuirk = false;
+ this.fboResetQuirk = false;
+ this.swapBufferContext = null;
+ }
- // default .. // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
- // this.doubleBufferMode = ( samples > 0 || fboCaps.getDoubleBuffered() ) ? DoubleBufferMode.FBO : DoubleBufferMode.NONE ;
+ private final void setupFBO(final GL gl, final int idx, final int width, final int height, final int samples,
+ final boolean useAlpha, final int depthBits, final int stencilBits,
+ final boolean useTexture, final boolean realUnbind) {
+ final FBObject fbo = new FBObject();
+ fbos[idx] = fbo;
- this.swapBufferContext = null;
+ final boolean useDepth = depthBits > 0;
+ final boolean useStencil = stencilBits > 0;
+
+ fbo.init(gl, width, height, samples);
+ if(fbo.getNumSamples() != samples) {
+ throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbo);
+ }
+ if(samples > 0 || !useTexture) {
+ fbo.attachColorbuffer(gl, 0, useAlpha);
+ } else {
+ fbo.attachTexture2D(gl, 0, useAlpha);
+ }
+ if( useStencil ) {
+ if( useDepth ) {
+ fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, depthBits);
+ } else {
+ fbo.attachRenderbuffer(gl, Attachment.Type.STENCIL, stencilBits);
+ }
+ } else if( useDepth ) {
+ fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, depthBits);
+ }
+ if(samples > 0) {
+ final FBObject ssink = new FBObject();
+ {
+ ssink.init(gl, width, height, 0);
+ if( !useTexture ) {
+ ssink.attachColorbuffer(gl, 0, useAlpha);
+ } else {
+ ssink.attachTexture2D(gl, 0, useAlpha);
+ }
+ if( useStencil ) {
+ if( useDepth ) {
+ ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, depthBits);
+ } else {
+ ssink.attachRenderbuffer(gl, Attachment.Type.STENCIL, stencilBits);
+ }
+ } else if( useDepth ) {
+ ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, depthBits);
+ }
+ }
+ fbo.setSamplingSink(ssink);
+ fbo.resetSamplingSink(gl); // validate
+ }
+ // Clear the framebuffer allowing defined state not exposing previous content.
+ // Also remedy for Bug 1020, i.e. OSX/Nvidia's FBO needs to be cleared before blitting,
+ // otherwise first MSAA frame lacks antialiasing.
+ fbo.bind(gl);
+ if( useDepth ) {
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ } else {
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ }
+ if( realUnbind ) {
+ fbo.unbind(gl);
+ } else {
+ fbo.markUnbound();
+ }
}
private final void initialize(final boolean realize, final GL gl) {
@@ -140,55 +202,20 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
fboIBack = 0; // head
fboIFront = fbos.length - 1; // tail
+ if( 0 == ( FBOMODE_USE_TEXTURE & fboModeBits ) &&
+ gl.getContext().hasRendererQuirk(GLRendererQuirks.BuggyColorRenderbuffer) ) {
+ // GLRendererQuirks.BuggyColorRenderbuffer also disables MSAA, i.e. full FBO support
+ fboModeBits |= FBOMODE_USE_TEXTURE;
+ }
+
final boolean useTexture = 0 != ( FBOMODE_USE_TEXTURE & fboModeBits );
- final boolean useDepth = 0 != ( FBOMODE_USE_DEPTH & fboModeBits );
- final boolean useStencil = chosenFBOCaps.getStencilBits() > 0;
final boolean useAlpha = chosenFBOCaps.getAlphaBits() > 0;
final int width = getSurfaceWidth();
final int height = getSurfaceHeight();
for(int i=0; i<fbosN; i++) {
- fbos[i] = new FBObject();
- fbos[i].reset(gl, width, height, samples, false);
- if(fbos[i].getNumSamples() != samples) {
- throw new InternalError("Sample number mismatch: "+samples+", fbos["+i+"] "+fbos[i]);
- }
- if(samples > 0 || !useTexture) {
- fbos[i].attachColorbuffer(gl, 0, useAlpha);
- } else {
- fbos[i].attachTexture2D(gl, 0, useAlpha);
- }
- if( useStencil ) {
- if( useDepth ) {
- fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24);
- } else {
- fbos[i].attachRenderbuffer(gl, Attachment.Type.STENCIL, 24);
- }
- } else if( useDepth ) {
- fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
- }
- if(samples > 0) {
- final FBObject ssink = new FBObject();
- {
- ssink.reset(gl, width, height);
- if( !useTexture ) {
- ssink.attachColorbuffer(gl, 0, useAlpha);
- } else {
- ssink.attachTexture2D(gl, 0, useAlpha);
- }
- if( useStencil ) {
- if( useDepth ) {
- ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24);
- } else {
- ssink.attachRenderbuffer(gl, Attachment.Type.STENCIL, 24);
- }
- } else if( useDepth ) {
- ssink.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
- }
- }
- fbos[i].setSamplingSink(ssink);
- fbos[i].resetSamplingSink(gl); // validate
- }
+ setupFBO(gl, i, width, height, samples, useAlpha,
+ chosenFBOCaps.getDepthBits(), chosenFBOCaps.getStencilBits(), useTexture, fbosN-1==i);
}
fbos[0].formatToGLCapabilities(chosenFBOCaps);
chosenFBOCaps.setDoubleBuffered( chosenFBOCaps.getDoubleBuffered() || samples > 0 );
@@ -213,29 +240,26 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
swapBufferContext = sbc;
}
- private final void reset(final GL gl, final int idx, final int width, final int height, final int samples, final int alphaBits, final int stencilBits) {
+ private final void reset(final GL gl, final int idx, final int width, final int height, final int samples,
+ final boolean useAlpha, final int depthBits, final int stencilBits) {
if( !fboResetQuirk ) {
try {
- fbos[idx].reset(gl, width, height, samples, false);
+ fbos[idx].reset(gl, width, height, samples);
if(fbos[idx].getNumSamples() != samples) {
throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbos[idx]);
}
return;
} catch (final GLException e) {
fboResetQuirk = true;
- if(DEBUG) {
+ if( DEBUG ) {
if(!resetQuirkInfoDumped) {
resetQuirkInfoDumped = true;
System.err.println("GLFBODrawable: FBO Reset failed: "+e.getMessage());
System.err.println("GLFBODrawable: Enabling FBOResetQuirk, due to GL driver bug.");
final JoglVersion joglVersion = JoglVersion.getInstance();
- if(DEBUG) {
- System.err.println(VersionUtil.getPlatformInfo());
- System.err.println(joglVersion.toString());
- System.err.println(JoglVersion.getGLInfo(gl, null));
- } else {
- System.err.println(joglVersion.getBriefOSGLBuildInfo(gl, null));
- }
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println(joglVersion.toString());
+ System.err.println(JoglVersion.getGLInfo(gl, null));
e.printStackTrace();
}
}
@@ -244,21 +268,8 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
}
// resetQuirk fallback
fbos[idx].destroy(gl);
- fbos[idx] = new FBObject();
- fbos[idx].reset(gl, getSurfaceWidth(), getSurfaceHeight(), samples, false);
- if(fbos[idx].getNumSamples() != samples) {
- throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbos[idx]);
- }
- if(samples > 0) {
- fbos[idx].attachColorbuffer(gl, 0, alphaBits>0);
- } else {
- fbos[idx].attachTexture2D(gl, 0, alphaBits>0);
- }
- if( stencilBits > 0 ) {
- fbos[idx].attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24);
- } else {
- fbos[idx].attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
- }
+ final boolean useTexture = 0 != ( FBOMODE_USE_TEXTURE & fboModeBits );
+ setupFBO(gl, idx, width, height, samples, useAlpha, depthBits, stencilBits, useTexture, true);
}
private final void reset(final GL gl, int newSamples) throws GLException {
@@ -303,7 +314,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities();
for(int i=0; i<fbos.length; i++) {
if( pendingFBOReset != i ) {
- reset(gl, i, nWidth, nHeight, samples, caps.getAlphaBits(), caps.getStencilBits());
+ reset(gl, i, nWidth, nHeight, samples, caps.getAlphaBits()>0, caps.getDepthBits(), caps.getStencilBits());
}
}
final GLCapabilities fboCapsNative = (GLCapabilities) surface.getGraphicsConfiguration().getChosenCapabilities();
@@ -430,7 +441,8 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
// Safely reset the previous front FBO - after completing propagating swap
if(0 <= pendingFBOReset) {
final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities();
- reset(glc.getGL(), pendingFBOReset, getSurfaceWidth(), getSurfaceHeight(), samples, caps.getAlphaBits(), caps.getStencilBits());
+ reset(glc.getGL(), pendingFBOReset, getSurfaceWidth(), getSurfaceHeight(), samples,
+ caps.getAlphaBits()>0, caps.getDepthBits(), caps.getStencilBits());
pendingFBOReset = -1;
}
}
@@ -513,9 +525,12 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
}
@Override
- public final int setNumBuffers(final int bufferCount) throws GLException {
+ public final int setNumBuffers(final int bufferCount) throws /* IllegalStateException, */ GLException {
+ if( isInitialized() ) {
+ throw new IllegalStateException("Already initialized: "+this);
+ }
// FIXME: Implement
- return bufferCount;
+ return GLFBODrawableImpl.bufferCount;
}
@Override
diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java
index 60cc9f0..721dc73 100644
--- a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java
@@ -102,7 +102,7 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen
}
@Override
- public final int setNumBuffers(final int bufferCount) throws GLException {
+ public final int setNumBuffers(final int bufferCount) throws /* IllegalStateException, */ GLException {
return ((GLFBODrawableImpl)drawable).setNumBuffers(bufferCount);
}
diff --git a/src/jogl/classes/jogamp/opengl/GLStateTracker.java b/src/jogl/classes/jogamp/opengl/GLStateTracker.java
index d532a25..dc49b35 100644
--- a/src/jogl/classes/jogamp/opengl/GLStateTracker.java
+++ b/src/jogl/classes/jogamp/opengl/GLStateTracker.java
@@ -68,7 +68,7 @@ public class GLStateTracker {
private IntIntHashMap pixelStateMap;
private final ArrayList<SavedState> stack;
- private static class SavedState {
+ static class SavedState {
/**
* Empty pixel-store state
@@ -78,15 +78,14 @@ public class GLStateTracker {
/**
* set (client) pixel-store state, deep copy
*/
- private final void setPixelStateMap(final IntIntHashMap pixelStateMap) {
+ final void setPixelStateMap(final IntIntHashMap pixelStateMap) {
this.pixelStateMap = (IntIntHashMap) pixelStateMap.clone();
}
/**
* get (client) pixel-store state, return reference
*/
- private final IntIntHashMap getPixelStateMap() { return pixelStateMap; }
-
+ final IntIntHashMap getPixelStateMap() { return pixelStateMap; }
}
@@ -163,10 +162,11 @@ public class GLStateTracker {
if(null==state) {
throw new GLException("null stack element (remaining stack size "+stack.size()+")");
}
+ final IntIntHashMap statePixelStateMap = state.getPixelStateMap();
- if ( null != state.getPixelStateMap() ) {
+ if ( null != statePixelStateMap ) {
// use pulled client pixel-store state from stack
- pixelStateMap = state.getPixelStateMap();
+ pixelStateMap = statePixelStateMap;
} // else: empty-slot, not pushed by GL_CLIENT_PIXEL_STORE_BIT
}
}
diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java
index 9ff6bd6..51d8ca6 100644
--- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java
+++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java
@@ -49,6 +49,7 @@ import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2ES3;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLContext;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.GLException;
@@ -255,8 +256,8 @@ public class Mipmap {
*/
public static void closestFit( final GL gl, final int target, final int width, final int height, final int internalFormat,
final int format, final int type, final int[] newWidth, final int[] newHeight ) {
- // Use proxy textures if OpenGL version >= 1.1
- if( Double.parseDouble( gl.glGetString( GL.GL_VERSION ).trim().substring( 0, 3 ) ) >= 1.1 ) {
+ // Use proxy textures if OpenGL GL2/GL3 version >= 1.1
+ if( gl.isGL2GL3() && gl.getContext().getGLVersionNumber().compareTo(GLContext.Version110) >= 0 ) {
int widthPowerOf2 = nearestPower( width );
int heightPowerOf2 = nearestPower( height );
final int[] proxyWidth = new int[1];
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 7066a6d..cb691a7 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -639,7 +639,7 @@ public class MacOSXCGLContext extends GLContextImpl
final IntBuffer viewNotReady = Buffers.newDirectIntBuffer(1);
// Try to allocate a context with this
ctx = CGL.createContext(share, nsViewHandle, incompleteView,
- pixelFormat, chosenCaps.isBackgroundOpaque(), viewNotReady);
+ pixelFormat, chosenCaps.isBackgroundOpaque(), viewNotReady);
if (0 == ctx) {
if(DEBUG) {
System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady.get(0)));
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
index 597f511..775e293 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -123,7 +123,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
final WGLExt wglExt = ((WindowsWGLContext)sharedResource.getContext()).getWGLExt();
if (DEBUG) {
- System.out.println(getThreadName()+": Pbuffer config: " + config);
+ System.err.println(getThreadName()+": Pbuffer config: " + config);
}
final int winattrPbuffer = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(false /* onscreen */, false /* fbo */, true /* pbuffer */, false /* bitmap */);
@@ -138,12 +138,12 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
final AbstractGraphicsDevice device = config.getScreen().getDevice();
if (DEBUG) {
- System.out.println(getThreadName()+": Pbuffer parentHdc = " + toHexString(sharedHdc));
- System.out.println(getThreadName()+": Pbuffer chosenCaps: " + chosenCaps);
+ System.err.println(getThreadName()+": Pbuffer parentHdc = " + toHexString(sharedHdc));
+ System.err.println(getThreadName()+": Pbuffer chosenCaps: " + chosenCaps);
}
- if(!WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(chosenCaps,
- iattributes, sharedResource, -1, floatModeTmp)){
+ if( !WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList( sharedResource, chosenCaps,
+ iattributes, -1, floatModeTmp) ) {
throw new GLException("Pbuffer-related extensions not supported");
}
@@ -162,7 +162,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
if (DEBUG) {
System.err.println("" + nformats + " suitable pixel formats found");
for (int i = 0; i < nformats; i++) {
- final WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile,
+ final WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilitiesNoCheck(sharedResource, device, glProfile,
sharedHdc, pformats.get(i), winattrPbuffer);
System.err.println("pixel format " + pformats.get(i) + " (index " + i + "): " + dbgCaps);
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index 465b5f5..5785f80 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -50,6 +50,7 @@ import javax.media.opengl.GLProfile;
import com.jogamp.common.nio.Buffers;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
+import com.jogamp.opengl.GLRendererQuirks;
import jogamp.nativewindow.windows.DWM_BLURBEHIND;
import jogamp.nativewindow.windows.GDI;
@@ -314,21 +315,40 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
final IntBuffer iresults = Buffers.newDirectIntBuffer(2*MAX_ATTRIBS);
final int niattribs = fillAttribsForGeneralWGLARBQuery(sharedResource, iattributes);
- if (!((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, iresults)) {
+ if ( !( (WindowsWGLContext)sharedResource.getContext()).getWGLExt()
+ .wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, iresults) ) {
throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID +
" of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError());
}
return AttribList2GLCapabilities(device, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits);
}
- static int[] wglChoosePixelFormatARB(final WindowsWGLDrawableFactory.SharedResource sharedResource, final AbstractGraphicsDevice device,
- final GLCapabilitiesImmutable capabilities,
- final long hdc, final IntBuffer iattributes, final int accelerationMode, final FloatBuffer fattributes)
+ static WGLGLCapabilities wglARBPFID2GLCapabilitiesNoCheck(final WindowsWGLDrawableFactory.SharedResource sharedResource,
+ final AbstractGraphicsDevice device, final GLProfile glp,
+ final long hdc, final int pfdID, final int winattrbits) {
+ if (!sharedResource.hasARBPixelFormat()) {
+ return null;
+ }
+
+ final IntBuffer iattributes = Buffers.newDirectIntBuffer(2 * MAX_ATTRIBS);
+ final IntBuffer iresults = Buffers.newDirectIntBuffer(2 * MAX_ATTRIBS);
+ final int niattribs = fillAttribsForGeneralWGLARBQuery(sharedResource, iattributes);
+
+ if ( !( (WindowsWGLContext)sharedResource.getContext()).getWGLExt()
+ .wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, iresults) ) {
+ throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format "
+ + pfdID + " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError());
+ }
+ return AttribList2GLCapabilitiesNoCheck(device, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits);
+ }
+
+ static int[] wglChoosePixelFormatARB(final WindowsWGLDrawableFactory.SharedResource sharedResource,
+ final AbstractGraphicsDevice device, final GLCapabilitiesImmutable capabilities,
+ final long hdc, final IntBuffer iattributes, final int accelerationMode,
+ final FloatBuffer fattributes)
{
-
- if ( !WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities,
- iattributes, sharedResource, accelerationMode, null))
- {
+ if ( !WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList( sharedResource, capabilities,
+ iattributes, accelerationMode, null) ) {
if (DEBUG) {
System.err.println("wglChoosePixelFormatARB: GLCapabilities2AttribList failed: " + GDI.GetLastError());
Thread.dumpStack();
@@ -362,7 +382,8 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
+ Integer.toHexString(accelerationMode) + ": " + numFormats);
for (int i = 0; i < numFormats; i++) {
final WGLGLCapabilities dbgCaps0 = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(
- sharedResource, device, capabilities.getGLProfile(), hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS);
+ sharedResource, device, capabilities.getGLProfile(), hdc,
+ pformats[i], GLGraphicsConfigurationUtil.ALL_BITS);
System.err.println("pixel format " + pformats[i] + " (index " + i + "): " + dbgCaps0);
}
}
@@ -370,7 +391,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
}
static List <GLCapabilitiesImmutable> wglARBPFIDs2GLCapabilities(final WindowsWGLDrawableFactory.SharedResource sharedResource,
- final AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int[] pfdIDs, final int winattrbits, final boolean onlyFirstValid) {
+ final AbstractGraphicsDevice device, final GLProfile glp,
+ final long hdc, final int[] pfdIDs, final int winattrbits,
+ final boolean onlyFirstValid) {
if (!sharedResource.hasARBPixelFormat()) {
return null;
}
@@ -384,8 +407,10 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
for(int i = 0; i<numFormats; i++) {
if ( pfdIDs[i] >= 1 &&
- ((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, iresults) ) {
- final GLCapabilitiesImmutable caps = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits);
+ ((WindowsWGLContext)sharedResource.getContext()).getWGLExt()
+ .wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, iresults) ) {
+ final GLCapabilitiesImmutable caps =
+ AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits);
if(null != caps) {
bucket.add(caps);
if(DEBUG) {
@@ -396,7 +421,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
break;
}
} else if(DEBUG) {
- final GLCapabilitiesImmutable skipped = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, GLGraphicsConfigurationUtil.ALL_BITS);
+ final GLCapabilitiesImmutable skipped =
+ AttribList2GLCapabilitiesNoCheck(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());
}
} else if (DEBUG) {
@@ -411,9 +438,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
return bucket;
}
- static boolean GLCapabilities2AttribList(final GLCapabilitiesImmutable caps,
+ static boolean GLCapabilities2AttribList(final WindowsWGLDrawableFactory.SharedResource sharedResource,
+ final GLCapabilitiesImmutable caps,
final IntBuffer iattributes,
- final WindowsWGLDrawableFactory.SharedResource sharedResource,
final int accelerationValue,
final int[] floatMode) throws GLException {
if (!sharedResource.hasARBPixelFormat()) {
@@ -476,23 +503,27 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
}
iattributes.put(niattribs++, WGLExt.WGL_DEPTH_BITS_ARB);
iattributes.put(niattribs++, caps.getDepthBits());
- if (caps.getAccumRedBits() > 0 ||
+
+ if( caps.getAccumRedBits() > 0 ||
caps.getAccumGreenBits() > 0 ||
caps.getAccumBlueBits() > 0 ||
- caps.getAccumAlphaBits() > 0) {
- iattributes.put(niattribs++, WGLExt.WGL_ACCUM_BITS_ARB);
- iattributes.put(niattribs++, ( caps.getAccumRedBits() +
- caps.getAccumGreenBits() +
- caps.getAccumBlueBits() +
- caps.getAccumAlphaBits() ) );
- iattributes.put(niattribs++, WGLExt.WGL_ACCUM_RED_BITS_ARB);
- iattributes.put(niattribs++, caps.getAccumRedBits());
- iattributes.put(niattribs++, WGLExt.WGL_ACCUM_GREEN_BITS_ARB);
- iattributes.put(niattribs++, caps.getAccumGreenBits());
- iattributes.put(niattribs++, WGLExt.WGL_ACCUM_BLUE_BITS_ARB);
- iattributes.put(niattribs++, caps.getAccumBlueBits());
- iattributes.put(niattribs++, WGLExt.WGL_ACCUM_ALPHA_BITS_ARB);
- iattributes.put(niattribs++, caps.getAccumAlphaBits());
+ caps.getAccumAlphaBits() > 0 ) {
+ final GLRendererQuirks sharedQuirks = sharedResource.getRendererQuirks();
+ if ( !usePBuffer || null==sharedQuirks || !sharedQuirks.exist(GLRendererQuirks.NoPBufferWithAccum) ) {
+ iattributes.put(niattribs++, WGLExt.WGL_ACCUM_BITS_ARB);
+ iattributes.put(niattribs++, ( caps.getAccumRedBits() +
+ caps.getAccumGreenBits() +
+ caps.getAccumBlueBits() +
+ caps.getAccumAlphaBits() ) );
+ iattributes.put(niattribs++, WGLExt.WGL_ACCUM_RED_BITS_ARB);
+ iattributes.put(niattribs++, caps.getAccumRedBits());
+ iattributes.put(niattribs++, WGLExt.WGL_ACCUM_GREEN_BITS_ARB);
+ iattributes.put(niattribs++, caps.getAccumGreenBits());
+ iattributes.put(niattribs++, WGLExt.WGL_ACCUM_BLUE_BITS_ARB);
+ iattributes.put(niattribs++, caps.getAccumBlueBits());
+ iattributes.put(niattribs++, WGLExt.WGL_ACCUM_ALPHA_BITS_ARB);
+ iattributes.put(niattribs++, caps.getAccumAlphaBits());
+ }
}
if (caps.getSampleBuffers() && sharedResource.hasARBMultisample()) {
@@ -539,7 +570,8 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
static WGLGLCapabilities AttribList2GLCapabilities(final AbstractGraphicsDevice device,
final GLProfile glp, final long hdc, final int pfdID,
- final IntBuffer iattribs, final int niattribs, final IntBuffer iresults, final int winattrmask) {
+ final IntBuffer iattribs, final int niattribs, final IntBuffer iresults,
+ final int winattrmask) {
final int allDrawableTypeBits = AttribList2DrawableTypeBits(iattribs, niattribs, iresults);
int drawableTypeBits = winattrmask & allDrawableTypeBits;
@@ -548,9 +580,11 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
}
final PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
- if (WGLUtil.DescribePixelFormat(hdc, pfdID, PIXELFORMATDESCRIPTOR.size(), pfd) == 0) {
+ if ( WGLUtil.DescribePixelFormat(hdc, pfdID, PIXELFORMATDESCRIPTOR.size(), pfd) == 0 ) {
// remove displayable bits, since pfdID is non displayable
- drawableTypeBits = drawableTypeBits & ~(GLGraphicsConfigurationUtil.WINDOW_BIT | GLGraphicsConfigurationUtil.BITMAP_BIT | GLGraphicsConfigurationUtil.FBO_BIT );
+ drawableTypeBits = drawableTypeBits & ~( GLGraphicsConfigurationUtil.WINDOW_BIT |
+ GLGraphicsConfigurationUtil.BITMAP_BIT |
+ GLGraphicsConfigurationUtil.FBO_BIT );
if( 0 == drawableTypeBits ) {
return null;
}
@@ -558,9 +592,29 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
}
final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp);
res.setValuesByARB(iattribs, niattribs, iresults);
- return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res);
+ return (WGLGLCapabilities) GLGraphicsConfigurationUtil
+ .fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res);
}
+ static WGLGLCapabilities AttribList2GLCapabilitiesNoCheck(final AbstractGraphicsDevice device, final GLProfile glp,
+ final long hdc, final int pfdID,
+ final IntBuffer iattribs, final int niattribs,
+ final IntBuffer iresults, final int winattrmask) {
+ final int allDrawableTypeBits = AttribList2DrawableTypeBits(iattribs, niattribs, iresults);
+ final int drawableTypeBits = winattrmask & allDrawableTypeBits;
+
+ if (0 == drawableTypeBits) {
+ return null;
+ }
+ final PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor();
+
+ WGLUtil.DescribePixelFormat(hdc, pfdID, PIXELFORMATDESCRIPTOR.size(), pfd);
+ final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp);
+ res.setValuesByARB(iattribs, niattribs, iresults);
+ return (WGLGLCapabilities) GLGraphicsConfigurationUtil
+ .fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res);
+ }
+
//
// GDI PIXELFORMAT
//
@@ -593,7 +647,8 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
return val;
}
- static WGLGLCapabilities PFD2GLCapabilities(final AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID, final int winattrmask) {
+ static WGLGLCapabilities PFD2GLCapabilities(final AbstractGraphicsDevice device, final GLProfile glp,
+ final long hdc, final int pfdID, final int winattrmask) {
final PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID);
if(null == pfd) {
return null;
@@ -626,12 +681,14 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res);
}
- static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(final AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID) {
+ static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(final AbstractGraphicsDevice device, final GLProfile glp,
+ final long hdc, final int pfdID) {
final PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID);
return PFD2GLCapabilitiesNoCheck(device, glp, pfd, pfdID);
}
- static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(final AbstractGraphicsDevice device, final GLProfile glp, final PIXELFORMATDESCRIPTOR pfd, final int pfdID) {
+ static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(final AbstractGraphicsDevice device, final GLProfile glp,
+ final PIXELFORMATDESCRIPTOR pfd, final int pfdID) {
if(null == pfd) {
return null;
}
@@ -727,4 +784,3 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
"]";
}
}
-
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index ea92b38..ea9b867 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -74,14 +74,17 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
static VisualIDHolder.VIDComparator PfdIDComparator = new VisualIDHolder.VIDComparator(VisualIDHolder.VIDType.WIN32_PFD);
static void registerFactory() {
- GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.windows.WindowsGraphicsDevice.class, GLCapabilitiesImmutable.class, new WindowsWGLGraphicsConfigurationFactory());
+ GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.windows.WindowsGraphicsDevice.class,
+ GLCapabilitiesImmutable.class, new WindowsWGLGraphicsConfigurationFactory());
}
private WindowsWGLGraphicsConfigurationFactory() {
}
@Override
protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
- final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested, final CapabilitiesChooser chooser, final AbstractGraphicsScreen absScreen, final int nativeVisualID) {
+ final CapabilitiesImmutable capsChosen, final CapabilitiesImmutable capsRequested, final CapabilitiesChooser chooser,
+ final AbstractGraphicsScreen absScreen, final int nativeVisualID)
+ {
if (! (capsChosen instanceof GLCapabilitiesImmutable) ) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
@@ -95,7 +98,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
- return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, (GLCapabilitiesChooser)chooser, absScreen);
+ return chooseGraphicsConfigurationStatic(
+ (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, (GLCapabilitiesChooser)chooser, absScreen);
}
static WindowsWGLGraphicsConfiguration createDefaultGraphicsConfiguration(final GLCapabilitiesImmutable caps,
@@ -115,7 +119,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, chooser );
}
- protected static List<GLCapabilitiesImmutable> getAvailableCapabilities(final WindowsWGLDrawableFactory factory, final AbstractGraphicsDevice device) {
+ protected static List<GLCapabilitiesImmutable> getAvailableCapabilities(final WindowsWGLDrawableFactory factory,
+ final AbstractGraphicsDevice device) {
final WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResourceImpl(device);
if(null == sharedResource) {
throw new GLException("Shared resource for device n/a: "+device);
@@ -141,7 +146,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
throw new GLException("Error: HDC is null");
}
if (sharedResource.hasARBPixelFormat()) {
- availableCaps = WindowsWGLGraphicsConfigurationFactory.getAvailableGLCapabilitiesARB(sharedResource, sharedResource.getDevice(), glp, hdc);
+ availableCaps = WindowsWGLGraphicsConfigurationFactory.getAvailableGLCapabilitiesARB(
+ sharedResource, sharedResource.getDevice(), glp, hdc);
}
final boolean hasARBCaps = null != availableCaps && !availableCaps.isEmpty() ;
final List<GLCapabilitiesImmutable> availableCapsGDI = getAvailableGLCapabilitiesGDI(device, glp, hdc, hasARBCaps);
@@ -164,14 +170,19 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
return availableCaps;
}
- private static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesARB(final WindowsWGLDrawableFactory.SharedResource sharedResource, final AbstractGraphicsDevice device, final GLProfile glProfile, final long hdc) {
+ private static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesARB(
+ final WindowsWGLDrawableFactory.SharedResource sharedResource,
+ final AbstractGraphicsDevice device, final GLProfile glProfile, final long hdc)
+ {
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, false); // w/o BITMAP
}
- private static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesGDI(final AbstractGraphicsDevice device, final GLProfile glProfile, final long hdc, final boolean bitmapOnly) {
+ private static List<GLCapabilitiesImmutable> getAvailableGLCapabilitiesGDI(
+ final AbstractGraphicsDevice device, final GLProfile glProfile, final long hdc, final boolean bitmapOnly)
+ {
final int[] pformats = WindowsWGLGraphicsConfiguration.wglAllGDIPFIDs(hdc);
final int numFormats = pformats.length;
final List<GLCapabilitiesImmutable> bucket = new ArrayList<GLCapabilitiesImmutable>(numFormats);
@@ -275,7 +286,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
private static void updateGraphicsConfiguration(final WindowsWGLGraphicsConfiguration config, final CapabilitiesChooser chooser,
- final GLDrawableFactory factory, final long hdc, final boolean extHDC, final int[] pfdIDs) {
+ final GLDrawableFactory factory, final long hdc, final boolean extHDC,
+ final int[] pfdIDs) {
if (DEBUG) {
if(extHDC) {
System.err.println("updateGraphicsConfiguration(using shared): hdc "+toHexString(hdc));
@@ -311,7 +323,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
}
- private static boolean updateGraphicsConfigurationARB(final WindowsWGLDrawableFactory factory, final WindowsWGLGraphicsConfiguration config, final CapabilitiesChooser chooser,
+ private static boolean updateGraphicsConfigurationARB(final WindowsWGLDrawableFactory factory,
+ final WindowsWGLGraphicsConfiguration config, final CapabilitiesChooser chooser,
final long hdc, final boolean extHDC, int[] pformats) {
final AbstractGraphicsDevice device = config.getScreen().getDevice();
final WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResourceImpl(device);
@@ -331,7 +344,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities();
final boolean isOpaque = capsChosen.isBackgroundOpaque() && GDI.DwmIsCompositionEnabled();
- final int winattrbits = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen) & ~GLGraphicsConfigurationUtil.BITMAP_BIT; // w/o BITMAP
+ final int winattrbits = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen)
+ & ~GLGraphicsConfigurationUtil.BITMAP_BIT; // w/o BITMAP
final GLProfile glProfile = capsChosen.getGLProfile();
final int pfdIDCount = WindowsWGLGraphicsConfiguration.wglARBPFDIDCount((WindowsWGLContext)sharedResource.getContext(), hdc);
@@ -363,7 +377,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
+ ", pixelformat " + presetPFDID);
}
pixelFormatSet = true;
- pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, hdc, presetPFDID, winattrbits);
+ pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile,
+ hdc, presetPFDID, winattrbits);
pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque);
} else {
int recommendedIndex = -1; // recommended index
@@ -410,7 +425,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
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
final List<GLCapabilitiesImmutable> availableCaps =
- WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, winattrbits, skipCapsChooser /* onlyFirstValid */);
+ WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile,
+ hdc, pformats, winattrbits, skipCapsChooser /* onlyFirstValid */);
if( null == availableCaps || 0 == availableCaps.size() ) {
if (DEBUG) {
@@ -462,8 +478,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
return true;
}
- private static boolean updateGraphicsConfigurationGDI(final WindowsWGLGraphicsConfiguration config, final CapabilitiesChooser chooser, final long hdc,
- final boolean extHDC, int[] pformats) {
+ private static boolean updateGraphicsConfigurationGDI(final WindowsWGLGraphicsConfiguration config, final CapabilitiesChooser chooser,
+ final long hdc, final boolean extHDC, int[] pformats) {
final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities();
if( !capsChosen.isOnscreen() && capsChosen.isPBuffer() ) {
if (DEBUG) {
@@ -514,16 +530,22 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
int recommendedIndex = -1 ;
final boolean skipCapsChooser;
if( 1 <= chosenPFDID ) {
- final boolean _skipCapsChooser = null == chooser && capsChosen.isBackgroundOpaque(); // fast path: skip choosing if using recommended idx and null chooser is used and if not translucent
+ // _skipCapsChooser: fast path: skip choosing if using recommended idx and null chooser is used and if not translucent
+ final boolean _skipCapsChooser = null == chooser && capsChosen.isBackgroundOpaque();
// seek index .. in all formats _or_ in given formats!
int chosenIdx;
for (chosenIdx = pformats.length - 1 ; 0 <= chosenIdx && chosenPFDID != pformats[chosenIdx]; chosenIdx--) { /* nop */ }
if( 0 <= chosenIdx ) {
if( _skipCapsChooser ) {
- final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, chosenPFDID, winattrmask);
- availableCaps.add(caps);
- recommendedIndex = 0;
- skipCapsChooser = true;
+ final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc,
+ chosenPFDID, winattrmask);
+ if(null != caps) {
+ availableCaps.add(caps);
+ recommendedIndex = 0;
+ skipCapsChooser = true;
+ } else {
+ skipCapsChooser = false;
+ }
} else {
skipCapsChooser = false;
}
@@ -549,7 +571,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
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);
+ final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile,
+ hdc, pfdid, winattrmask);
if(null != caps) {
availableCaps.add(caps);
if(DEBUG) {
@@ -599,4 +622,3 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
return true;
}
}
-
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
index d4d3dda..462b539 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
@@ -556,8 +556,8 @@ NSOpenGLContext* createContext(NSOpenGLContext* share,
GLint zeroOpacity = 0;
[ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity];
}
+ [ctx setView:view]; // Bug 1087: Set default framebuffer, hence enforce NSView realization
if( viewReadyAndLocked ) {
- [ctx setView:view];
[view unlockFocus];
}
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java b/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java
index fd3c31f..e5901f5 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/PixelFormat.java
@@ -119,7 +119,8 @@ public enum PixelFormat {
* <ul>
* <li>OpenGL: data-format GL_RGBA, data-type GL_UNSIGNED_BYTE</li>
* <li>AWT: <i>None</i></li>
- * <li>PointerIcon: X11 (XCURSOR)</li>
+ * <li>PointerIcon: OSX (NSBitmapImageRep)</li>
+ * <li>Window Icon: OSX (NSBitmapImageRep)</li>
* <li>PNGJ: Scanlines</li>
* </ul>
* </p>
@@ -175,8 +176,8 @@ public enum PixelFormat {
* <ul>
* <li>OpenGL: data-format GL_BGRA, data-type GL_UNSIGNED_BYTE</li>
* <li>AWT: {@link java.awt.image.BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}</li>
- * <li>PointerIcon: Win32, OSX (NSBitmapImageRep), AWT</li>
- * <li>Window Icon: X11, Win32, OSX (NSBitmapImageRep)</li>
+ * <li>PointerIcon: X11 (XCURSOR), Win32, AWT</li>
+ * <li>Window Icon: X11, Win32</li>
* </ul>
* </p>
*/
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
index acc7b72..c30968c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
@@ -76,6 +76,12 @@ public class Rectangle implements Cloneable, RectangleImmutable {
this.width = width;
this.height = height;
}
+ public final void set(final Rectangle s) {
+ this.x = s.x;
+ this.y = s.y;
+ this.width = s.width;
+ this.height = s.height;
+ }
public final void setX(final int x) { this.x = x; }
public final void setY(final int y) { this.y = y; }
public final void setWidth(final int width) { this.width = width; }
diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java
index cadef9b..4f6c0d1 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java
@@ -53,12 +53,12 @@ public class GlobalToolkitLock implements ToolkitLock {
@Override
public final void lock() {
globalLock.lock();
- if(TRACE_LOCK) { System.err.println("GlobalToolkitLock.lock()"); }
+ if(TRACE_LOCK) { System.err.println(Thread.currentThread()+" GlobalToolkitLock: lock() "+toStringImpl()); }
}
@Override
public final void unlock() {
- if(TRACE_LOCK) { System.err.println("GlobalToolkitLock.unlock()"); }
+ if(TRACE_LOCK) { System.err.println(Thread.currentThread()+" GlobalToolkitLock: unlock() "+toStringImpl()); }
globalLock.unlock(); // implicit lock validation
}
@@ -74,6 +74,9 @@ public class GlobalToolkitLock implements ToolkitLock {
@Override
public String toString() {
- return "GlobalToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+globalLock.isOwner(Thread.currentThread())+", "+globalLock.toString()+"]";
+ return "GlobalToolkitLock["+toStringImpl()+"]";
+ }
+ private String toStringImpl() {
+ return "obj 0x"+Integer.toHexString(hashCode())+", isOwner "+globalLock.isOwner(Thread.currentThread())+", "+globalLock.toString();
}
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java
index bda2052..bbfb585 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java
@@ -42,14 +42,14 @@ public class NullToolkitLock implements ToolkitLock {
@Override
public final void lock() {
if(TRACE_LOCK) {
- System.err.println("NullToolkitLock.lock()");
- // Thread.dumpStack();
+ System.err.println(Thread.currentThread()+" NullToolkitLock: lock() "+toStringImpl());
+ // ExceptionUtils.dumpStackTrace(System.err, 1, 4);
}
}
@Override
public final void unlock() {
- if(TRACE_LOCK) { System.err.println("NullToolkitLock.unlock()"); }
+ if(TRACE_LOCK) { System.err.println(Thread.currentThread()+" NullToolkitLock: unlock() "+toStringImpl()); }
}
@Override
@@ -66,7 +66,10 @@ public class NullToolkitLock implements ToolkitLock {
@Override
public String toString() {
- return "NullToolkitLock[]";
+ return "NullToolkitLock["+toStringImpl()+"]";
+ }
+ private String toStringImpl() {
+ return "obj 0x"+Integer.toHexString(hashCode());
}
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java
index f1efb81..e4e557d 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java
@@ -54,12 +54,15 @@ public class ResourceToolkitLock implements ToolkitLock {
@Override
public final void lock() {
lock.lock();
- if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.lock()"); }
+ if(TRACE_LOCK) {
+ System.err.println(Thread.currentThread()+" ResourceToolkitLock: lock() "+toStringImpl());
+ // ExceptionUtils.dumpStackTrace(System.err, 1, 4);
+ }
}
@Override
public final void unlock() {
- if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.unlock()"); }
+ if(TRACE_LOCK) { System.err.println(Thread.currentThread()+" ResourceToolkitLock: unlock() "+toStringImpl()); }
lock.unlock(); // implicit lock validation
}
@@ -75,6 +78,9 @@ public class ResourceToolkitLock implements ToolkitLock {
@Override
public String toString() {
- return "ResourceToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]";
+ return "ResourceToolkitLock["+toStringImpl()+"]";
+ }
+ private String toStringImpl() {
+ return "obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString();
}
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java
index 5dac743..881fd56 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java
@@ -112,12 +112,12 @@ public class SharedResourceToolkitLock implements ToolkitLock {
@Override
public final void lock() {
lock.lock();
- if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.lock()"); }
+ if(TRACE_LOCK) { System.err.println(Thread.currentThread()+" SharedResourceToolkitLock: lock() "+toStringImpl()); }
}
@Override
public final void unlock() {
- if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.unlock()"); }
+ if(TRACE_LOCK) { System.err.println(Thread.currentThread()+" SharedResourceToolkitLock: unlock() "+toStringImpl()); }
lock.unlock();
}
@@ -144,6 +144,9 @@ public class SharedResourceToolkitLock implements ToolkitLock {
@Override
public String toString() {
- return "SharedResourceToolkitLock[refCount "+refCount+", handle 0x"+Long.toHexString(handle)+", obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]";
+ return "SharedResourceToolkitLock["+toStringImpl()+"]";
+ }
+ private String toStringImpl() {
+ return "refCount "+refCount+", handle 0x"+Long.toHexString(handle)+", obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString();
}
}
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index bf01f19..127b329 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -333,7 +333,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0
NSWindow* myWindow = [[NSWindow alloc] initWithContentRect: rect
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreBuffered
- defer: YES];
+ defer: NO]; // Bug 1087: Set default framebuffer, hence enforce NSView realization
[myWindow setReleasedWhenClosed: YES]; // default
[myWindow setPreservesContentDuringLiveResize: YES];
// Remove animations
@@ -349,6 +349,13 @@ NS_ENDHANDLER
[myWindow setOpaque: NO];
[myWindow setBackgroundColor: [NSColor clearColor]];
+ // Bug 1087: Set default framebuffer, hence enforce NSView realization
+ // However, using the NSWindow ctor w/ 'defer: NO' seems sufficient
+ // and we are invisible - no focus!
+ // NSView* myView = [myWindow contentView];
+ // [myView lockFocus];
+ // [myView unlockFocus];
+
[pool release];
return (jlong) ((intptr_t) myWindow);
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index 7091060..c4b9199 100644
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -168,6 +168,14 @@ public abstract class Display {
* <p>
* Using this value will avoid conversion within {@link #createPointerIcon(PixelRectangle, int, int)}.
* </p>
+ * <p>
+ * Known native pixel formats are:
+ * <ul>
+ * <li>X11: {@link PixelFormat#BGRA8888}</li>
+ * <li>Windows: {@link PixelFormat#BGRA8888}</li>
+ * <li>OSX: {@link PixelFormat#RGBA8888}</li>
+ * </ul>
+ * </p>
*/
public abstract PixelFormat getNativePointerIconPixelFormat();
@@ -381,7 +389,7 @@ public abstract class Display {
* @param type
* @param name
* @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1.
- * @paran shared if true, only shared instances are found, otherwise also exclusive
+ * @param shared if true, only shared instances are found, otherwise also exclusive
* @return
*/
public static Display getLastDisplayOf(final String type, final String name, final int fromIndex, final boolean shared) {
diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
index 397c810..c470f68 100644
--- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
+++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java
@@ -56,6 +56,8 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLOffscreenAutoDrawable;
import javax.swing.MenuSelectionManager;
import jogamp.nativewindow.awt.AWTMisc;
@@ -670,11 +672,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto
}
if( reqNewGLAD ) {
final GLDrawableFactory factory = GLDrawableFactory.getFactory(newGLADCaps.getGLProfile());
- printGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
- printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
- printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
- GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD);
- printDrawable = printGLAD.getDelegatedDrawable();
+ GLOffscreenAutoDrawable offGLAD = null;
+ try {
+ offGLAD = factory.createOffscreenAutoDrawable(null, newGLADCaps, null,
+ printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE,
+ printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE);
+ } catch (final GLException gle) {
+ if( DEBUG ) {
+ System.err.println("Caught: "+gle.getMessage());
+ gle.printStackTrace();
+ }
+ }
+ if( null != offGLAD ) {
+ printGLAD = offGLAD;
+ GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD);
+ printDrawable = printGLAD.getDelegatedDrawable();
+ }
}
printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented());
printAWTTiles.renderer.setTileSize(printDrawable.getSurfaceWidth(), printDrawable.getSurfaceHeight(), 0);
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 24a203b..2ba030f 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -65,6 +65,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
+import javax.media.opengl.GLSharedContextSetter;
import jogamp.newt.WindowImpl;
import jogamp.opengl.GLAutoDrawableBase;
@@ -108,6 +109,12 @@ import com.jogamp.opengl.GLStateKeeper;
* you can inject {@link GLRunnable} objects
* via {@link #invoke(boolean, GLRunnable)} to the OpenGL command stream.<br>
* </p>
+ * <p>
+ * <a name="contextSharing"><h5>OpenGL Context Sharing</h5></a>
+ * To share a {@link GLContext} see the following note in the documentation overview:
+ * <a href="../../../../overview-summary.html#SHARING">context sharing</a>
+ * as well as {@link GLSharedContextSetter}.
+ * </p>
*/
public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter {
private final WindowImpl window;
@@ -599,10 +606,12 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
@Override
public synchronized boolean pauseRenderingAction() {
- boolean animatorPaused = false;
+ final boolean animatorPaused;
savedAnimator = GLWindow.this.getAnimator();
if ( null != savedAnimator ) {
animatorPaused = savedAnimator.pause();
+ } else {
+ animatorPaused = false;
}
return animatorPaused;
}
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
index fab3fe8..2cd4731 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java
@@ -110,6 +110,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
@Override
protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) {
viewport.set(0, 0, fixedWidth, fixedHeight); // FIXME
+ viewportInWindowUnits.set(viewport);
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
index e3e854c..64cae75 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java
@@ -103,6 +103,7 @@ public class ScreenDriver extends ScreenImpl {
@Override
protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) {
viewport.set(0, 0, cachedWidth, cachedHeight);
+ viewportInWindowUnits.set(viewport);
}
/** Called from {@link #initNative()}. */
diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
index b5400c3..2ce835c 100644
--- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java
@@ -112,6 +112,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl {
@Override
protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) {
viewport.set(0, 0, cachedWidth, cachedHeight);
+ viewportInWindowUnits.set(viewport);
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
index 71f8b14..d411356 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java
@@ -108,6 +108,7 @@ public class ScreenDriver extends ScreenImpl {
@Override
protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) {
viewport.set(0, 0, cachedWidth, cachedHeight);
+ viewportInWindowUnits.set(viewport);
}
protected void sizeChanged(final int w, final int h) {
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java
index 4ecc2fd..051294d 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java
@@ -70,7 +70,7 @@ public class DisplayDriver extends DisplayImpl {
// NOTE: MUST BE DIRECT BUFFER, since NSBitmapImageRep uses buffer directly!
final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons();
final URLConnection urlConn = iconRes.resolve(iconRes.resourceCount()-1);
- image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, true /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
+ image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.RGBA8888, true /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
} catch (final Exception e) {
e.printStackTrace();
}
@@ -97,6 +97,9 @@ public class DisplayDriver extends DisplayImpl {
}
@Override
+ public PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.RGBA8888; }
+
+ @Override
protected void dispatchMessagesNative() {
// nop
}
diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java
index 1cba421..38acd03 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java
@@ -158,6 +158,7 @@ public class ScreenDriver extends ScreenImpl {
@Override
protected void calcVirtualScreenOriginAndSize(final Rectangle viewport, final Rectangle viewportInWindowUnits) {
viewport.set(getVirtualOriginX0(), getVirtualOriginY0(), getVirtualWidthImpl0(), getVirtualHeightImpl0());
+ viewportInWindowUnits.set(viewport);
}
// Native calls
diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
index 759c274..e2b9a65 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java
@@ -125,9 +125,6 @@ public class DisplayDriver extends DisplayImpl {
protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; }
@Override
- public final PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.RGBA8888; }
-
- @Override
protected final long createPointerIconImpl(final PixelFormat pixelformat, final int width, final int height, final ByteBuffer pixels, final int hotX, final int hotY) {
return createPointerIcon(getHandle(), pixels, width, height, hotX, hotY);
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java
index 1d77974..f736174 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java
@@ -246,6 +246,7 @@ public class ScreenDriver extends ScreenImpl {
@Override
public Object run(final long dpy) {
viewport.set(0, 0, getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx));
+ viewportInWindowUnits.set(viewport);
return null;
} } );
if( DEBUG ) {
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 5a19631..caf9e54 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -124,6 +124,9 @@ static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLa
static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboard) {
CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData);
+ if( NULL == layoutData ) {
+ return NULL;
+ }
const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData);
CFMutableDictionaryRef codeToCharDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128, NULL, NULL);
@@ -149,8 +152,10 @@ static CFMutableDictionaryRef CKCH_USCodeToNNChar = NULL;
static void CKCH_CreateDictionaries() {
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
- CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard);
- CFRelease(currentKeyboard);
+ if( NULL != currentKeyboard ) {
+ CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard);
+ CFRelease(currentKeyboard);
+ }
}
static UniChar CKCH_CharForKeyCode(jshort keyCode) {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java b/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java
new file mode 100644
index 0000000..03a00af
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/FontSet01.java
@@ -0,0 +1,35 @@
+package com.jogamp.opengl.test.junit.graph;
+
+import java.io.IOException;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.font.FontSet;
+
+public class FontSet01 {
+ public static Font[] getSet01() throws IOException {
+ final Font[] fonts = new Font[11];
+ int i = 0;
+ fonts[i++] = FontFactory.get(FontFactory.UBUNTU).getDefault(); // FontSet.FAMILY_REGULAR, FontSet.STYLE_NONE
+ fonts[i++] = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_REGULAR, FontSet.STYLE_ITALIC);
+ fonts[i++] = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_REGULAR, FontSet.STYLE_BOLD);
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeMono.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeMonoBold.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSans.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSansBold.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerif.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerifBold.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerifBoldItalic.ttf"));
+ fonts[i++] = FontFactory.get(IOUtil.getResource(TestTextRendererNEWTBugXXXX.class,
+ "fonts/freefont/FreeSerifItalic.ttf"));
+ return fonts;
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java
new file mode 100644
index 0000000..e0c6d2a
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestFontsNEWT00.java
@@ -0,0 +1,93 @@
+/**
+ * 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 com.jogamp.opengl.test.junit.graph;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.Font.Glyph;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+
+ at FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestFontsNEWT00 extends UITestCase {
+ static boolean mainRun = false;
+
+ static int atoi(final String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (final Exception ex) { throw new RuntimeException(ex); }
+ }
+
+ public static void main(final String args[]) throws IOException {
+ mainRun = true;
+ final String tstname = TestFontsNEWT00.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ @Test
+ public void test00() throws InterruptedException, IOException {
+ testFontImpl(FontSet01.getSet01());
+ }
+ void testFontImpl(final Font[] fonts) throws InterruptedException, IOException {
+ final float fontSize = 10;
+ final float dpi = 96;
+ for(int i=0; i<fonts.length; i++) {
+ final Font font = fonts[i];
+ final float pixelSize = font.getPixelSize(fontSize, dpi);
+ System.err.println(font.getFullFamilyName(null).toString()+": "+fontSize+"p, "+dpi+"dpi -> "+pixelSize+"px:");
+ testFontGlyphAdvancedSize(font, ' ', Glyph.ID_SPACE, fontSize, dpi, pixelSize);
+ testFontGlyphAdvancedSize(font, 'X', 'X', fontSize, dpi, pixelSize);
+ }
+ }
+ void testFontGlyphAdvancedSize(final Font font, final char c, final int glyphID,
+ final float fontSize, final float dpi, final float pixelSize) {
+ final float glyphScale = font.getGlyph(c).getScale(pixelSize);
+ final float fontScale = font.getMetrics().getScale(pixelSize);
+
+ // return this.metrics.getAdvance(pixelSize, useFrationalMetrics);
+ // this.metrics.getAdvance(pixelSize, useFrationalMetrics)
+ // this.advance * this.font.getMetrics().getScale(pixelSize)
+ // font.getHmtxTable().getAdvanceWidth(glyphID) * this.font.getMetrics().getScale(pixelSize)
+ final float spaceAdvanceSizeOfGlyph = font.getGlyph(c).getAdvance(pixelSize, true);
+
+ // font.getHmtxTable().getAdvanceWidth(glyphID) * metrics.getScale(pixelSize);
+ // font.getHmtxTable().getAdvanceWidth(glyphID) * pixelSize * unitsPerEM_Inv;
+ final float spaceAdvanceWidth = font.getAdvanceWidth(glyphID, pixelSize);
+ System.err.println(" Char '"+c+"', "+glyphID+":");
+ System.err.println(" glyphScale "+glyphScale);
+ System.err.println(" glyphSize "+spaceAdvanceSizeOfGlyph);
+ System.err.println(" fontScale "+fontScale);
+ System.err.println(" fontWidth "+spaceAdvanceWidth);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
index cb9f3e3..4cfa8d9 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -27,12 +27,14 @@
*/
package com.jogamp.opengl.test.junit.graph;
+import java.io.File;
import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
@@ -42,6 +44,8 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRegionUtil;
@@ -49,8 +53,10 @@ import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.SVertex;
import com.jogamp.opengl.math.geom.AABBox;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.PMVMatrix;
@@ -64,13 +70,16 @@ public class TestTextRendererNEWT10 extends UITestCase {
static boolean mainRun = false;
static boolean useMSAA = true;
- static final int[] texSize = new int[] { 0 };
- static final int fontSize = 24;
static Font font;
+ static float fontSize = 24;
+ static String customStr = null;
@BeforeClass
public static void setup() throws IOException {
- font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ if( null == font ) {
+ font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ // font = FontFactory.get(FontFactory.JAVA).getDefault();
+ }
}
static int atoi(final String a) {
@@ -91,6 +100,15 @@ public class TestTextRendererNEWT10 extends UITestCase {
forceES2 = true;
} else if(args[i].equals("-gl3")) {
forceGL3 = true;
+ } else if(args[i].equals("-font")) {
+ i++;
+ font = FontFactory.get(IOUtil.getResource(TestTextRendererNEWT10.class, args[i]));
+ } else if(args[i].equals("-fontSize")) {
+ i++;
+ fontSize = MiscUtils.atof(args[i], fontSize);
+ } else if(args[i].equals("-text")) {
+ i++;
+ customStr = args[i];
}
}
final String tstname = TestTextRendererNEWT10.class.getName();
@@ -104,17 +122,22 @@ public class TestTextRendererNEWT10 extends UITestCase {
} catch (final InterruptedException ie) {}
}
- // @Test
- public void test00TextRendererNONE01() throws InterruptedException {
- testTextRendererImpl(0);
+ @Test
+ public void test00TextRendererNONE00() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(0, 0);
}
@Test
- public void testTextRendererMSAA01() throws InterruptedException {
- testTextRendererImpl(4);
+ public void test01TextRendererMSAA04() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(0, 4);
}
- void testTextRendererImpl(final int sampleCount) throws InterruptedException {
+ @Test
+ public void test02TextRendererVBAA04() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(Region.VBAA_RENDERING_BIT, 4);
+ }
+
+ void testTextRendererImpl(final int renderModes, final int sampleCount) throws InterruptedException, GLException, IOException {
final GLProfile glp;
if(forceGL3) {
glp = GLProfile.get(GLProfile.GL3);
@@ -123,13 +146,15 @@ public class TestTextRendererNEWT10 extends UITestCase {
} else {
glp = GLProfile.getGL2ES2();
}
+
final GLCapabilities caps = new GLCapabilities( glp );
caps.setAlphaBits(4);
- if( 0 < sampleCount ) {
+ if( 0 < sampleCount && !Region.isVBAA(renderModes) ) {
caps.setSampleBuffers(true);
caps.setNumSamples(sampleCount);
}
System.err.println("Requested: "+caps);
+ System.err.println("Requested: "+Region.getRenderModeString(renderModes));
final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(caps, 800, 400, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
@@ -142,12 +167,13 @@ public class TestTextRendererNEWT10 extends UITestCase {
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
- final TextRegionUtil textRenderUtil = new TextRegionUtil(0);
+ final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes);
// init
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
renderer.init(gl, 0);
rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
+ screenshot = new GLReadBufferUtil(false, false);
// reshape
gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
@@ -155,32 +181,40 @@ public class TestTextRendererNEWT10 extends UITestCase {
// renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f);
+ final int[] sampleCountIO = { sampleCount };
// display
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000);
-
- int c = 0;
- renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000);
-
+ if( null == customStr ) {
+ renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000,sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000, sampleCountIO);
+
+ int c = 0;
+ renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000, sampleCountIO);
+ } else {
+ renderString(drawable, gl, renderer, textRenderUtil, customStr, 0, 0, -1000, sampleCountIO);
+ }
drawable.swapBuffers();
+ printScreen(renderModes, drawable, gl, false, sampleCount);
+
sleep();
// dispose
+ screenshot.dispose(gl);
renderer.destroy(gl);
NEWTGLContext.destroyWindow(winctx);
}
+ private GLReadBufferUtil screenshot;
int lastRow = -1;
- void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0) {
+ void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
final int height = drawable.getSurfaceHeight();
int dx = 0;
@@ -196,8 +230,25 @@ public class TestTextRendererNEWT10 extends UITestCase {
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(dx, dy, z0);
- textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, texSize);
+ textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount);
lastRow = row;
}
+
+ private int screenshot_num = 0;
+
+ public void printScreen(final int renderModes, final GLDrawable drawable, final GL gl, final boolean exportAlpha, final int sampleCount) throws GLException, IOException {
+ final String dir = "./";
+ final String objName = getSimpleTestName(".")+"-snap"+screenshot_num;
+ screenshot_num++;
+ final String modeS = Region.getRenderModeString(renderModes);
+ final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName,
+ drawable.getChosenGLCapabilities().getNumSamples(),
+ TestTextRendererNEWT10.fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount);
+ final String filename = dir + bname +".png";
+ if(screenshot.readPixels(gl, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
similarity index 64%
copy from src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
copy to src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
index cb9f3e3..b29d886 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWTBugXXXX.java
@@ -27,12 +27,14 @@
*/
package com.jogamp.opengl.test.junit.graph;
+import java.io.File;
import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
@@ -42,6 +44,8 @@ import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.curve.opengl.TextRegionUtil;
@@ -51,27 +55,20 @@ import com.jogamp.graph.geom.SVertex;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.test.junit.util.NEWTGLContext;
import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.PMVMatrix;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestTextRendererNEWT10 extends UITestCase {
- static final boolean DEBUG = false;
- static final boolean TRACE = false;
+public class TestTextRendererNEWTBugXXXX extends UITestCase {
static long duration = 100; // ms
static boolean forceES2 = false;
static boolean forceGL3 = false;
static boolean mainRun = false;
static boolean useMSAA = true;
+ static boolean onlyIssues = false;
- static final int[] texSize = new int[] { 0 };
- static final int fontSize = 24;
- static Font font;
-
- @BeforeClass
- public static void setup() throws IOException {
- font = FontFactory.get(FontFactory.UBUNTU).getDefault();
- }
+ static final float fontSize = 24;
static int atoi(final String a) {
try {
@@ -93,7 +90,7 @@ public class TestTextRendererNEWT10 extends UITestCase {
forceGL3 = true;
}
}
- final String tstname = TestTextRendererNEWT10.class.getName();
+ final String tstname = TestTextRendererNEWTBugXXXX.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
@@ -104,17 +101,11 @@ public class TestTextRendererNEWT10 extends UITestCase {
} catch (final InterruptedException ie) {}
}
- // @Test
- public void test00TextRendererNONE01() throws InterruptedException {
- testTextRendererImpl(0);
- }
-
@Test
- public void testTextRendererMSAA01() throws InterruptedException {
- testTextRendererImpl(4);
+ public void test00() throws InterruptedException, GLException, IOException {
+ testTextRendererImpl(FontSet01.getSet01(), Region.VBAA_RENDERING_BIT, 4);
}
-
- void testTextRendererImpl(final int sampleCount) throws InterruptedException {
+ void testTextRendererImpl(final Font[] fonts, final int renderModes, final int sampleCount) throws InterruptedException, GLException, IOException {
final GLProfile glp;
if(forceGL3) {
glp = GLProfile.get(GLProfile.GL3);
@@ -123,15 +114,19 @@ public class TestTextRendererNEWT10 extends UITestCase {
} else {
glp = GLProfile.getGL2ES2();
}
+
final GLCapabilities caps = new GLCapabilities( glp );
caps.setAlphaBits(4);
- if( 0 < sampleCount ) {
+ if( 0 < sampleCount && !Region.isVBAA(renderModes) ) {
caps.setSampleBuffers(true);
caps.setNumSamples(sampleCount);
}
System.err.println("Requested: "+caps);
+ System.err.println("Requested: "+Region.getRenderModeString(renderModes));
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(caps, 800, 400, true);
+ final NEWTGLContext.WindowContext winctx =
+ // NEWTGLContext.createOnscreenWindow(caps, 800, 400, true);
+ NEWTGLContext.createOffscreenWindow(caps, 800, 200*fonts.length, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
@@ -142,12 +137,13 @@ public class TestTextRendererNEWT10 extends UITestCase {
final RenderState rs = RenderState.createRenderState(SVertex.factory());
final RegionRenderer renderer = RegionRenderer.create(rs, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
rs.setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
- final TextRegionUtil textRenderUtil = new TextRegionUtil(0);
+ final TextRegionUtil textRenderUtil = new TextRegionUtil(renderModes);
// init
gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
renderer.init(gl, 0);
rs.setColorStatic(0.1f, 0.1f, 0.1f, 1.0f);
+ screenshot = new GLReadBufferUtil(false, false);
// reshape
gl.glViewport(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
@@ -155,32 +151,38 @@ public class TestTextRendererNEWT10 extends UITestCase {
// renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
renderer.reshapeOrtho(drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0.1f, 1000.0f);
+ final int[] sampleCountIO = { sampleCount };
// display
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- renderString(drawable, gl, renderer, textRenderUtil, "012345678901234567890123456789", 0, 0, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "Hello World", 0, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "4567890123456", 4, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "I like JogAmp", 4, -1, -1000);
-
- int c = 0;
- renderString(drawable, gl, renderer, textRenderUtil, "GlueGen", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOAL", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOGL", c++, -1, -1000);
- renderString(drawable, gl, renderer, textRenderUtil, "JOCL", c++, -1, -1000);
+ for(int i=0; i<fonts.length; i++) {
+ final Font font = fonts[i];
+ renderString(drawable, gl, renderer, font, textRenderUtil, font.getFullFamilyName(null).toString()+": "+issues, 0, 0==i?0:-1, -1000, sampleCountIO);
+ if(!onlyIssues) {
+ renderString(drawable, gl, renderer, font, textRenderUtil, "012345678901234567890123456789", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, font, textRenderUtil, "abcdefghijklmnopqrstuvwxyz", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, font, textRenderUtil, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO);
+ renderString(drawable, gl, renderer, font, textRenderUtil, "", 0, -1, -1000, sampleCountIO);
+ }
+ }
drawable.swapBuffers();
+ printScreen(renderModes, drawable, gl, false, sampleCount);
+
sleep();
// dispose
+ screenshot.dispose(gl);
renderer.destroy(gl);
NEWTGLContext.destroyWindow(winctx);
}
+ private static final String issues = "m M n u 8 g q Q";
+ private GLReadBufferUtil screenshot;
int lastRow = -1;
- void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0) {
+ void renderString(final GLDrawable drawable, final GL2ES2 gl, final RegionRenderer renderer, final Font font, final TextRegionUtil textRenderUtil, final String text, final int column, int row, final int z0, final int[] sampleCount) {
final int height = drawable.getSurfaceHeight();
int dx = 0;
@@ -196,8 +198,25 @@ public class TestTextRendererNEWT10 extends UITestCase {
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glLoadIdentity();
pmv.glTranslatef(dx, dy, z0);
- textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, texSize);
+ textRenderUtil.drawString3D(gl, renderer, font, fontSize, text, null, sampleCount);
lastRow = row;
}
+
+ private int screenshot_num = 0;
+
+ public void printScreen(final int renderModes, final GLDrawable drawable, final GL gl, final boolean exportAlpha, final int sampleCount) throws GLException, IOException {
+ final String dir = "./";
+ final String objName = getSimpleTestName(".")+"-snap"+screenshot_num;
+ screenshot_num++;
+ final String modeS = Region.getRenderModeString(renderModes);
+ final String bname = String.format("%s-msaa%02d-fontsz%02.1f-%03dx%03d-%s%04d", objName,
+ drawable.getChosenGLCapabilities().getNumSamples(),
+ TestTextRendererNEWTBugXXXX.fontSize, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), modeS, sampleCount);
+ final String filename = dir + bname +".png";
+ if(screenshot.readPixels(gl, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java
index 06d8692..a8cd320 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/GLEventListenerButton.java
@@ -89,8 +89,8 @@ public class GLEventListenerButton extends TextureSeqButton {
final GLContext ctx = gl.getContext();
final GLDrawable drawable = ctx.getGLDrawable();
- final GLCapabilitiesImmutable capsHas = drawable.getChosenGLCapabilities();
- final GLCapabilities caps = (GLCapabilities) capsHas.cloneMutable();
+ final GLCapabilitiesImmutable reqCaps = drawable.getRequestedGLCapabilities();
+ final GLCapabilities caps = (GLCapabilities) reqCaps.cloneMutable();
caps.setFBO(true);
caps.setDoubleBuffered(false);
if( !useAlpha ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMono.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMono.ttf
new file mode 100644
index 0000000..c420056
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMono.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBold.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBold.ttf
new file mode 100644
index 0000000..0bee057
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBold.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBoldOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBoldOblique.ttf
new file mode 100644
index 0000000..91bbc0e
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoBoldOblique.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoOblique.ttf
new file mode 100644
index 0000000..3252bdd
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeMonoOblique.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSans.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSans.ttf
new file mode 100644
index 0000000..e56dc6e
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSans.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBold.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBold.ttf
new file mode 100644
index 0000000..66e19ec
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBold.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBoldOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBoldOblique.ttf
new file mode 100644
index 0000000..de8a9e1
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansBoldOblique.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansOblique.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansOblique.ttf
new file mode 100644
index 0000000..b0357ea
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSansOblique.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerif.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerif.ttf
new file mode 100644
index 0000000..dffa1ae
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerif.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBold.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBold.ttf
new file mode 100644
index 0000000..e2393ad
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBold.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBoldItalic.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBoldItalic.ttf
new file mode 100644
index 0000000..46bc469
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifBoldItalic.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifItalic.ttf b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifItalic.ttf
new file mode 100644
index 0000000..d173e35
Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/graph/fonts/freefont/FreeSerifItalic.ttf differ
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
index 26974eb..710f53f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java
@@ -48,7 +48,18 @@ import com.jogamp.opengl.test.junit.graph.TextRendererGLELBase;
import com.jogamp.opengl.test.junit.util.UITestCase;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * Analyzes behavior of reported bugs
+ * <ul>
+ * <li>Bug 841 - GLJPanel "lagging" by one frame, https://jogamp.org/bugzilla/show_bug.cgi?id=841</li>
+ * <li>Bug 975 - GLJPanel's OffscreenDrawable shall not double swap (custom swap by GLEventListener using [AWT]GLReadBufferUtil),
+ * https://jogamp.org/bugzilla/show_bug.cgi?id=975</li>
+ * <li>Bug 1020 - First frame on a mac nvidia card not antialiased, https://jogamp.org/bugzilla/show_bug.cgi?id=841</li>
+ * </ul>
+ * </p>
+ *
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public abstract class GLReadBuffer00Base extends UITestCase {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00BaseAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00BaseAWT.java
new file mode 100644
index 0000000..be0d383
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00BaseAWT.java
@@ -0,0 +1,120 @@
+/**
+ * Copyright 2014 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 com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLEventListener;
+
+import com.jogamp.opengl.util.GLDrawableUtil;
+import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+/**
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
+ */
+public abstract class GLReadBuffer00BaseAWT extends GLReadBuffer00Base {
+
+ protected class SnapshotGLELAWT implements GLEventListener {
+ final TextRendererGLEL textRendererGLEL;
+ final AWTGLReadBufferUtil glReadBufferUtil;
+ final boolean skipGLOrientationVerticalFlip;
+ boolean defAutoSwapMode;
+ boolean swapBuffersBeforeRead;
+ int i;
+
+ SnapshotGLELAWT(final TextRendererGLEL textRendererGLEL, final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) {
+ this.textRendererGLEL = textRendererGLEL;
+ this.glReadBufferUtil = glReadBufferUtil;
+ this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip;
+ this.defAutoSwapMode = true;
+ this.swapBuffersBeforeRead = false;
+ i = 0;
+ }
+
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ defAutoSwapMode = drawable.getAutoSwapBufferMode();
+ swapBuffersBeforeRead = GLDrawableUtil.swapBuffersBeforeRead(drawable.getChosenGLCapabilities());
+ drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead );
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {
+ drawable.setAutoSwapBufferMode( defAutoSwapMode );
+ }
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
+ @Override
+ public void display(final GLAutoDrawable drawable) {
+ snapshot(i++, drawable.getGL(), TextureIO.PNG, null);
+ }
+ public void snapshot(final int sn, final GL gl, final String fileSuffix, final String destPath) {
+ final GLDrawable drawable = gl.getContext().getGLReadDrawable();
+ final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter);
+ final String filenameAWT = getSnapshotFilename(sn, postSNDetail,
+ drawable.getChosenGLCapabilities(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight(),
+ glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
+ if( swapBuffersBeforeRead ) {
+ drawable.swapBuffers();
+ // Just to test whether we use the right buffer,
+ // i.e. back-buffer shall no more be required ..
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ } else {
+ gl.glFinish(); // just make sure rendering finished ..
+ }
+
+ final boolean awtOrientation = !( drawable.isGLOriented() && skipGLOrientationVerticalFlip );
+ System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameAWT);
+
+ final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation);
+ final File fout = new File(filenameAWT);
+ try {
+ ImageIO.write(image, "png", fout);
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ /**
+ final String filenameJGL = getSnapshotFilename(sn, "jgl",
+ drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(),
+ glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
+ glReadBufferUtil.write(new File(filenameJGL));
+ */
+ }
+ };
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java
index c17f669..05f7068 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java
@@ -58,12 +58,12 @@ import com.jogamp.opengl.util.Animator;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug669RecursiveGLContext01NEWT extends UITestCase {
- @Test(timeout=5000)
+ @Test(timeout=10000)
public void test01_Plain() {
test01Impl(false);
}
- @Test(timeout=5000)
+ @Test(timeout=10000)
public void test01_Anim() {
test01Impl(true);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java
index 54afe91..4a8499b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java
@@ -56,12 +56,12 @@ import com.jogamp.opengl.util.Animator;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug669RecursiveGLContext02NEWT extends UITestCase {
- @Test(timeout=5000)
+ @Test(timeout=10000)
public void test01_Plain() {
test01Impl(false);
}
- @Test(timeout=5000)
+ @Test(timeout=10000)
public void test01_Anim() {
test01Impl(true);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
index 2559fe3..929799e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java
@@ -102,7 +102,7 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase {
fbod.destroy();
}
- @Test(timeout = 2000) // 2s timeout
+ @Test(timeout = 10000)
public void testDeadlock() throws InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL( caps );
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
index 6bbe00f..327fecd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java
@@ -76,20 +76,21 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(false);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_DEFAULT, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
}
@Test
public void test01b_GL2ES2_Demo1_SingleBuffer_NoTex() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(false);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_DEPTH, new GearsES2(0));
+ testGLFBODrawableImpl(caps, 0, new GearsES2(0));
}
@Test
public void test01c_GL2ES2_Demo1_SingleBuffer_NoTexNoDepth() throws InterruptedException {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(false);
+ caps.setDepthBits(0);
testGLFBODrawableImpl(caps, 0, new GearsES2(0));
}
@@ -98,7 +99,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities caps = new GLCapabilities(glp);
caps.setDoubleBuffered(true); // default
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_DEFAULT, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
}
@Test
@@ -107,7 +108,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_DEFAULT, new MultisampleDemoES2(true));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new MultisampleDemoES2(true));
}
@Test
public void test03b_GL2ES2_Demo2MSAA4_NoTex() throws InterruptedException {
@@ -115,7 +116,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_DEPTH, new MultisampleDemoES2(true));
+ testGLFBODrawableImpl(caps, 0, new MultisampleDemoES2(true));
}
@Test
public void test03c_GL2ES2_Demo2MSAA4_NoTexNoDepth() throws InterruptedException {
@@ -123,6 +124,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
+ caps.setDepthBits(0);
testGLFBODrawableImpl(caps, 0, new MultisampleDemoES2(true));
}
@@ -134,7 +136,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_DEFAULT, demo);
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, demo);
}
@Test
@@ -142,7 +144,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
if( GLProfile.isAvailable(GLProfile.GLES2) ) {
final GLProfile glp = GLProfile.get(GLProfile.GLES2);
final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_DEFAULT, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
} else {
System.err.println("EGL ES2 n/a");
}
@@ -155,7 +157,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(glp);
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_DEFAULT, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
} else {
System.err.println("EGL ES2 n/a");
}
@@ -166,7 +168,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
if( GLProfile.isAvailable(GLProfile.GL3) ) {
final GLProfile glp = GLProfile.get(GLProfile.GL3);
final GLCapabilities caps = new GLCapabilities(glp);
- testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_DEFAULT, new GearsES2(0));
+ testGLFBODrawableImpl(caps, GLFBODrawable.FBOMODE_USE_TEXTURE, new GearsES2(0));
} else {
System.err.println("GL3 n/a");
}
@@ -179,6 +181,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep);
Assert.assertNotNull(glad);
+ System.out.println("Requested: "+caps);
System.out.println("Realized GLAD: "+glad);
System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities());
Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized());
@@ -192,8 +195,12 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
}
Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized());
- // final boolean useTexture = 0 != ( GLFBODrawable.FBOMODE_USE_TEXTURE & glad.getFBOMode() );
- final boolean useDepth = 0 != ( GLFBODrawable.FBOMODE_USE_DEPTH & glad.getFBOMode() );
+ final boolean expDepth = caps.getDepthBits() > 0;
+ final boolean reqDepth = glad.getRequestedGLCapabilities().getDepthBits() > 0;
+ final boolean hasDepth = glad.getChosenGLCapabilities().getDepthBits() > 0;
+ System.out.println("Depth: exp "+expDepth+", req "+reqDepth+", has "+hasDepth);
+ Assert.assertEquals("Depth: expected not passed to requested", expDepth, reqDepth);
+ Assert.assertEquals("Depth: requested not passed to chosen", reqDepth, hasDepth);
//
// FBO incl. MSAA is fully initialized now
@@ -230,6 +237,13 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
color1 = null;
}
+ final boolean expTexture = 0 != ( GLFBODrawable.FBOMODE_USE_TEXTURE & glad.getFBOMode() );
+ System.out.println("Texture: exp "+expTexture+", hasFront "+color0.isTextureAttachment());
+ Assert.assertEquals("Texture: Front", expTexture, color0.isTextureAttachment());
+ if(0==glad.getNumSamples()) {
+ Assert.assertEquals("Texture: Back", expTexture, color1.isTextureAttachment());
+ }
+
final FBObject.Colorbuffer colorA, colorB;
final FBObject.RenderAttachment depthA, depthB;
@@ -238,7 +252,14 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
colorB = fboBack.getColorbuffer(0);
Assert.assertNotNull(colorB);
- if( useDepth ) {
+ Assert.assertEquals("Texture: Front", expTexture, colorA.isTextureAttachment());
+ if(0==glad.getNumSamples()) {
+ Assert.assertEquals("Texture: Back", expTexture, colorB.isTextureAttachment());
+ } else {
+ Assert.assertEquals("Texture: MSAA Back is Texture", false, colorB.isTextureAttachment());
+ }
+
+ if( hasDepth ) {
depthA = fboFront.getDepthAttachment();
Assert.assertNotNull(depthA);
depthB = fboBack.getDepthAttachment();
@@ -254,7 +275,7 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
// double buffer or MSAA
Assert.assertNotEquals("Color attachments are equal: "+colorB+" == "+colorA, colorA, colorB);
Assert.assertNotSame(colorB, colorA);
- if( useDepth ) {
+ if( hasDepth ) {
Assert.assertNotEquals("Depth attachments are equal: "+depthB+" == "+depthA, depthA, depthB);
Assert.assertNotSame(depthB, depthA);
}
@@ -343,14 +364,14 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment();
System.err.println("Resize1.oldDepth "+depthA);
System.err.println("Resize1.newDepth "+_depth);
- if( useDepth ) {
+ if( hasDepth ) {
Assert.assertNotNull(_depth);
}
Assert.assertEquals(depthA, _depth);
Assert.assertSame(depthA, _depth);
_depth = _fboBack.getDepthAttachment();
- if( useDepth ) {
+ if( hasDepth ) {
Assert.assertNotNull(_depth);
}
Assert.assertEquals(depthB, _depth);
@@ -394,14 +415,14 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase {
Assert.assertSame(colorB, _color);
FBObject.RenderAttachment _depth = fboBack.getDepthAttachment();
- if( useDepth ) {
+ if( hasDepth ) {
Assert.assertNotNull(_depth); // MSAA back w/ depth
}
Assert.assertEquals(depthB, _depth);
Assert.assertSame(depthB, _depth);
_depth = fboFront.getDepthAttachment();
- if( useDepth ) {
+ if( hasDepth ) {
Assert.assertNotNull(_depth);
}
Assert.assertEquals(depthA, _depth);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
index ba57c6d..a293e2c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java
@@ -167,7 +167,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
// FBO w/ 2 texture2D color buffers
final FBObject fbo_mrt = new FBObject();
- fbo_mrt.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
+ fbo_mrt.init(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0);
final TextureAttachment texA0 = fbo_mrt.attachTexture2D(gl, texA0Point, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE);
final TextureAttachment texA1;
if(fbo_mrt.getMaxColorAttachments() > 1) {
@@ -176,7 +176,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
texA1 = null;
System.err.println("FBO supports only one attachment, no MRT available!");
}
- fbo_mrt.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo_mrt.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
Assert.assertTrue( fbo_mrt.isStatusValid() ) ;
fbo_mrt.unbind(gl);
@@ -257,7 +257,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
final int w = width/step * j;
final int h = height/step * j;
System.err.println("resize: "+step_i+" -> "+j+" - "+w+"x"+h);
- fbo_mrt.reset(gl, w, h);
+ fbo_mrt.reset(gl, w, h, 0);
winctx.window.setSize(w, h);
step_i = j;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
index f8feefd..5eebf9c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java
@@ -62,14 +62,14 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestFBOMix2DemosES2NEWT extends UITestCase {
- static long duration = 500; // ms
+ static long duration = 1000; // ms
static int swapInterval = 1;
static boolean showFPS = false;
static boolean forceES2 = false;
static boolean doRotate = true;
static boolean demo0Only = false;
static int globalNumSamples = 0;
- static boolean mainRun = false;
+ static boolean manual = false;
@AfterClass
public static void releaseClass() {
@@ -81,7 +81,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
final GLWindow glWindow = GLWindow.create(caps);
Assert.assertNotNull(glWindow);
glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval);
- if(mainRun) {
+ if(manual) {
glWindow.setSize(512, 512);
} else {
glWindow.setSize(128, 128);
@@ -100,7 +100,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
}
public void dispose(final GLAutoDrawable drawable) {}
public void display(final GLAutoDrawable drawable) {
- if(mainRun) return;
+ if(manual) return;
final int dw = drawable.getSurfaceWidth();
final int dh = drawable.getSurfaceHeight();
@@ -112,18 +112,24 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
snapshot(i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null);
}
if( 3 == c ) {
+ demo.setMSAA(4);
+ } else if( 6 == c ) {
new Thread() {
@Override
public void run() {
- demo.setMSAA(4);
+ glWindow.setSize(dw+64, dh+64);
} }.start();
- } else if( 6 == c ) {
+ } else if( 9 == c ) {
+ demo.setMSAA(8);
+ } else if( 12 == c ) {
+ demo.setMSAA(0);
+ } else if( 15 == c ) {
new Thread() {
@Override
public void run() {
- demo.setMSAA(8);
+ glWindow.setSize(dw+128, dh+128);
} }.start();
- } else if(9 == c) {
+ } else if( 18 == c ) {
c=0;
new Thread() {
@Override
@@ -203,8 +209,8 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
}
@Test
- public void test01_Main() throws InterruptedException {
- if( mainRun ) {
+ public void test00_Manual() throws InterruptedException {
+ if( manual ) {
final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setAlphaBits(1);
runTestGL(caps, globalNumSamples);
@@ -212,17 +218,25 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
}
@Test
- public void test01() throws InterruptedException {
- if( mainRun ) return ;
+ public void test01_startMSAA0() throws InterruptedException {
+ if( manual ) return ;
final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setAlphaBits(1);
runTestGL(caps, 0);
}
+ @Test
+ public void test02_startMSAA4() throws InterruptedException {
+ if( manual ) return ;
+ final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
+ caps.setAlphaBits(1);
+ runTestGL(caps, 4);
+ }
+
public static void main(final String args[]) throws IOException {
boolean waitForKey = false;
- mainRun = true;
+ manual = false;
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -244,13 +258,14 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase {
demo0Only = true;
} else if(args[i].equals("-wait")) {
waitForKey = true;
- } else if(args[i].equals("-nomain")) {
- mainRun = false;
+ } else if(args[i].equals("-manual")) {
+ manual = true;
}
}
System.err.println("swapInterval "+swapInterval);
System.err.println("forceES2 "+forceES2);
+ System.err.println("manual "+manual);
if(waitForKey) {
final BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLOffscreenAutoDrawableBug1044AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLOffscreenAutoDrawableBug1044AWT.java
new file mode 100644
index 0000000..18ac7ab
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLOffscreenAutoDrawableBug1044AWT.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2014 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 com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.fixedfunc.GLLightingFunc;
+
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
+
+ at FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestGLOffscreenAutoDrawableBug1044AWT extends UITestCase {
+
+ @Test
+ public void test01GLOffscreenDrawable() throws InterruptedException {
+ final GLReadBufferUtil readBufferUtilRGB888 = new GLReadBufferUtil(false, false);
+ final GLReadBufferUtil readBufferUtilRGBA8888 = new GLReadBufferUtil(true, false);
+ final GLDrawableFactory fac = GLDrawableFactory.getFactory(GLProfile.getDefault());
+ final GLCapabilities glCap = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
+ // Without line below, there is an error on Windows.
+ glCap.setDoubleBuffered(false);
+ //makes a new buffer 100x100
+ final GLDrawable glad = fac.createOffscreenDrawable(null, glCap, null, 100, 100);
+ glad.setRealized(true);
+ final GLContext context = glad.createContext(null);
+ context.makeCurrent();
+
+ System.err.println("Chosen: "+glad.getChosenGLCapabilities());
+
+ final GL2 gl2 = context.getGL().getGL2();
+ gl2.glViewport(0, 0, 100, 100);
+
+ gl2.glShadeModel(GLLightingFunc.GL_SMOOTH);
+ gl2.glClearColor(1.0f, 0.80f, 0.80f, 1); // This Will Clear The Background Color
+ gl2.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
+ gl2.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ gl2.glLoadIdentity(); // Reset The Projection Matrix
+
+ final AWTGLReadBufferUtil agb = new AWTGLReadBufferUtil(glad.getGLProfile(), true);
+ final BufferedImage image = agb.readPixelsToBufferedImage(context.getGL(), true);
+ try {
+ ImageIO.write(image, "PNG", new File(getSimpleTestName(".")+"-AWTImageIO.png"));
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+
+ if(readBufferUtilRGB888.readPixels(gl2, false)) {
+ readBufferUtilRGB888.write(new File(getSimpleTestName(".")+"-PNGJ-rgb_.png"));
+ }
+ readBufferUtilRGB888.dispose(gl2);
+ if(readBufferUtilRGBA8888.readPixels(gl2, false)) {
+ readBufferUtilRGBA8888.write(new File(getSimpleTestName(".")+"-PNGJ-rgba.png"));
+ }
+ readBufferUtilRGBA8888.dispose(gl2);
+
+ context.destroy();
+ glad.setRealized(false);
+ System.out.println("Done!");
+ }
+
+ public static void main(final String[] args) {
+ org.junit.runner.JUnitCore.main(TestGLOffscreenAutoDrawableBug1044AWT.class.getName());
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
index 5861d42..69ddb77 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
@@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -44,8 +45,27 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestGLProfile00NEWT extends UITestCase {
@Test
- public void testInitSingleton() throws InterruptedException {
+ public void test01InternedString() {
+ final String s1 = "GL2";
+ final String s2 = "GL2";
+ Assert.assertEquals(s1, s2);
+ Assert.assertTrue("s1-ref != s2-ref", s1 == s2);
+ Assert.assertTrue("s1-ref != 'GL2'-ref", s1 == "GL2");
+
+ Assert.assertEquals("GL2", GLProfile.GL2);
+ Assert.assertTrue("GLProfile-ref != 'GL2'-ref", GLProfile.GL2 == "GL2");
+ }
+
+ @Test
+ public void test02InitSingleton() throws InterruptedException {
+ Assert.assertFalse("JOGL is initialized before usage", GLProfile.isInitialized());
GLProfile.initSingleton();
+ Assert.assertTrue("JOGL is not initialized after enforced initialization", GLProfile.isInitialized());
+ }
+
+ @Test
+ public void test11DumpDesktopGLInfo() throws InterruptedException {
+ Assert.assertTrue("JOGL is not initialized ...", GLProfile.isInitialized());
System.err.println("Desktop");
final GLDrawableFactory desktopFactory = GLDrawableFactory.getDesktopFactory();
if( null != desktopFactory ) {
@@ -54,7 +74,11 @@ public class TestGLProfile00NEWT extends UITestCase {
} else {
System.err.println("\tNULL");
}
+ }
+ @Test
+ public void test12DumpEGLGLInfo() throws InterruptedException {
+ Assert.assertTrue("JOGL is not initialized ...", GLProfile.isInitialized());
System.err.println("EGL");
final GLDrawableFactory eglFactory = GLDrawableFactory.getEGLFactory();
if( null != eglFactory ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
index 9e87513..3262ff9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java
@@ -36,6 +36,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -72,7 +73,556 @@ public class TestGLProfile01NEWT extends UITestCase {
}
}
- static void validate(final GLProfile glp) {
+ //
+ // GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3, GL4ES3, GL3ES3, GL2ES2, GL2ES1, GLES3, GLES2, GLES1
+ //
+ // Real: GL4bc, GL4, GL3bc, GL3, GL2, GLES3, GLES2, GLES1
+ // Maps: GL2GL3, GL4ES3, GL3ES3, GL2ES2, GL2ES1
+ //
+
+ private static void validateGLProfileGL4bc(final GLProfile glp) {
+ Assert.assertTrue(glp.isGL4bc());
+ Assert.assertTrue(glp.isGL4());
+ Assert.assertTrue(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertTrue(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertTrue(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGL4bc(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertTrue(gl.isGL4bc());
+ Assert.assertTrue(gl.isGL4());
+ Assert.assertTrue(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertTrue(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertTrue(ctx.isGL4bc());
+ Assert.assertTrue(ctx.isGL4());
+ Assert.assertTrue(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertTrue(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL4(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertTrue(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertTrue(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGL4(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertTrue(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertTrue(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) {
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL3bc(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertTrue(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertTrue(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGL3bc(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertTrue(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertTrue(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertTrue(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertTrue(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL3(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertTrue(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGL3(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertTrue(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(gl.isGL4ES3());
+ } else {
+ Assert.assertFalse(gl.isGL4ES3());
+ }
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertTrue(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ if( gles3CompatAvail ) { // possible w/ GL3 implementations!
+ Assert.assertTrue(ctx.isGL4ES3());
+ } else {
+ Assert.assertFalse(ctx.isGL4ES3());
+ }
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL2(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertTrue(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertTrue(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertFalse(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGL2(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertTrue(gl.isGL2());
+ Assert.assertTrue(gl.isGL2GL3());
+ Assert.assertFalse(gl.isGL4ES3());
+ Assert.assertFalse(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertTrue(ctx.isGL2());
+ Assert.assertTrue(ctx.isGL2GL3());
+ Assert.assertFalse(ctx.isGL4ES3());
+ Assert.assertFalse(ctx.isGL3ES3());
+ Assert.assertFalse(gles3CompatAvail);
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGLES3(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertTrue(glp.isGLES3());
+ Assert.assertTrue(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertFalse(glp.isGL2GL3());
+ Assert.assertTrue(glp.isGL4ES3());
+ Assert.assertTrue(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGLES3(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertFalse(gl.isGL2GL3());
+ Assert.assertTrue(gl.isGL4ES3());
+ Assert.assertTrue(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertTrue(gl.isGLES3());
+ Assert.assertTrue(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertFalse(ctx.isGL2GL3());
+ Assert.assertTrue(ctx.isGL4ES3());
+ Assert.assertTrue(ctx.isGL3ES3());
+ Assert.assertTrue(gles3CompatAvail);
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertTrue(ctx.isGLES3());
+ Assert.assertTrue(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGLES2(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertTrue(glp.isGLES2());
+ Assert.assertFalse(glp.isGLES1());
+ Assert.assertFalse(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertFalse(glp.isGL3ES3());
+ Assert.assertTrue(glp.isGL2ES2());
+ Assert.assertFalse(glp.isGL2ES1());
+ }
+ private static void validateGLES2(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertFalse(gl.isGL2GL3());
+ Assert.assertFalse(gl.isGL4ES3());
+ Assert.assertFalse(gl.isGL3ES3());
+ Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertFalse(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertTrue(gl.isGLES2());
+ Assert.assertFalse(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertFalse(ctx.isGL2GL3());
+ Assert.assertFalse(ctx.isGL4ES3());
+ Assert.assertFalse(ctx.isGL3ES3());
+ Assert.assertFalse(gles3CompatAvail);
+ Assert.assertTrue(ctx.isGL2ES2());
+ Assert.assertFalse(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertTrue(ctx.isGLES2());
+ Assert.assertFalse(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGLES1(final GLProfile glp) {
+ Assert.assertFalse(glp.isGL4bc());
+ Assert.assertFalse(glp.isGL4());
+ Assert.assertFalse(glp.isGL3bc());
+ Assert.assertFalse(glp.isGL3());
+ Assert.assertFalse(glp.isGL2());
+ Assert.assertFalse(glp.isGLES3());
+ Assert.assertFalse(glp.isGLES2());
+ Assert.assertTrue(glp.isGLES1());
+ Assert.assertFalse(glp.isGL2GL3());
+ Assert.assertFalse(glp.isGL4ES3());
+ Assert.assertFalse(glp.isGL3ES3());
+ Assert.assertFalse(glp.isGL2ES2());
+ Assert.assertTrue(glp.isGL2ES1());
+ }
+ private static void validateGLES1(final GL gl) {
+ final GLContext ctx = gl.getContext();
+ final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+
+ Assert.assertFalse(gl.isGL4bc());
+ Assert.assertFalse(gl.isGL4());
+ Assert.assertFalse(gl.isGL3bc());
+ Assert.assertFalse(gl.isGL3());
+ Assert.assertFalse(gl.isGL2());
+ Assert.assertFalse(gl.isGL2GL3());
+ Assert.assertFalse(gl.isGL4ES3());
+ Assert.assertFalse(gl.isGL3ES3());
+ Assert.assertFalse(gl.isGL2ES2());
+ Assert.assertTrue(gl.isGL2ES1());
+ Assert.assertFalse(gl.isGLES3());
+ Assert.assertFalse(gl.isGLES2());
+ Assert.assertTrue(gl.isGLES1());
+
+ Assert.assertFalse(ctx.isGL4bc());
+ Assert.assertFalse(ctx.isGL4());
+ Assert.assertFalse(ctx.isGL3bc());
+ Assert.assertFalse(ctx.isGL3());
+ Assert.assertFalse(ctx.isGL2());
+ Assert.assertFalse(ctx.isGL2GL3());
+ Assert.assertFalse(ctx.isGL4ES3());
+ Assert.assertFalse(ctx.isGL3ES3());
+ Assert.assertFalse(gles3CompatAvail);
+ Assert.assertFalse(ctx.isGL2ES2());
+ Assert.assertTrue(ctx.isGL2ES1());
+ Assert.assertFalse(ctx.isGLES3());
+ Assert.assertFalse(ctx.isGLES2());
+ Assert.assertTrue(ctx.isGLES1());
+ }
+
+ private static void validateGLProfileGL2GL3(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if(glp.isGL3bc()) {
+ validateGLProfileGL3bc(glp);
+ } else if(glp.isGL2()) {
+ validateGLProfileGL2(glp);
+ } else if(glp.isGL4()) {
+ validateGLProfileGL4(glp);
+ } else if(glp.isGL3()) {
+ validateGLProfileGL3(glp);
+ } else {
+ throw new GLException("GL2GL3 is neither GL4bc, GL3bc, GL2, GL4 nor GL3");
+ }
+ }
+ private static void validateGL2GL3(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if(gl.isGL3bc()) {
+ validateGL3bc(gl);
+ } else if(gl.isGL2()) {
+ validateGL2(gl);
+ } else if(gl.isGL4()) {
+ validateGL4(gl);
+ } else if(gl.isGL3()) {
+ validateGL3(gl);
+ } else {
+ throw new GLException("GL2GL3 is neither GL4bc, GL3bc, GL2, GL4 nor GL3");
+ }
+ }
+
+ private static void validateGLProfileGL4ES3(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if( glp.isGL4() ) {
+ validateGLProfileGL4(glp);
+ } else if( glp.isGLES3() ) {
+ validateGLProfileGLES3(glp);
+ } else {
+ throw new GLException("GL4ES3 is neither GL4bc, GL4 nor GLES3");
+ }
+ }
+ private static void validateGL4ES3(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL4() ) {
+ validateGL4(gl);
+ } else if( gl.isGLES3() ) {
+ validateGLES3(gl);
+ } else {
+ throw new GLException("GL4ES3 is neither GL4bc, GL4 nor GLES3");
+ }
+ }
+
+ private static void validateGLProfileGL2ES2(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if(glp.isGL3bc()) {
+ validateGLProfileGL3bc(glp);
+ } else if(glp.isGL2()) {
+ validateGLProfileGL2(glp);
+ } else if(glp.isGL4()) {
+ validateGLProfileGL4(glp);
+ } else if(glp.isGL3()) {
+ validateGLProfileGL3(glp);
+ } else if(glp.isGLES3()) {
+ validateGLProfileGLES3(glp);
+ } else if(glp.isGLES2()) {
+ validateGLProfileGLES2(glp);
+ } else {
+ throw new GLException("GL2ES2 is neither GL4bc, GL3bc, GL2, GL4, GL3, GLES3 nor GLES2");
+ }
+ }
+ private static void validateGL2ES2(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if(gl.isGL3bc()) {
+ validateGL3bc(gl);
+ } else if(gl.isGL2()) {
+ validateGL2(gl);
+ } else if(gl.isGL4()) {
+ validateGL4(gl);
+ } else if(gl.isGL3()) {
+ validateGL3(gl);
+ } else if(gl.isGLES3()) {
+ validateGLES3(gl);
+ } else if(gl.isGLES2()) {
+ validateGLES2(gl);
+ } else {
+ throw new GLException("GL2ES2 is neither GL4bc, GL3bc, GL2, GL4, GL3, GLES3 nor GLES2");
+ }
+ }
+
+ private static void validateGLProfileGL2ES1(final GLProfile glp) {
+ if( glp.isGL4bc() ) {
+ validateGLProfileGL4bc(glp);
+ } else if(glp.isGL3bc()) {
+ validateGLProfileGL3bc(glp);
+ } else if(glp.isGL2()) {
+ validateGLProfileGL2(glp);
+ } else if(glp.isGLES1()) {
+ validateGLProfileGLES1(glp);
+ } else {
+ throw new GLException("GL2ES1 is neither GL4bc, GL3bc, GL2 nor GLES1");
+ }
+ }
+ private static void validateGL2ES1(final GL gl) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if(gl.isGL3bc()) {
+ validateGL3bc(gl);
+ } else if(gl.isGL2()) {
+ validateGL2(gl);
+ } else if(gl.isGLES1()) {
+ validateGLES1(gl);
+ } else {
+ throw new GLException("GL2ES1 is neither GL4bc, GL3bc, GL2 nor GLES1");
+ }
+ }
+
+ private static void validateOffline(final String requestedProfile, final GLProfile glp) {
+ System.err.println("GLProfile Mapping "+requestedProfile+" -> "+glp);
+
final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(GLProfile.getDefaultDevice());
if( glp.getImplName().equals(GLProfile.GL4bc) ) {
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4bc));
@@ -130,163 +680,233 @@ public class TestGLProfile01NEWT extends UITestCase {
Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES1));
}
if( glp.isGL4bc() ) {
- Assert.assertTrue(glp.isGL4());
- Assert.assertTrue(glp.isGL3bc());
- Assert.assertTrue(glp.isGL3());
- Assert.assertTrue(glp.isGL2());
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL4ES3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES1());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL4bc(glp);
} else if(glp.isGL3bc()) {
- Assert.assertTrue(glp.isGL3());
- Assert.assertTrue(glp.isGL2());
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL2ES1());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL3bc(glp);
} else if(glp.isGL2()) {
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL2ES1());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL2(glp);
} else if(glp.isGL4()) {
- Assert.assertTrue(glp.isGL3());
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL4ES3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL4(glp);
} else if(glp.isGL3()) {
- Assert.assertTrue(glp.isGL2GL3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGL3(glp);
} else if(glp.isGLES3()) {
- Assert.assertTrue(glp.isGL4ES3());
- Assert.assertTrue(glp.isGL3ES3());
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGLES3(glp);
} else if(glp.isGLES2()) {
- Assert.assertTrue(glp.isGL2ES2());
+ validateGLProfileGLES2(glp);
} else if(glp.isGLES1()) {
- Assert.assertTrue(glp.isGL2ES1());
+ validateGLProfileGLES1(glp);
}
+
+ if( requestedProfile == GLProfile.GL4bc ) {
+ validateGLProfileGL4bc(glp);
+ } else if( requestedProfile == GLProfile.GL3bc ) {
+ validateGLProfileGL3bc(glp);
+ } else if( requestedProfile == GLProfile.GL2 ) {
+ validateGLProfileGL2(glp);
+ } else if( requestedProfile == GLProfile.GL4 ) {
+ validateGLProfileGL4(glp);
+ } else if( requestedProfile == GLProfile.GL3 ) {
+ validateGLProfileGL3(glp);
+ } else if( requestedProfile == GLProfile.GLES3 ) {
+ validateGLProfileGLES3(glp);
+ } else if( requestedProfile == GLProfile.GLES2 ) {
+ validateGLProfileGLES2(glp);
+ } else if( requestedProfile == GLProfile.GLES1 ) {
+ validateGLProfileGLES1(glp);
+ } else if( requestedProfile == GLProfile.GL2GL3 ) {
+ validateGLProfileGL2GL3(glp);
+ } else if( requestedProfile == GLProfile.GL4ES3 ) {
+ validateGLProfileGL4ES3(glp);
+ } else if( requestedProfile == GLProfile.GL2ES2 ) {
+ validateGLProfileGL2ES2(glp);
+ } else if( requestedProfile == GLProfile.GL2ES1 ) {
+ validateGLProfileGL2ES1(glp);
+ }
+
}
- static void validate(final GL gl) {
+ static void validateOnline(final String requestedProfile, final GLProfile glpReq, final GL gl) {
final GLContext ctx = gl.getContext();
- final boolean gles3CompatAvail = ctx.isGLES3Compatible();
+ final GLProfile glp = gl.getGLProfile();
+ System.err.println("GLContext Mapping "+requestedProfile+" -> "+glpReq+" -> "+glp+" -> "+ctx.getGLVersion());
+
+ System.err.println("GL impl. class "+gl.getClass().getName());
+ if( gl.isGL4() ) {
+ Assert.assertNotNull( gl.getGL4() );
+ System.err.println("GL Mapping "+glp+" -> GL4");
+ }
if( gl.isGL4bc() ) {
- Assert.assertTrue(gl.isGL4());
- Assert.assertTrue(gl.isGL3bc());
- Assert.assertTrue(gl.isGL3());
- Assert.assertTrue(gl.isGL2());
- Assert.assertTrue(gl.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(gl.isGL4ES3());
- } else {
- Assert.assertFalse(gl.isGL4ES3());
- }
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES1());
- Assert.assertTrue(gl.isGL2ES2());
+ Assert.assertNotNull( gl.getGL4bc() );
+ System.err.println("GL Mapping "+glp+" -> GL4bc");
+ }
+ if( gl.isGL3() ) {
+ Assert.assertNotNull( gl.getGL3() );
+ System.err.println("GL Mapping "+glp+" -> GL3");
+ }
+ if( gl.isGL3bc() ) {
+ Assert.assertNotNull( gl.getGL3bc() );
+ System.err.println("GL Mapping "+glp+" -> GL3bc");
+ }
+ if( gl.isGL2() ) {
+ Assert.assertNotNull( gl.getGL2() );
+ System.err.println("GL Mapping "+glp+" -> GL2");
+ }
+ if( gl.isGLES3() ) {
+ Assert.assertNotNull( gl.getGLES3() );
+ System.err.println("GL Mapping "+glp+" -> GLES3");
+ }
+ if( gl.isGLES2() ) {
+ Assert.assertNotNull( gl.getGLES2() );
+ System.err.println("GL Mapping "+glp+" -> GLES2");
+ }
+ if( gl.isGLES1() ) {
+ Assert.assertNotNull( gl.getGLES1() );
+ System.err.println("GL Mapping "+glp+" -> GLES1");
+ }
+ if( gl.isGL4ES3() ) {
+ Assert.assertNotNull( gl.getGL4ES3() );
+ System.err.println("GL Mapping "+glp+" -> GL4ES3");
+ }
+ if( gl.isGL3ES3() ) {
+ Assert.assertNotNull( gl.getGL3ES3() );
+ System.err.println("GL Mapping "+glp+" -> GL3ES3");
+ }
+ if( gl.isGL2GL3() ) {
+ Assert.assertNotNull( gl.getGL2GL3() );
+ System.err.println("GL Mapping "+glp+" -> GL2GL3");
+ }
+ if( gl.isGL2ES2() ) {
+ Assert.assertNotNull( gl.getGL2ES2() );
+ System.err.println("GL Mapping "+glp+" -> GL2ES2");
+ }
+ if( gl.isGL2ES1() ) {
+ Assert.assertNotNull( gl.getGL2ES1() );
+ System.err.println("GL Mapping "+glp+" -> GL2ES1");
+ }
+
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
} else if(gl.isGL3bc()) {
- Assert.assertTrue(gl.isGL3());
- Assert.assertTrue(gl.isGL2());
- Assert.assertTrue(gl.isGL2GL3());
- Assert.assertTrue(gl.isGL2ES1());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL3bc(gl);
} else if(gl.isGL2()) {
- Assert.assertTrue(gl.isGL2GL3());
- Assert.assertTrue(gl.isGL2ES1());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL2(gl);
} else if(gl.isGL4()) {
- Assert.assertTrue(gl.isGL3());
- Assert.assertTrue(gl.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(gl.isGL4ES3());
- } else {
- Assert.assertFalse(gl.isGL4ES3());
- }
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL4(gl);
} else if(gl.isGL3()) {
- Assert.assertTrue(gl.isGL2GL3());
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGL3(gl);
} else if(gl.isGLES3()) {
- if( gles3CompatAvail ) {
- Assert.assertTrue(gl.isGL4ES3());
- } else {
- Assert.assertFalse(gl.isGL4ES3());
- }
- Assert.assertTrue(gl.isGL3ES3());
- Assert.assertTrue(gl.isGL2ES2());
+ validateGLES3(gl);
} else if(gl.isGLES2()) {
- Assert.assertTrue(gl.isGL2ES2());
+ validateGLES2(gl);
} else if(gl.isGLES1()) {
- Assert.assertTrue(gl.isGL2ES1());
+ validateGLES1(gl);
}
- if( ctx.isGL4bc() ) {
- Assert.assertTrue(ctx.isGL4());
- Assert.assertTrue(ctx.isGL3bc());
- Assert.assertTrue(ctx.isGL3());
- Assert.assertTrue(ctx.isGL2());
- Assert.assertTrue(ctx.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(ctx.isGL4ES3());
+ if( requestedProfile == GLProfile.GL4bc ) {
+ validateGL4bc(gl);
+ } else if( requestedProfile == GLProfile.GL3bc ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL3bc() ) {
+ validateGL3bc(gl);
} else {
- Assert.assertFalse(ctx.isGL4ES3());
+ throw new GLException("GL3bc is neither GL4bc nor GL3bc");
}
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES1());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL3bc()) {
- Assert.assertTrue(ctx.isGL3());
- Assert.assertTrue(ctx.isGL2());
- Assert.assertTrue(ctx.isGL2GL3());
- Assert.assertTrue(ctx.isGL2ES1());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL2()) {
- Assert.assertTrue(ctx.isGL2GL3());
- Assert.assertTrue(ctx.isGL2ES1());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL4()) {
- Assert.assertTrue(ctx.isGL3());
- Assert.assertTrue(ctx.isGL2GL3());
- if( gles3CompatAvail ) {
- Assert.assertTrue(ctx.isGL4ES3());
+ } else if( requestedProfile == GLProfile.GL2 ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL3bc() ) {
+ validateGL3bc(gl);
+ } else if( gl.isGL2() ) {
+ validateGL2(gl);
} else {
- Assert.assertFalse(ctx.isGL4ES3());
+ throw new GLException("GL2 is neither GL4bc, GL3bc, GL2");
}
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGL3()) {
- Assert.assertTrue(ctx.isGL2GL3());
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGLES3()) {
- if( gles3CompatAvail ) {
- Assert.assertTrue(ctx.isGL4ES3());
+ } else if( requestedProfile == GLProfile.GL4 ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL4() ) {
+ validateGL4(gl);
+ } else {
+ throw new GLException("GL4 is neither GL4bc, nor GL4");
+ }
+ } else if( requestedProfile == GLProfile.GL3 ) {
+ if( gl.isGL4bc() ) {
+ validateGL4bc(gl);
+ } else if( gl.isGL3bc() ) {
+ validateGL3bc(gl);
+ } else if( gl.isGL4() ) {
+ validateGL4(gl);
+ } else if( gl.isGL3() ) {
+ validateGL3(gl);
+ } else {
+ throw new GLException("GL3 is neither GL4bc, GL3bc, GL4 nor GL3");
+ }
+ } else if( requestedProfile == GLProfile.GLES3 ) {
+ validateGLES3(gl);
+ } else if( requestedProfile == GLProfile.GLES2 ) {
+ if( gl.isGLES3() ) {
+ validateGLES3(gl);
+ } else if( gl.isGLES2() ) {
+ validateGLES2(gl);
} else {
- Assert.assertFalse(ctx.isGL4ES3());
+ throw new GLException("GLES2 is neither GLES3 nor GLES2");
}
- Assert.assertTrue(ctx.isGL3ES3());
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGLES2()) {
- Assert.assertTrue(ctx.isGL2ES2());
- } else if(ctx.isGLES1()) {
- Assert.assertTrue(ctx.isGL2ES1());
+ } else if( requestedProfile == GLProfile.GLES1 ) {
+ validateGLES1(gl);
+ } else if( requestedProfile == GLProfile.GL2GL3 ) {
+ validateGL2GL3(gl);
+ } else if( requestedProfile == GLProfile.GL4ES3 ) {
+ validateGL4ES3(gl);
+ } else if( requestedProfile == GLProfile.GL2ES2 ) {
+ validateGL2ES2(gl);
+ } else if( requestedProfile == GLProfile.GL2ES1 ) {
+ validateGL2ES1(gl);
}
}
+ void validateOnline(final String requestedProfile, final GLProfile glp) throws InterruptedException {
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setTitle(getSimpleTestName("."));
+
+ glWindow.addGLEventListener(new GLEventListener() {
+
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(JoglVersion.getGLStrings(gl, null, false));
+
+ validateOnline(requestedProfile, glp, gl);
+ }
+
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ }
+
+ public void display(final GLAutoDrawable drawable) {
+ }
+
+ public void dispose(final GLAutoDrawable drawable) {
+ }
+ });
+
+ glWindow.setSize(128, 128);
+ glWindow.setVisible(true);
+
+ glWindow.display();
+ Thread.sleep(100);
+ glWindow.destroy();
+ }
+
@Test
public void test01GLProfileDefault() throws InterruptedException {
System.out.println("GLProfile "+GLProfile.glAvailabilityToString());
System.out.println("GLProfile.getDefaultDevice(): "+GLProfile.getDefaultDevice());
final GLProfile glp = GLProfile.getDefault();
System.out.println("GLProfile.getDefault(): "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline("default", glp);
+ validateOnline("default", glp);
}
@Test
@@ -294,8 +914,8 @@ public class TestGLProfile01NEWT extends UITestCase {
// Assuming at least one programmable profile is available
final GLProfile glp = GLProfile.getMaxProgrammable(true);
System.out.println("GLProfile.getMaxProgrammable(): "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline("maxProgrammable", glp);
+ validateOnline("maxProgrammable", glp);
}
@Test
@@ -303,8 +923,8 @@ public class TestGLProfile01NEWT extends UITestCase {
// Assuming at least one fixed function profile is available
final GLProfile glp = GLProfile.getMaxFixedFunc(true);
System.out.println("GLProfile.getMaxFixedFunc(): "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline("maxFixedFunc", glp);
+ validateOnline("maxFixedFunc", glp);
}
@Test
@@ -314,9 +934,8 @@ public class TestGLProfile01NEWT extends UITestCase {
return;
}
final GLProfile glp = GLProfile.getGL2ES1();
- System.out.println("GLProfile GL2ES1: "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(GLProfile.GL2ES1, glp);
+ validateOnline(GLProfile.GL2ES1, glp);
}
@Test
@@ -326,9 +945,8 @@ public class TestGLProfile01NEWT extends UITestCase {
return;
}
final GLProfile glp = GLProfile.getGL2ES2();
- System.out.println("GLProfile GL2ES2: "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(GLProfile.GL2ES2, glp);
+ validateOnline(GLProfile.GL2ES2, glp);
}
@Test
@@ -338,16 +956,26 @@ public class TestGLProfile01NEWT extends UITestCase {
return;
}
final GLProfile glp = GLProfile.getGL4ES3();
- System.out.println("GLProfile GL4ES3: "+glp);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(GLProfile.GL4ES3, glp);
+ validateOnline(GLProfile.GL4ES3, glp);
+ }
+
+ @Test
+ public void test07GLProfileGL2GL3() throws InterruptedException {
+ if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ System.out.println("GLProfile GL2GL3 n/a");
+ return;
+ }
+ final GLProfile glp = GLProfile.getGL2GL3();
+ validateOffline(GLProfile.GL2GL3, glp);
+ validateOnline(GLProfile.GL2GL3, glp);
}
void testSpecificProfile(final String glps) throws InterruptedException {
if(GLProfile.isAvailable(glps)) {
final GLProfile glp = GLProfile.get(glps);
- validate(glp);
- dumpVersion(glp);
+ validateOffline(glps, glp);
+ validateOnline(glps, glp);
} else {
System.err.println("Profile "+glps+" n/a");
}
@@ -393,78 +1021,6 @@ public class TestGLProfile01NEWT extends UITestCase {
testSpecificProfile(GLProfile.GLES3);
}
- protected void dumpVersion(final GLProfile glp) throws InterruptedException {
- final GLCapabilities caps = new GLCapabilities(glp);
- final GLWindow glWindow = GLWindow.create(caps);
- Assert.assertNotNull(glWindow);
- glWindow.setTitle("TestGLProfile01NEWT");
-
- glWindow.addGLEventListener(new GLEventListener() {
-
- public void init(final GLAutoDrawable drawable) {
- final GL gl = drawable.getGL();
- System.err.println(JoglVersion.getGLStrings(gl, null, true));
-
- validate(gl);
-
- final GLProfile glp = gl.getGLProfile();
- System.err.println("GL impl. class "+gl.getClass().getName());
- if( gl.isGL4() ) {
- Assert.assertNotNull( gl.getGL4() );
- System.err.println("GL Mapping "+glp+" -> GL4");
- }
- if( gl.isGL4bc() ) {
- Assert.assertNotNull( gl.getGL4bc() );
- System.err.println("GL Mapping "+glp+" -> GL4bc");
- }
- if( gl.isGL3() ) {
- Assert.assertNotNull( gl.getGL3() );
- System.err.println("GL Mapping "+glp+" -> GL3");
- }
- if( gl.isGL3bc() ) {
- Assert.assertNotNull( gl.getGL3bc() );
- System.err.println("GL Mapping "+glp+" -> GL3bc");
- }
- if( gl.isGLES3() ) {
- Assert.assertNotNull( gl.getGLES3() );
- System.err.println("GL Mapping "+glp+" -> GLES3");
- }
- if( gl.isGLES2() ) {
- Assert.assertNotNull( gl.getGLES2() );
- System.err.println("GL Mapping "+glp+" -> GLES2");
- }
- if( gl.isGL4ES3() ) {
- Assert.assertNotNull( gl.getGL4ES3() );
- System.err.println("GL Mapping "+glp+" -> GL4ES3");
- }
- if( gl.isGL2ES2() ) {
- Assert.assertNotNull( gl.getGL2ES2() );
- System.err.println("GL Mapping "+glp+" -> GL2ES2");
- }
- if( gl.isGL2ES1() ) {
- Assert.assertNotNull( gl.getGL2ES1() );
- System.err.println("GL Mapping "+glp+" -> GL2ES1");
- }
- }
-
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
- }
-
- public void display(final GLAutoDrawable drawable) {
- }
-
- public void dispose(final GLAutoDrawable drawable) {
- }
- });
-
- glWindow.setSize(128, 128);
- glWindow.setVisible(true);
-
- glWindow.display();
- Thread.sleep(100);
- glWindow.destroy();
- }
-
public static void main(final String args[]) throws IOException {
final String tstname = TestGLProfile01NEWT.class.getName();
org.junit.runner.JUnitCore.main(tstname);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java
index 2b6c84b..37f1c75 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLCanvasAWT.java
@@ -30,15 +30,10 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import javax.imageio.ImageIO;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
@@ -49,18 +44,23 @@ import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.GLDrawableUtil;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
-import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels with AWT GLCanvas
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
+public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00BaseAWT {
@BeforeClass
public static void initClass() {
@@ -77,7 +77,7 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
final Dimension d = new Dimension(320, 240);
final GLCanvas glad = createGLCanvas(caps, d);
final TextRendererGLEL textRendererGLEL = new TextRendererGLEL();
- final SnapshotGLELAWT snapshotGLEL = doSnapshot ? new SnapshotGLELAWT(textRendererGLEL, awtGLReadBufferUtil) : null;
+ final SnapshotGLELAWT snapshotGLEL = doSnapshot ? new SnapshotGLELAWT(textRendererGLEL, awtGLReadBufferUtil, false) : null;
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
@@ -88,9 +88,34 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
// panel.setDoubleBuffered(useSwingDoubleBuffer);
// frame.getContentPane().add(panel);
- final GearsES2 gears = new GearsES2(1);
- gears.setVerbose(false);
- glad.addGLEventListener(gears);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println("GLEventListener init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {}
+ @Override
+ public void display(final GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x,final int y, final int width, final int height) {}
+ });
+ {
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glad.addGLEventListener(gears);
+ }
+ {
+ final MultisampleDemoES2 demo = new MultisampleDemoES2(caps.getSampleBuffers());
+ demo.setClearBuffers(false);;
+ glad.addGLEventListener(demo);
+ }
+
glad.addGLEventListener(textRendererGLEL);
if( doSnapshot ) {
glad.addGLEventListener(snapshotGLEL);
@@ -166,71 +191,6 @@ public class TestGLReadBuffer01GLCanvasAWT extends GLReadBuffer00Base {
return canvas;
}
- private class SnapshotGLELAWT implements GLEventListener {
- final TextRendererGLEL textRendererGLEL;
- final AWTGLReadBufferUtil glReadBufferUtil;
- boolean defAutoSwapMode;
- boolean swapBuffersBeforeRead;
- int i;
-
- SnapshotGLELAWT(final TextRendererGLEL textRendererGLEL, final AWTGLReadBufferUtil glReadBufferUtil) {
- this.textRendererGLEL = textRendererGLEL;
- this.glReadBufferUtil = glReadBufferUtil;
- this.defAutoSwapMode = true;
- this.swapBuffersBeforeRead = false;
- i = 0;
- }
-
- @Override
- public void init(final GLAutoDrawable drawable) {
- defAutoSwapMode = drawable.getAutoSwapBufferMode();
- swapBuffersBeforeRead = GLDrawableUtil.swapBuffersBeforeRead(drawable.getChosenGLCapabilities());
- drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead );
- }
- @Override
- public void dispose(final GLAutoDrawable drawable) {
- drawable.setAutoSwapBufferMode( defAutoSwapMode );
- }
- @Override
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
- @Override
- public void display(final GLAutoDrawable drawable) {
- snapshot(i++, drawable.getGL(), TextureIO.PNG, null);
- }
- public void snapshot(final int sn, final GL gl, final String fileSuffix, final String destPath) {
- final GLDrawable drawable = gl.getContext().getGLReadDrawable();
- final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter);
- final String filenameAWT = getSnapshotFilename(sn, postSNDetail,
- drawable.getChosenGLCapabilities(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- if( swapBuffersBeforeRead ) {
- drawable.swapBuffers();
- // Just to test whether we use the right buffer,
- // i.e. back-buffer shall no more be required ..
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- } else {
- gl.glFinish(); // just make sure rendering finished ..
- }
-
- final boolean awtOrientation = drawable.isGLOriented();
- System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameAWT);
-
- final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation);
- final File fout = new File(filenameAWT);
- try {
- ImageIO.write(image, "png", fout);
- } catch (final IOException e) {
- e.printStackTrace();
- }
- /**
- final String filenameJGL = getSnapshotFilename(sn, "jgl",
- drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- glReadBufferUtil.write(new File(filenameJGL));
- */
- }
- };
-
static GLCapabilitiesImmutable caps = null;
static boolean doSnapshot = true;
static boolean keyFrame = false;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java
index 7f5755f..599392d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java
@@ -29,15 +29,10 @@ package com.jogamp.opengl.test.junit.jogl.acore;
import java.awt.BorderLayout;
import java.awt.Dimension;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import javax.imageio.ImageIO;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLJPanel;
@@ -50,18 +45,24 @@ import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.GlueGenVersion;
+import com.jogamp.common.util.VersionUtil;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.GLDrawableUtil;
import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
-import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels with AWT GLJPanel
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
+public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00BaseAWT {
@BeforeClass
public static void initClass() {
@@ -85,10 +86,34 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
panel.setDoubleBuffered(useSwingDoubleBuffer);
frame.getContentPane().add(panel);
- final GearsES2 gears = new GearsES2(1);
- gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
- gears.setVerbose(false);
- glad.addGLEventListener(gears);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println("GLEventListener init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {}
+ @Override
+ public void display(final GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x,final int y, final int width, final int height) {}
+ });
+ {
+ final GearsES2 gears = new GearsES2(1);
+ gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
+ gears.setVerbose(false);
+ glad.addGLEventListener(gears);
+ }
+ {
+ final MultisampleDemoES2 demo = new MultisampleDemoES2(caps.getSampleBuffers());
+ demo.setClearBuffers(false);;
+ glad.addGLEventListener(demo);
+ }
textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
glad.addGLEventListener(textRendererGLEL);
if( doSnapshot ) {
@@ -102,6 +127,9 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
throwable.printStackTrace();
Assume.assumeNoException( throwable );
}
+ if( keyFrame ) {
+ waitForKey("Post init: Frame# "+textRendererGLEL.frameNo);
+ }
glad.display(); // trigger initialization to get chosen-caps!
final Dimension size0 = frame.getSize();
final Dimension size1 = new Dimension(size0.width+100, size0.height+100);
@@ -166,73 +194,6 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base {
return canvas;
}
- private class SnapshotGLELAWT implements GLEventListener {
- final TextRendererGLEL textRendererGLEL;
- final AWTGLReadBufferUtil glReadBufferUtil;
- final boolean skipGLOrientationVerticalFlip;
- boolean defAutoSwapMode;
- boolean swapBuffersBeforeRead;
- int i;
-
- SnapshotGLELAWT(final TextRendererGLEL textRendererGLEL, final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) {
- this.textRendererGLEL = textRendererGLEL;
- this.glReadBufferUtil = glReadBufferUtil;
- this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip;
- this.defAutoSwapMode = true;
- this.swapBuffersBeforeRead = false;
- i = 0;
- }
-
- @Override
- public void init(final GLAutoDrawable drawable) {
- defAutoSwapMode = drawable.getAutoSwapBufferMode();
- swapBuffersBeforeRead = GLDrawableUtil.swapBuffersBeforeRead(drawable.getChosenGLCapabilities());
- drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead );
- }
- @Override
- public void dispose(final GLAutoDrawable drawable) {
- drawable.setAutoSwapBufferMode( defAutoSwapMode );
- }
- @Override
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { }
- @Override
- public void display(final GLAutoDrawable drawable) {
- snapshot(i++, drawable.getGL(), TextureIO.PNG, null);
- }
- public void snapshot(final int sn, final GL gl, final String fileSuffix, final String destPath) {
- final GLDrawable drawable = gl.getContext().getGLReadDrawable();
- final String postSNDetail = String.format("awt-usr%03d", textRendererGLEL.userCounter);
- final String filenameAWT = getSnapshotFilename(sn, postSNDetail,
- drawable.getChosenGLCapabilities(), drawable.getSurfaceWidth(), drawable.getSurfaceHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- if( swapBuffersBeforeRead ) {
- drawable.swapBuffers();
- // Just to test whether we use the right buffer,
- // i.e. back-buffer shall no more be required ..
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- } else {
- gl.glFinish(); // just make sure rendering finished ..
- }
-
- final boolean awtOrientation = !( drawable.isGLOriented() && skipGLOrientationVerticalFlip );
- System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameAWT);
-
- final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation);
- final File fout = new File(filenameAWT);
- try {
- ImageIO.write(image, "png", fout);
- } catch (final IOException e) {
- e.printStackTrace();
- }
- /**
- final String filenameJGL = getSnapshotFilename(sn, "jgl",
- drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(),
- glReadBufferUtil.hasAlpha(), fileSuffix, destPath);
- glReadBufferUtil.write(new File(filenameJGL));
- */
- }
- };
-
static GLCapabilitiesImmutable caps = null;
static boolean doSnapshot = true;
static boolean keyFrame = false;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java
index 8e0e6bf..4da73db 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java
@@ -42,8 +42,11 @@ import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
+import com.jogamp.common.util.VersionUtil;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLDrawableUtil;
@@ -51,7 +54,11 @@ import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Multiple GLJPanels in a JFrame
+ * Test synchronous GLAutoDrawable display, swap-buffer and read-pixels with NEWT
+ * including non-MSAA and MSAA framebuffer.
+ * <p>
+ * See {@link GLReadBuffer00Base} for related bugs and further details.
+ * </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base {
@@ -73,9 +80,33 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base {
try {
glad.setPosition(64, 64);
glad.setSize(320, 240);
- final GearsES2 gears = new GearsES2(1);
- gears.setVerbose(false);
- glad.addGLEventListener(gears);
+ glad.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) {
+ final GL gl = drawable.getGL();
+ System.err.println(VersionUtil.getPlatformInfo());
+ System.err.println("GLEventListener init on "+Thread.currentThread());
+ System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
+ System.err.println("INIT GL IS: " + gl.getClass().getName());
+ System.err.println(JoglVersion.getGLStrings(gl, null, false).toString());
+ }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) {}
+ @Override
+ public void display(final GLAutoDrawable drawable) {}
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x,final int y, final int width, final int height) {}
+ });
+ {
+ final GearsES2 gears = new GearsES2(1);
+ gears.setVerbose(false);
+ glad.addGLEventListener(gears);
+ }
+ {
+ final MultisampleDemoES2 demo = new MultisampleDemoES2(caps.getSampleBuffers());
+ demo.setClearBuffers(false);;
+ glad.addGLEventListener(demo);
+ }
textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip);
glad.addGLEventListener(textRendererGLEL);
if( doSnapshot ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
index ec37766..e8b21e9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java
@@ -101,7 +101,7 @@ public class TestPBufferDeadlockAWT extends UITestCase {
pbuffer.destroy();
}
- @Test(timeout = 2000) // 2s timeout
+ @Test(timeout = 10000)
public void testDeadlock() throws InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL( caps );
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
index 44ff2d2..c899a31 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java
@@ -108,7 +108,7 @@ public class TestSharedContextListAWT extends UITestCase {
final Gears gears = new Gears(vsync ? 1 : 0);
if(useShared) {
- gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGears(sharedGears);
}
glCanvas.addGLEventListener(gears);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
index 6f8d6c6..38b3f92 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT.java
@@ -99,7 +99,7 @@ public class TestSharedContextListNEWT extends UITestCase {
final Gears gears = new Gears(vsync ? 1 : 0);
if(useShared) {
- gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGears(sharedGears);
}
glWindow.addGLEventListener(gears);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
index 1646777..7f5d503 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java
@@ -100,7 +100,7 @@ public class TestSharedContextListNEWT2 extends UITestCase {
final Gears gears = new Gears(vsync ? 1 : 0);
if(useShared) {
- gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGears(sharedGears);
}
glWindow.addGLEventListener(gears);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
index 11ca642..d3cdf5e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextNewtAWTBug523.java
@@ -79,7 +79,6 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil.WindowClosingListener;
import com.jogamp.opengl.util.Animator;
-import com.jogamp.opengl.util.GLBuffers;
/**
@@ -819,19 +818,7 @@ public class TestSharedContextNewtAWTBug523 extends UITestCase {
}
}
}
-
- final String testname = TestSharedContextNewtAWTBug523.class.getName();
- org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
- testname,
- "filtertrace=true",
- "haltOnError=false",
- "haltOnFailure=false",
- "showoutput=true",
- "outputtoformatters=true",
- "logfailedtests=true",
- "logtestlistenerevents=true",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+testname+".xml" } );
+ org.junit.runner.JUnitCore.main(TestSharedContextNewtAWTBug523.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
index 8f84e29..855dc9c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java
@@ -127,7 +127,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
final GearsES1 gears = new GearsES1(vsync ? 1 : 0);
if(useShared) {
- gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGears(sharedGears);
}
glWindow.addGLEventListener(gears);
@@ -138,12 +138,13 @@ public class TestSharedContextVBOES1NEWT extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true));
- System.err.println("Master Context: ");
- MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
- System.err.println("New Context: ");
- MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ MiscUtils.dumpSharedGLContext("Master Context", sharedDrawable.getContext());
+ MiscUtils.dumpSharedGLContext("New Context", glWindow.getContext());
if( useShared ) {
Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ Assert.assertEquals("Master Context is different", sharedDrawable.getContext(), glWindow.getContext().getSharedMaster());
+ } else {
+
}
Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
index a5b5653..fcbfcb1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java
@@ -157,12 +157,9 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -307,12 +304,9 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java
index 4c9cb72..bac84d4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java
@@ -148,12 +148,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -260,12 +257,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
index d2d1384..54f60f5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java
@@ -122,14 +122,13 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared());
final InsetsImmutable insets = f1.getInsets();
- System.err.println("XXX-C-2.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-1.1", ctx1);
//
// 2nd
//
final GearsES2 g2 = new GearsES2(0);
- g2.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
+ g2.setSharedGears(g1);
final GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2, f1);
final GLContext ctx2 = f2.getContext();
@@ -139,10 +138,8 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
{
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
- System.err.println("XXX-C-2.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-2.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-2.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-2.2", ctx2);
Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size());
@@ -152,7 +149,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
// 3rd
//
final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3());
+ g3.setSharedGears(g1);
final GLWindow f3 = runTestGL(animator, f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3, f1);
@@ -165,12 +162,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
@@ -197,12 +191,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-D-0.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-D-0.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-D-0.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-D-0.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-D-0.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-D-0.3", ctx3);
Assert.assertTrue("Ctx1 is shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is shared", ctx2.isShared());
@@ -221,12 +212,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-D-1.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-D-1.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-D-1.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-D-1.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-D-1.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-D-1.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -245,12 +233,9 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-D-2.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-D-2.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-D-2.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-D-2.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-D-2.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-D-2.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", !ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", !ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
index fb15509..2c547ec 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java
@@ -142,7 +142,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
final GearsES2 gears = new GearsES2(vsync ? 1 : 0);
if(useShared) {
- gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3());
+ gears.setSharedGears(sharedGears);
}
glWindow.addGLEventListener(gears);
@@ -153,12 +153,14 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true));
- System.err.println("Master Context: ");
- MiscUtils.dumpSharedGLContext(sharedDrawable.getContext());
- System.err.println("New Context: ");
- MiscUtils.dumpSharedGLContext(glWindow.getContext());
+ final GLContext sharedMasterContext = sharedDrawable.getContext();
+ MiscUtils.dumpSharedGLContext("Master Context", sharedMasterContext);
+ MiscUtils.dumpSharedGLContext("New Context", glWindow.getContext());
if( useShared ) {
- Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared());
+ Assert.assertEquals("Master Context not shared as expected", true, sharedMasterContext.isShared());
+ Assert.assertEquals("Master Context is different", sharedMasterContext, glWindow.getContext().getSharedMaster());
+ } else {
+ Assert.assertEquals("Master Context is not null", null, glWindow.getContext().getSharedMaster());
}
Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared());
@@ -203,7 +205,45 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
}
@Test
- public void test02CommonAnimatorSharedOffscreen() throws InterruptedException {
+ public void test02EachWithAnimatorSharedOnscreen() throws InterruptedException {
+ initShared(true);
+ final Animator animator1 = new Animator();
+ final Animator animator2 = new Animator();
+ final Animator animator3 = new Animator();
+ final GLWindow f1 = runTestGL(animator1, 0, 0, true, false);
+ final InsetsImmutable insets = f1.getInsets();
+ final GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(),
+ f1.getY()+0, true, false);
+ final GLWindow f3 = runTestGL(animator3, f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), true, false);
+
+ try {
+ Thread.sleep(duration);
+ } catch(final Exception e) {
+ e.printStackTrace();
+ }
+ animator1.stop();
+ animator2.stop();
+ animator3.stop();
+
+ f1.destroy();
+ f2.destroy();
+ f3.destroy();
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false));
+
+ releaseShared();
+ }
+
+ @Test
+ public void test11CommonAnimatorSharedOffscreen() throws InterruptedException {
initShared(false);
final Animator animator = new Animator();
final GLWindow f1 = runTestGL(animator, 0, 0, true, false);
@@ -236,7 +276,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase {
}
@Test
- public void test03EachWithAnimatorSharedOffscreen() throws InterruptedException {
+ public void test12EachWithAnimatorSharedOffscreen() throws InterruptedException {
initShared(false);
final Animator animator1 = new Animator();
final Animator animator2 = new Animator();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
index a101c05..8d04022 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
@@ -33,11 +33,9 @@ import java.util.List;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
-import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLProfile;
-import javax.media.opengl.GLRunnable;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
@@ -55,9 +53,8 @@ import org.junit.runners.MethodSorters;
* Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
* <p>
* This is achieved by using the 1st GLWindow's GLContext as the <i>master</i>
- * and manually triggering creation of the 2nd and 3rd GLWindow when the 1st GLWindow's
- * GLContext becomes created. The trigger is performed by simply
- * inserting a GLRunnable in the 1st GLWindow, which makes the other visible.
+ * and synchronizing via GLSharedContextSetter to postpone creation
+ * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
* </p>
* <p>
* Above method allows random creation of the 1st GLWindow, which triggers
@@ -107,40 +104,43 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
public void syncedOneAnimator(final boolean destroyCleanOrder) throws InterruptedException {
final Animator animator = new Animator();
+ animator.start();
+
final GearsES2 g1 = new GearsES2(0);
+ g1.setSyncObjects(g1); // this is master, since rendered we must use it as sync
final GLWindow f1 = createGLWindow(0, 0, g1);
animator.add(f1);
final InsetsImmutable insets = f1.getInsets();
final GearsES2 g2 = new GearsES2(0);
- g2.setSharedGears(g1);
+ g2.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
animator.add(f2);
+ f2.setVisible(true);
final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
+ g3.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f3 = createGLWindow(f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
animator.add(f3);
+ f3.setVisible(true);
- // f1's shared GLContext is ready !
- f1.invoke(false, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable drawable) {
- Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
- f2.setSharedAutoDrawable(f1);
- f2.setVisible(true);
- f2.display(); // kick off GLContext ..
- f3.setSharedAutoDrawable(f1);
- f3.setVisible(true);
- f3.display(); // kick off GLContext ..
- return true;
- }
- });
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
- f1.setVisible(true);
- f1.display(); // kick off GLContext .. and hence f2 + f3 creation
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false));
+
+ f1.setVisible(true); // kick off f1 GLContext .. and hence allow f2 + f3 creation
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -157,8 +157,6 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
- animator.start(); // post start animator, otherwise display will be suppressed
-
final GLContext ctx1 = f1.getContext();
final GLContext ctx2 = f2.getContext();
final GLContext ctx3 = f3.getContext();
@@ -166,12 +164,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -179,6 +174,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
@@ -225,41 +223,46 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
public void asyncEachAnimator(final boolean destroyCleanOrder) throws InterruptedException {
final Animator a1 = new Animator();
final GearsES2 g1 = new GearsES2(0);
+ g1.setSyncObjects(g1); // this is master, since rendered we must use it as sync
final GLWindow f1 = createGLWindow(0, 0, g1);
a1.add(f1);
a1.start();
- f1.setVisible(true);
final InsetsImmutable insets = f1.getInsets();
final Animator a2 = new Animator();
final GearsES2 g2 = new GearsES2(0);
- g2.setSharedGears(g1);
+ g2.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
a2.add(f2);
a2.start();
+ f2.setVisible(true);
final Animator a3 = new Animator();
final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
+ g3.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f3 = createGLWindow(f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
a3.add(f3);
a3.start();
+ f3.setVisible(true);
- // f1's shared GLContext is ready !
- f1.invoke(false, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable drawable) {
- Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
- f2.setSharedAutoDrawable(f1);
- f2.setVisible(true);
- f3.setSharedAutoDrawable(f1);
- f3.setVisible(true);
- return true;
- }
- });
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
+
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false));
+
+ f1.setVisible(true); // kicks off f1 GLContext .. and hence gears of f2 + f3 completion
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -282,12 +285,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -295,6 +295,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
@@ -335,8 +338,10 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
}
static long duration = 1000; // ms
+ static boolean mainRun = false;
public static void main(final String args[]) {
+ mainRun = true;
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
index bfd1a92..a0d111c 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java
@@ -53,7 +53,7 @@ import org.junit.runners.MethodSorters;
* Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
* <p>
* This is achieved by using the 1st GLWindow as the <i>master</i>
- * and using the build-in blocking mechanism to postpone creation
+ * and synchronizing via GLSharedContextSetter to postpone creation
* of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
* </p>
* <p>
@@ -112,6 +112,8 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
public void syncedOneAnimator(final boolean destroyCleanOrder, final boolean useMappedBuffers) throws InterruptedException {
final Animator animator = new Animator();
+ animator.start();
+
final GearsES2 g1 = new GearsES2(0);
g1.setUseMappedBuffers(useMappedBuffers);
g1.setValidateBuffers(true);
@@ -125,20 +127,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
f1.getY()+0, g2);
f2.setSharedAutoDrawable(f1);
animator.add(f2);
+ f2.setVisible(true); // shall wait until f1 is ready
- final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
- final GLWindow f3 = createGLWindow(f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), g3);
- f3.setSharedAutoDrawable(f1);
- animator.add(f3);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
- f2.setVisible(true); // shall wait until f1 is ready
- f1.setVisible(true); // master ..
- f3.setVisible(true); // shall wait until f1 is ready
- animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
- Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+ f1.setVisible(true); // kicks off f1 GLContext .. and hence gears of f2 + f3 completion
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -150,6 +149,14 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true));
Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1);
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ animator.add(f3);
+ f3.setVisible(true); // shall wait until f1 is ready
+
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
@@ -162,12 +169,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -175,6 +179,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
@@ -241,18 +248,18 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
public void asyncEachAnimator(final boolean destroyCleanOrder, final boolean useMappedBuffers) throws InterruptedException {
final Animator a1 = new Animator();
final GearsES2 g1 = new GearsES2(0);
+ g1.setSyncObjects(g1); // this is master, since rendered we must use it as sync
g1.setUseMappedBuffers(useMappedBuffers);
g1.setValidateBuffers(true);
final GLWindow f1 = createGLWindow(0, 0, g1);
a1.add(f1);
a1.start();
- // f1.setVisible(true); // we do this post f2 .. to test pending creation!
final InsetsImmutable insets = f1.getInsets();
final Animator a2 = new Animator();
final GearsES2 g2 = new GearsES2(0);
- g2.setSharedGears(g1);
+ g2.setSharedGears(g1); // also uses master g1 as sync, if required
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
f2.setSharedAutoDrawable(f1);
@@ -260,19 +267,15 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
a2.start();
f2.setVisible(true);
- f1.setVisible(true); // test pending creation of f2
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
- final Animator a3 = new Animator();
- final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
- final GLWindow f3 = createGLWindow(f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), g3);
- f3.setSharedAutoDrawable(f1);
- a3.add(f3);
- a3.start();
- f3.setVisible(true);
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
- Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid)
+ f1.setVisible(true); // test pending creation of f2
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -284,6 +287,16 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true));
Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+ final Animator a3 = new Animator();
+ final GearsES2 g3 = new GearsES2(0);
+ g3.setSharedGears(g1); // also uses master g1 as sync, if required
+ final GLWindow f3 = createGLWindow(f1.getX()+0,
+ f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f1);
+ a3.add(f3);
+ a3.start();
+ f3.setVisible(true);
+
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
@@ -296,12 +309,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -309,6 +319,9 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx1, ctx3.getSharedMaster());
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
@@ -362,8 +375,10 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase {
static long duration = 1000; // ms
static long durationPostDestroy = 1000; // ms - ~60 frames post destroy
+ static boolean mainRun = false;
public static void main(final String args[]) {
+ mainRun = true;
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT4.java
similarity index 52%
copy from src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT4.java
index a101c05..804badb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT4.java
@@ -29,15 +29,16 @@
package com.jogamp.opengl.test.junit.jogl.acore;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import com.jogamp.newt.opengl.GLWindow;
import javax.media.nativewindow.util.InsetsImmutable;
+import javax.media.opengl.GLAnimatorControl;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLProfile;
-import javax.media.opengl.GLRunnable;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
@@ -52,20 +53,15 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
/**
- * Sharing the VBO of 3 GearsES2 instances, each in their own GLWindow.
+ * Test sharing w/ different shared-master context.
* <p>
- * This is achieved by using the 1st GLWindow's GLContext as the <i>master</i>
- * and manually triggering creation of the 2nd and 3rd GLWindow when the 1st GLWindow's
- * GLContext becomes created. The trigger is performed by simply
- * inserting a GLRunnable in the 1st GLWindow, which makes the other visible.
- * </p>
- * <p>
- * Above method allows random creation of the 1st GLWindow, which triggers
- * creation of the <i>dependent</i> other GLWindow sharing it's GLContext.
+ * This is achieved by using the 1st GLWindow as the <i>master</i>
+ * and synchronizing via GLSharedContextSetter to postpone creation
+ * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created.
* </p>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestSharedContextVBOES2NEWT2 extends UITestCase {
+public class TestSharedContextVBOES2NEWT4 extends UITestCase {
static GLProfile glp;
static GLCapabilities caps;
static int width, height;
@@ -96,17 +92,10 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
}
@Test
- public void test01SyncedOneAnimatorCleanDtorOrder() throws InterruptedException {
- syncedOneAnimator(true);
- }
-
- @Test
- public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException {
- syncedOneAnimator(false);
- }
-
- public void syncedOneAnimator(final boolean destroyCleanOrder) throws InterruptedException {
+ public void test01() throws InterruptedException {
final Animator animator = new Animator();
+ animator.start();
+
final GearsES2 g1 = new GearsES2(0);
final GLWindow f1 = createGLWindow(0, 0, g1);
animator.add(f1);
@@ -116,150 +105,46 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
g2.setSharedGears(g1);
final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
f1.getY()+0, g2);
+ f2.setSharedAutoDrawable(f1);
animator.add(f2);
+ f2.setVisible(true);
final GearsES2 g3 = new GearsES2(0);
g3.setSharedGears(g1);
final GLWindow f3 = createGLWindow(f1.getX()+0,
f1.getY()+height+insets.getTotalHeight(), g3);
+ f3.setSharedAutoDrawable(f2); // Mixed master!
animator.add(f3);
-
- // f1's shared GLContext is ready !
- f1.invoke(false, new GLRunnable() {
+ final AtomicBoolean gotAnimException = new AtomicBoolean(false);
+ final AtomicBoolean gotOtherException = new AtomicBoolean(false);
+ animator.setUncaughtExceptionHandler(new GLAnimatorControl.UncaughtExceptionHandler() {
@Override
- public boolean run(final GLAutoDrawable drawable) {
- Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
- f2.setSharedAutoDrawable(f1);
- f2.setVisible(true);
- f2.display(); // kick off GLContext ..
- f3.setSharedAutoDrawable(f1);
- f3.setVisible(true);
- f3.display(); // kick off GLContext ..
- return true;
+ public void uncaughtException(final GLAnimatorControl _animator, final GLAutoDrawable _drawable, final Throwable _cause) {
+ if( _animator == animator && _drawable == f3 && _cause instanceof RuntimeException ) {
+ System.err.println("Caught expected exception: "+_cause.getMessage());
+ gotAnimException.set(true);
+ } else {
+ System.err.println("Caught unexpected exception: "+_cause.getMessage());
+ _cause.printStackTrace();
+ gotOtherException.set(true);
+ }
}
});
+ f3.setVisible(true);
- f1.setVisible(true);
- f1.display(); // kick off GLContext .. and hence f2 + f3 creation
-
- Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
- Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
- Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, true));
- Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true));
+ Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
- Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true));
- Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
- Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
- Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
-
- animator.start(); // post start animator, otherwise display will be suppressed
-
- final GLContext ctx1 = f1.getContext();
- final GLContext ctx2 = f2.getContext();
- final GLContext ctx3 = f3.getContext();
- {
- final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
- final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
- final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
-
- Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
- Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
- Assert.assertTrue("Ctx3 is not shared", ctx3.isShared());
- Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
- Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
- Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
- }
-
- Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
- Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears());
- Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears());
-
- try {
- Thread.sleep(duration);
- } catch(final Exception e) {
- e.printStackTrace();
- }
- animator.stop();
- Assert.assertEquals(false, animator.isAnimating());
+ Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false));
- if( destroyCleanOrder ) {
- System.err.println("XXX Destroy in clean order NOW");
- f3.destroy();
- f2.destroy();
- f1.destroy();
- } else {
- System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs.");
- f1.destroy();
- f2.destroy();
- f3.destroy();
- }
- Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
- Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false));
- Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false));
- Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false));
- }
-
- @Test
- public void test11AsyncEachAnimatorCleanDtorOrder() throws InterruptedException {
- asyncEachAnimator(true);
- }
-
- @Test
- public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException {
- asyncEachAnimator(false);
- }
-
- public void asyncEachAnimator(final boolean destroyCleanOrder) throws InterruptedException {
- final Animator a1 = new Animator();
- final GearsES2 g1 = new GearsES2(0);
- final GLWindow f1 = createGLWindow(0, 0, g1);
- a1.add(f1);
- a1.start();
- f1.setVisible(true);
-
- final InsetsImmutable insets = f1.getInsets();
-
- final Animator a2 = new Animator();
- final GearsES2 g2 = new GearsES2(0);
- g2.setSharedGears(g1);
- final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(),
- f1.getY()+0, g2);
- a2.add(f2);
- a2.start();
-
- final Animator a3 = new Animator();
- final GearsES2 g3 = new GearsES2(0);
- g3.setSharedGears(g1);
- final GLWindow f3 = createGLWindow(f1.getX()+0,
- f1.getY()+height+insets.getTotalHeight(), g3);
- a3.add(f3);
- a3.start();
-
- // f1's shared GLContext is ready !
- f1.invoke(false, new GLRunnable() {
- @Override
- public boolean run(final GLAutoDrawable drawable) {
- Assert.assertTrue("Ctx is shared before shared creation", !f1.getContext().isShared());
- f2.setSharedAutoDrawable(f1);
- f2.setVisible(true);
- f3.setSharedAutoDrawable(f1);
- f3.setVisible(true);
- return true;
- }
- });
+ f1.setVisible(true); // kick off f1 GLContext .. and hence allow f2 + f3 creation
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true));
@@ -270,11 +155,15 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true));
Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true));
+
Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true));
Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true));
Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true));
+ Assert.assertFalse("Unexpected exception (animator) caught", gotAnimException.get());
+ Assert.assertFalse("Unexpected exception (other) caught", gotOtherException.get());
+
final GLContext ctx1 = f1.getContext();
final GLContext ctx2 = f2.getContext();
final GLContext ctx3 = f3.getContext();
@@ -282,12 +171,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -295,6 +181,9 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size());
Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size());
Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size());
+ Assert.assertEquals("Ctx1 Master Context is different", ctx1, ctx1.getSharedMaster());
+ Assert.assertEquals("Ctx2 Master Context is different", ctx1, ctx2.getSharedMaster());
+ Assert.assertEquals("Ctx3 Master Context is different", ctx2, ctx3.getSharedMaster()); // Mixed master!
}
Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears());
@@ -306,26 +195,14 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
} catch(final Exception e) {
e.printStackTrace();
}
- // Stopped animator allows native windowing system 'repaint' event
- // to trigger GLAD 'display'
- a1.stop();
- Assert.assertEquals(false, a1.isAnimating());
- a2.stop();
- Assert.assertEquals(false, a2.isAnimating());
- a3.stop();
- Assert.assertEquals(false, a3.isAnimating());
+ animator.stop();
+ Assert.assertEquals(false, animator.isAnimating());
+
+ System.err.println("XXX Destroy in clean order NOW");
+ f3.destroy();
+ f2.destroy();
+ f1.destroy();
- if( destroyCleanOrder ) {
- System.err.println("XXX Destroy in clean order NOW");
- f3.destroy();
- f2.destroy();
- f1.destroy();
- } else {
- System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs.");
- f1.destroy();
- f2.destroy();
- f3.destroy();
- }
Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false));
Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false));
Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false));
@@ -349,6 +226,6 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.err.println("Press enter to continue");
System.err.println(stdin.readLine()); */
- org.junit.runner.JUnitCore.main(TestSharedContextVBOES2NEWT2.class.getName());
+ org.junit.runner.JUnitCore.main(TestSharedContextVBOES2NEWT4.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java
index 90cb503..09f4408 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java
@@ -220,12 +220,9 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.3", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
@@ -314,12 +311,9 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase {
final List<GLContext> ctx1Shares = ctx1.getCreatedShares();
final List<GLContext> ctx2Shares = ctx2.getCreatedShares();
final List<GLContext> ctx3Shares = ctx3.getCreatedShares();
- System.err.println("XXX-C-3.1:");
- MiscUtils.dumpSharedGLContext(ctx1);
- System.err.println("XXX-C-3.2:");
- MiscUtils.dumpSharedGLContext(ctx2);
- System.err.println("XXX-C-3.3:");
- MiscUtils.dumpSharedGLContext(ctx3);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.1", ctx1);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx2);
+ MiscUtils.dumpSharedGLContext("XXX-C-3.2", ctx3);
Assert.assertTrue("Ctx1 is not shared", ctx1.isShared());
Assert.assertTrue("Ctx2 is not shared", ctx2.isShared());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java
index 6f38c4b..b752474 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestVersionSemanticsNOUI.java
@@ -37,7 +37,6 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.osjava.jardiff.DiffCriteria;
-import org.osjava.jardiff.SimpleDiffCriteria;
import org.semver.Delta;
import com.jogamp.common.util.JogampVersion;
@@ -49,39 +48,58 @@ import com.jogamp.opengl.JoglVersion;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestVersionSemanticsNOUI extends JunitTracer {
static final String jarFile = "jogl-all.jar";
- static final VersionNumberString preVersionNumber = new VersionNumberString("2.1.5");
- static final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.NON_BACKWARD_COMPATIBLE;
- static final DiffCriteria diffCriteria = new SimpleDiffCriteria();
- // static final DiffCriteria diffCriteria = new PublicDiffCriteria();
+ static final DiffCriteria diffCriteria = new org.osjava.jardiff.SimpleDiffCriteria();
+ // static final DiffCriteria diffCriteria = new org.osjava.jardiff.PublicDiffCriteria();
static final JogampVersion curVersion = JoglVersion.getInstance();
static final VersionNumberString curVersionNumber = new VersionNumberString(curVersion.getImplementationVersion());
- static final Set<String> excludes;
+ static final Set<String> excludesDefault;
static {
- excludes = new HashSet<String>();
- excludes.add("^\\Qjogamp/\\E.*$");
+ excludesDefault = new HashSet<String>();
+ excludesDefault.add("^\\Qjogamp/\\E.*$");
}
// @Test
public void testVersionV212V213() throws IllegalArgumentException, IOException, URISyntaxException {
- testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.2", "2.1.3");
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.2", "2.1.3", excludesDefault);
}
// @Test
public void testVersionV213V214() throws IllegalArgumentException, IOException, URISyntaxException {
- testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.3", "2.1.4");
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.3", "2.1.4", excludesDefault);
}
// @Test
public void testVersionV214V215() throws IllegalArgumentException, IOException, URISyntaxException {
- testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.4", "2.1.5");
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.4", "2.1.5", excludesDefault);
+ }
+
+ // @Test
+ public void testVersionV215V220() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.1.5", "2.2.0", excludesDefault);
+ }
+
+ @Test
+ public void testVersionV220V221() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.2.0", "2.2.1", excludesDefault);
+ }
+
+ // @Test /* Broken backward compat in 2.2.2 !! */
+ public void testVersionV221V222() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.2.1", "2.2.2", excludesDefault);
+ }
+
+ @Test
+ public void testVersionV221V223() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersions(diffCriteria, Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER, "2.2.1", "2.2.3", excludesDefault);
}
void testVersions(final DiffCriteria diffCriteria, final Delta.CompatibilityType expectedCompatibilityType,
- final String v1, final String v2) throws IllegalArgumentException, IOException, URISyntaxException {
+ final String v1, final String v2, final Set<String> excludes)
+ throws IllegalArgumentException, IOException, URISyntaxException {
final VersionNumberString preVersionNumber = new VersionNumberString(v1);
final File previousJar = new File("lib/v"+v1+"/"+jarFile);
@@ -95,7 +113,23 @@ public class TestVersionSemanticsNOUI extends JunitTracer {
}
@Test
- public void testVersionLatest() throws IllegalArgumentException, IOException, URISyntaxException {
+ public void testVersionV220V22X() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersionV22nV22X( new VersionNumberString("2.2.0") );
+ }
+
+ @Test
+ public void testVersionV221V22X() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersionV22nV22X( new VersionNumberString("2.2.1") );
+ }
+
+ @Test
+ public void testVersionV223V22X() throws IllegalArgumentException, IOException, URISyntaxException {
+ testVersionV22nV22X( new VersionNumberString("2.2.3") );
+ }
+
+ void testVersionV22nV22X(final VersionNumberString preVersionNumber) throws IllegalArgumentException, IOException, URISyntaxException {
+ final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER;
+
final File previousJar = new File("lib/v"+preVersionNumber.getVersionString()+"/"+jarFile);
final ClassLoader currentCL = TestVersionSemanticsNOUI.class.getClassLoader();
@@ -103,7 +137,7 @@ public class TestVersionSemanticsNOUI extends JunitTracer {
VersionSemanticsUtil.testVersion(diffCriteria, expectedCompatibilityType,
previousJar, preVersionNumber,
curVersion.getClass(), currentCL, curVersionNumber,
- excludes);
+ excludesDefault);
}
public static void main(final String args[]) throws IOException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java
index 920fdda..b074297 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java
@@ -30,13 +30,13 @@ package com.jogamp.opengl.test.junit.jogl.awt;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
-
import com.jogamp.opengl.test.junit.util.MiscUtils;
+import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Label;
@@ -52,12 +52,20 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestAWT03GLCanvasRecreate01 extends UITestCase {
- static long durationPerTest = 1000; // ms
+ static long durationPerTest = 500; // ms
+
+ final static int sizeEps = 64;
+ final static Dimension size1 = new Dimension(512, 512-sizeEps-1);
+ final static Dimension size2 = new Dimension(512+sizeEps+1+256, 512+256);
+ final static Dimension size3 = new Dimension(512-256, 512-sizeEps-1-256);
Frame frame1=null;
Frame frame2=null;
- GLCanvas glCanvas=null;
- Label label = null;
+ Frame frame3=null;
+ GLCanvas glComp=null;
+ Label label1 = null;
+ Label label2 = null;
+ Label label3 = null;
Animator animator = null;
@BeforeClass
@@ -67,39 +75,50 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
@Before
public void init() {
- glCanvas = new GLCanvas();
- Assert.assertNotNull(glCanvas);
- glCanvas.addGLEventListener(new GearsES2());
+ glComp = new GLCanvas();
+ Assert.assertNotNull(glComp);
+ glComp.addGLEventListener(new GearsES2());
- animator = new Animator(glCanvas);
+ animator = new Animator(glComp);
animator.start();
- label = new Label("No GLCanvas");
-
+ label1 = new Label("L1 - No GLCanvas");
+ label1.setMinimumSize(size1);
+ label1.setPreferredSize(size1);
frame1 = new Frame("Frame 1");
Assert.assertNotNull(frame1);
- frame1.add(label);
- frame1.setSize(512, 512);
+ frame1.add(label1);
frame1.setLocation(0, 0);
+ label2 = new Label("L2 - No GLCanvas");
+ label2.setMinimumSize(size2);
+ label2.setPreferredSize(size2);
frame2 = new Frame("Frame 2");
Assert.assertNotNull(frame2);
- frame2.add(label);
- frame2.setSize(512, 512);
- frame2.setLocation(512, 0);
+ frame2.add(label2);
+ frame2.setLocation(size1.width + size1.width/2, 0);
+
+ label3 = new Label("L3 - No GLCanvas");
+ label3.setMinimumSize(size3);
+ label3.setPreferredSize(size3);
+ frame3 = new Frame("Frame 3");
+ Assert.assertNotNull(frame3);
+ frame3.add(label3);
+ frame3.setLocation(0, size1.height + size1.height/2);
}
@After
public void release() {
Assert.assertNotNull(frame1);
Assert.assertNotNull(frame2);
- Assert.assertNotNull(glCanvas);
+ Assert.assertNotNull(glComp);
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- glCanvas.destroy();
+ glComp.destroy();
frame1.dispose();
frame2.dispose();
+ frame3.dispose();
}});
} catch (final Throwable t) {
t.printStackTrace();
@@ -107,19 +126,22 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
}
frame1=null;
frame2=null;
- glCanvas=null;
+ frame3=null;
+ glComp=null;
animator.stop();
animator=null;
}
- private void addCanvas(final Frame frame) {
+ private void addCanvas(final Frame frame, final Label label, final Dimension size) {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.remove(label);
- frame.add(glCanvas);
- frame.validate();
+ glComp.setPreferredSize(size);
+ glComp.setMinimumSize(size);
+ frame.add(glComp);
+ frame.pack();
}});
} catch (final Throwable t) {
t.printStackTrace();
@@ -127,13 +149,14 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
}
}
- private void removeCanvas(final Frame frame) {
+ private void removeCanvas(final Frame frame, final Label label) {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- frame.remove(glCanvas);
+ frame.remove(glComp);
frame.add(label);
- frame.validate();
+ frame.pack();
+ frame.repaint();
}});
} catch (final Throwable t) {
t.printStackTrace();
@@ -145,6 +168,7 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ frame.pack();
frame.setVisible(v);
}});
} catch (final Throwable t) {
@@ -153,26 +177,56 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
}
}
+ private void assertSize(final Dimension expSize) {
+ final int[] scale = { 1, 1 };
+ glComp.getNativeSurfaceScale(scale);
- @Test
- public void testAddRemove3Times() throws InterruptedException {
- setVisible(frame1, true);
- setVisible(frame2, true);
+ final Dimension hasSize = glComp.getSize(null);
- addCanvas(frame1);
- Thread.sleep(durationPerTest/4);
+ Assert.assertTrue("AWT Size.width mismatch: expected "+expSize+", has "+hasSize,
+ Math.abs(expSize.width-hasSize.width) <= sizeEps);
+ Assert.assertTrue("AWT Size.height mismatch: expected "+expSize+", has "+hasSize,
+ Math.abs(expSize.height-hasSize.height) <= sizeEps);
- removeCanvas(frame1);
- addCanvas(frame2);
- Thread.sleep(durationPerTest/4);
+ final int expSurfWidth = expSize.width * scale[0];
+ final int expSurfHeight = expSize.height * scale[0];
+ final int hasSurfWidth = glComp.getSurfaceWidth();
+ final int hasSurfHeight = glComp.getSurfaceHeight();
- removeCanvas(frame2);
- addCanvas(frame1);
- Thread.sleep(durationPerTest/4);
+ Assert.assertTrue("GL Size.width mismatch: expected "+expSurfWidth+", has "+hasSurfWidth,
+ Math.abs(expSurfWidth-hasSurfWidth) <= sizeEps);
+ Assert.assertTrue("GL Size.height mismatch: expected "+expSurfHeight+", has "+hasSurfHeight,
+ Math.abs(expSurfHeight-hasSurfHeight) <= sizeEps);
+ }
- removeCanvas(frame1);
- addCanvas(frame2);
- Thread.sleep(durationPerTest/4);
+ @Test
+ public void testAddRemove3Times() throws InterruptedException {
+ setVisible(frame1, true);
+ setVisible(frame2, true);
+ setVisible(frame3, true);
+
+ // Init Frame 1
+ addCanvas(frame1, label1, size1);
+ Thread.sleep(durationPerTest);
+ assertSize(size1);
+
+ // Frame 1 -> Frame 2
+ removeCanvas(frame1, label1);
+ addCanvas(frame2, label2, size2);
+ Thread.sleep(durationPerTest);
+ assertSize(size2);
+
+ // Frame 2 -> Frame 3
+ removeCanvas(frame2, label2);
+ addCanvas(frame3, label3, size3);
+ Thread.sleep(durationPerTest);
+ assertSize(size3);
+
+ // Frame 3 -> Frame 1
+ removeCanvas(frame3, label3);
+ addCanvas(frame1, label1, size1);
+ Thread.sleep(durationPerTest);
+ assertSize(size1);
}
public static void main(final String args[]) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLJPanelRecreate01.java
similarity index 50%
copy from src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLJPanelRecreate01.java
index 920fdda..b2d4877 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLCanvasRecreate01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT03GLJPanelRecreate01.java
@@ -29,16 +29,17 @@
package com.jogamp.opengl.test.junit.jogl.awt;
import javax.media.opengl.GLProfile;
-import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.Animator;
+import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
-
import com.jogamp.opengl.test.junit.util.MiscUtils;
-import java.awt.Frame;
-import java.awt.Label;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
import org.junit.Assert;
import org.junit.Assume;
@@ -51,13 +52,21 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestAWT03GLCanvasRecreate01 extends UITestCase {
- static long durationPerTest = 1000; // ms
-
- Frame frame1=null;
- Frame frame2=null;
- GLCanvas glCanvas=null;
- Label label = null;
+public class TestAWT03GLJPanelRecreate01 extends UITestCase {
+ static long durationPerTest = 500; // ms
+
+ final static int sizeEps = 64;
+ final static Dimension size1 = new Dimension(512, 512-sizeEps-1);
+ final static Dimension size2 = new Dimension(512+sizeEps+1+256, 512+256);
+ final static Dimension size3 = new Dimension(512-256, 512-sizeEps-1-256);
+
+ JFrame frame1=null;
+ JFrame frame2=null;
+ JFrame frame3=null;
+ GLJPanel glComp=null;
+ JLabel label1 = null;
+ JLabel label2 = null;
+ JLabel label3 = null;
Animator animator = null;
@BeforeClass
@@ -67,39 +76,50 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
@Before
public void init() {
- glCanvas = new GLCanvas();
- Assert.assertNotNull(glCanvas);
- glCanvas.addGLEventListener(new GearsES2());
+ glComp = new GLJPanel();
+ Assert.assertNotNull(glComp);
+ glComp.addGLEventListener(new GearsES2());
- animator = new Animator(glCanvas);
+ animator = new Animator(glComp);
animator.start();
- label = new Label("No GLCanvas");
-
- frame1 = new Frame("Frame 1");
+ label1 = new JLabel("L1 - No GLJPanel");
+ label1.setMinimumSize(size1);
+ label1.setPreferredSize(size1);
+ frame1 = new JFrame("Frame 1");
Assert.assertNotNull(frame1);
- frame1.add(label);
- frame1.setSize(512, 512);
+ frame1.add(label1);
frame1.setLocation(0, 0);
- frame2 = new Frame("Frame 2");
+ label2 = new JLabel("L2 - No GLJPanel");
+ label2.setMinimumSize(size2);
+ label2.setPreferredSize(size2);
+ frame2 = new JFrame("Frame 2");
Assert.assertNotNull(frame2);
- frame2.add(label);
- frame2.setSize(512, 512);
- frame2.setLocation(512, 0);
+ frame2.add(label2);
+ frame2.setLocation(size1.width, 0);
+
+ label3 = new JLabel("L3 - No GLJPanel");
+ label3.setMinimumSize(size3);
+ label3.setPreferredSize(size3);
+ frame3 = new JFrame("Frame 3");
+ Assert.assertNotNull(frame3);
+ frame3.add(label3);
+ frame3.setLocation(0, size1.height);
}
@After
public void release() {
Assert.assertNotNull(frame1);
Assert.assertNotNull(frame2);
- Assert.assertNotNull(glCanvas);
+ Assert.assertNotNull(glComp);
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- glCanvas.destroy();
+ glComp.destroy();
frame1.dispose();
frame2.dispose();
+ frame3.dispose();
}});
} catch (final Throwable t) {
t.printStackTrace();
@@ -107,19 +127,22 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
}
frame1=null;
frame2=null;
- glCanvas=null;
+ frame3=null;
+ glComp=null;
animator.stop();
animator=null;
}
- private void addCanvas(final Frame frame) {
+ private void addCanvas(final JFrame frame, final JLabel label, final Dimension size) {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- frame.remove(label);
- frame.add(glCanvas);
- frame.validate();
+ frame.getContentPane().remove(label);
+ glComp.setPreferredSize(size);
+ glComp.setMinimumSize(size);
+ frame.getContentPane().add(glComp, BorderLayout.CENTER);
+ frame.pack();
}});
} catch (final Throwable t) {
t.printStackTrace();
@@ -127,13 +150,14 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
}
}
- private void removeCanvas(final Frame frame) {
+ private void removeCanvas(final JFrame frame, final JLabel label) {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- frame.remove(glCanvas);
- frame.add(label);
- frame.validate();
+ frame.getContentPane().remove(glComp);
+ frame.getContentPane().add(label);
+ frame.pack();
+ frame.repaint();
}});
} catch (final Throwable t) {
t.printStackTrace();
@@ -141,10 +165,11 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
}
}
- private void setVisible(final Frame frame, final boolean v) {
+ private void setVisible(final JFrame frame, final boolean v) {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ frame.pack();
frame.setVisible(v);
}});
} catch (final Throwable t) {
@@ -153,26 +178,56 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
}
}
+ private void assertSize(final Dimension expSize) {
+ final int[] scale = { 1, 1 };
+ glComp.getNativeSurfaceScale(scale);
- @Test
- public void testAddRemove3Times() throws InterruptedException {
- setVisible(frame1, true);
- setVisible(frame2, true);
+ final Dimension hasSize = glComp.getSize(null);
- addCanvas(frame1);
- Thread.sleep(durationPerTest/4);
+ Assert.assertTrue("AWT Size.width mismatch: expected "+expSize+", has "+hasSize,
+ Math.abs(expSize.width-hasSize.width) <= sizeEps);
+ Assert.assertTrue("AWT Size.height mismatch: expected "+expSize+", has "+hasSize,
+ Math.abs(expSize.height-hasSize.height) <= sizeEps);
- removeCanvas(frame1);
- addCanvas(frame2);
- Thread.sleep(durationPerTest/4);
+ final int expSurfWidth = expSize.width * scale[0];
+ final int expSurfHeight = expSize.height * scale[0];
+ final int hasSurfWidth = glComp.getSurfaceWidth();
+ final int hasSurfHeight = glComp.getSurfaceHeight();
- removeCanvas(frame2);
- addCanvas(frame1);
- Thread.sleep(durationPerTest/4);
+ Assert.assertTrue("GL Size.width mismatch: expected "+expSurfWidth+", has "+hasSurfWidth,
+ Math.abs(expSurfWidth-hasSurfWidth) <= sizeEps);
+ Assert.assertTrue("GL Size.height mismatch: expected "+expSurfHeight+", has "+hasSurfHeight,
+ Math.abs(expSurfHeight-hasSurfHeight) <= sizeEps);
+ }
- removeCanvas(frame1);
- addCanvas(frame2);
- Thread.sleep(durationPerTest/4);
+ @Test
+ public void testAddRemove3Times() throws InterruptedException {
+ setVisible(frame1, true);
+ setVisible(frame2, true);
+ setVisible(frame3, true);
+
+ // Init Frame 1
+ addCanvas(frame1, label1, size1);
+ Thread.sleep(durationPerTest);
+ assertSize(size1);
+
+ // Frame 1 -> Frame 2
+ removeCanvas(frame1, label1);
+ addCanvas(frame2, label2, size2);
+ Thread.sleep(durationPerTest);
+ assertSize(size2);
+
+ // Frame 2 -> Frame 3
+ removeCanvas(frame2, label2);
+ addCanvas(frame3, label3, size3);
+ Thread.sleep(durationPerTest);
+ assertSize(size3);
+
+ // Frame 3 -> Frame 1
+ removeCanvas(frame3, label3);
+ addCanvas(frame1, label1, size1);
+ Thread.sleep(durationPerTest);
+ assertSize(size1);
}
public static void main(final String args[]) {
@@ -181,6 +236,6 @@ public class TestAWT03GLCanvasRecreate01 extends UITestCase {
durationPerTest = MiscUtils.atoi(args[++i], (int)durationPerTest);
}
}
- org.junit.runner.JUnitCore.main(TestAWT03GLCanvasRecreate01.class.getName());
+ org.junit.runner.JUnitCore.main(TestAWT03GLJPanelRecreate01.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java
index daac8ad..148e107 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java
@@ -87,17 +87,17 @@ public class TestMultisampleES2NEWT extends UITestCase {
testMultiSampleAAImpl(false, true, 0);
}
- @Test(timeout = 3000) // 3s timeout
+ @Test(timeout = 10000)
public void testOffsreenPBufferMultiSampleAA8() throws InterruptedException {
testMultiSampleAAImpl(false, true, 8);
}
- @Test(timeout = 3000) // 3s timeout
+ @Test(timeout = 10000)
public void testOffscreenFBOMultiSampleAA0() throws InterruptedException {
testMultiSampleAAImpl(true, false, 0);
}
- @Test(timeout = 3000) // 3s timeout
+ @Test(timeout = 10000)
public void testOffsreenFBOMultiSampleAA8() throws InterruptedException {
testMultiSampleAAImpl(true, false, 8);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index b1df926..9d20495 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -41,6 +41,7 @@ import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
+import com.jogamp.opengl.GLRendererQuirks;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.jogl.demos.GearsObject;
import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil;
@@ -64,6 +65,8 @@ public class GearsES1 implements GLEventListener {
private final float view_rotz = 0.0f;
private GearsObject gear1=null, gear2=null, gear3=null;
private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue;
+ private GearsES1 sharedGears;
+ private Object syncObjects;
private volatile boolean usesSharedGears = false;
private boolean useMappedBuffers = false;
private boolean validateBuffers = false;
@@ -71,6 +74,7 @@ public class GearsES1 implements GLEventListener {
private final int swapInterval;
private final MouseListener gearsMouse = new GearsMouseAdapter();
private final KeyListener gearsKeys = new GearsKeyAdapter();
+ private volatile boolean isInit = false;
private int prevMouseX, prevMouseY;
@@ -96,10 +100,8 @@ public class GearsES1 implements GLEventListener {
this.gear3Color = gear3Color;
}
- public void setSharedGearsObjects(final GearsObject g1, final GearsObject g2, final GearsObject g3) {
- gear1 = g1;
- gear2 = g2;
- gear3 = g3;
+ public void setSharedGears(final GearsES1 shared) {
+ sharedGears = shared;
}
/**
@@ -123,6 +125,11 @@ public class GearsES1 implements GLEventListener {
public void setValidateBuffers(final boolean v) { validateBuffers = v; }
public void init(final GLAutoDrawable drawable) {
+ if(null != sharedGears && !sharedGears.isInit() ) {
+ System.err.println(Thread.currentThread()+" GearsES1.init.0: pending shared Gears .. re-init later XXXXX");
+ drawable.setGLEventListenerInitState(this, false);
+ return;
+ }
System.err.println(Thread.currentThread()+" GearsES1.init ...");
// Use debug pipeline
@@ -167,28 +174,32 @@ public class GearsES1 implements GLEventListener {
gl.glEnable(GL.GL_DEPTH_TEST);
/* make the gears */
- if(null == gear1) {
+ if( null != sharedGears ) {
+ gear1 = new GearsObjectES1(sharedGears.getGear1());
+ gear2 = new GearsObjectES1(sharedGears.getGear2());
+ gear3 = new GearsObjectES1(sharedGears.getGear3());
+ usesSharedGears = true;
+ System.err.println("gear1 reuse: "+gear1);
+ System.err.println("gear2 reuse: "+gear2);
+ System.err.println("gear3 reuse: "+gear3);
+ if( gl.getContext().hasRendererQuirk(GLRendererQuirks.NeedSharedObjectSync) ) {
+ syncObjects = sharedGears;
+ System.err.println("Shared GearsES1: Synchronized Objects due to quirk "+GLRendererQuirks.toString(GLRendererQuirks.NeedSharedObjectSync));
+ } else {
+ syncObjects = new Object();
+ System.err.println("Shared GearsES1: Unsynchronized Objects");
+ }
+ } else {
gear1 = new GearsObjectES1(gl, useMappedBuffers, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, validateBuffers);
System.err.println("gear1 created: "+gear1);
- } else {
- usesSharedGears = true;
- System.err.println("gear1 reused: "+gear1);
- }
- if(null == gear2) {
gear2 = new GearsObjectES1(gl, useMappedBuffers, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, validateBuffers);
System.err.println("gear2 created: "+gear2);
- } else {
- usesSharedGears = true;
- System.err.println("gear2 reused: "+gear2);
- }
- if(null == gear3) {
gear3 = new GearsObjectES1(gl, useMappedBuffers, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, validateBuffers);
System.err.println("gear3 created: "+gear3);
- } else {
- usesSharedGears = true;
- System.err.println("gear3 reused: "+gear3);
+
+ syncObjects = new Object();
}
gl.glEnable(GLLightingFunc.GL_NORMALIZE);
@@ -203,10 +214,14 @@ public class GearsES1 implements GLEventListener {
new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse, drawable).addTo(comp);
new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys, drawable).addTo(comp);
}
+ isInit = true;
System.err.println(Thread.currentThread()+" GearsES1.init FIN");
}
+ public final boolean isInit() { return isInit; }
+
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ if( !isInit ) { return; }
System.err.println(Thread.currentThread()+" GearsES1.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
final GL2ES1 gl = drawable.getGL().getGL2ES1();
@@ -229,6 +244,8 @@ public class GearsES1 implements GLEventListener {
}
public void dispose(final GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
+ isInit = false;
System.err.println(Thread.currentThread()+" GearsES1.dispose ... ");
final Object upstreamWidget = drawable.getUpstreamWidget();
if (upstreamWidget instanceof Window) {
@@ -243,12 +260,16 @@ public class GearsES1 implements GLEventListener {
gear2 = null;
gear3.destroy(gl);
gear3 = null;
+ sharedGears = null;
+ syncObjects = null;
System.err.println(Thread.currentThread()+" GearsES1.dispose FIN");
}
public void display(final GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
+
// Turn the gears' teeth
- angle += 2.0f;
+ angle += 0.5f;
// Get the GL corresponding to the drawable we are animating
final GL2ES1 gl = drawable.getGL().getGL2ES1();
@@ -286,9 +307,11 @@ public class GearsES1 implements GLEventListener {
gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
- gear1.draw(gl, -3.0f, -2.0f, angle);
- gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f);
- gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f);
+ synchronized ( syncObjects ) {
+ gear1.draw(gl, -3.0f, -2.0f, angle);
+ gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f);
+ gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f);
+ }
// Remember that every push needs a pop; this one is paired with
// rotating the entire gear assembly
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
index bd487ea..1355a44 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java
@@ -43,6 +43,10 @@ public class GearsObjectES1 extends GearsObject {
super(gl, useMappedBuffers, gearColor, inner_radius, outer_radius, width, teeth, tooth_depth, validateBuffers);
}
+ public GearsObjectES1(final GearsObject shared) {
+ super(shared);
+ }
+
@Override
public GLArrayDataServer createInterleaved(final boolean useMappedBuffers, final int comps, final int dataType, final boolean normalized, final int initialSize, final int vboUsage) {
if( useMappedBuffers ) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
index 6cd9723..42f4c5f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java
@@ -49,7 +49,7 @@ public class FBOMix2DemosES2 implements GLEventListener {
private final GearsES2 demo0;
private final RedSquareES2 demo1;
private final int swapInterval;
- private int numSamples;
+ private volatile int numSamples;
private boolean demo0Only;
@@ -156,13 +156,8 @@ public class FBOMix2DemosES2 implements GLEventListener {
}
private void initFBOs(final GL gl, final GLAutoDrawable drawable) {
- // remove all texture attachments, since MSAA uses just color-render-buffer
- // and non-MSAA uses texture2d-buffer
- fbo0.detachAllColorbuffer(gl);
- fbo1.detachAllColorbuffer(gl);
-
- fbo0.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, false);
- fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, false);
+ fbo0.init(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
+ fbo1.init(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
if(fbo0.getNumSamples() != fbo1.getNumSamples()) {
throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1);
}
@@ -180,15 +175,15 @@ public class FBOMix2DemosES2 implements GLEventListener {
fbo1Tex = fbo1.attachTexture2D(gl, 0, true);
}
numSamples=fbo0.getNumSamples();
- fbo0.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo0.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
fbo0.unbind(gl);
- fbo1.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo1.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
fbo1.unbind(gl);
}
private void resetFBOs(final GL gl, final GLAutoDrawable drawable) {
- fbo0.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, true);
- fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples, true);
+ fbo0.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
+ fbo1.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), numSamples);
if(fbo0.getNumSamples() != fbo1.getNumSamples()) {
throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1);
}
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 84cd893..a548d4c 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
@@ -30,6 +30,7 @@ import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.event.PinchToZoomGesture;
import com.jogamp.newt.event.GestureHandler.GestureEvent;
+import com.jogamp.opengl.GLRendererQuirks;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.math.FloatUtil;
import com.jogamp.opengl.math.Quaternion;
@@ -75,6 +76,7 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
private float panX = 0.0f, panY = 0.0f, panZ=0.0f;
private volatile GearsObjectES2 gear1=null, gear2=null, gear3=null;
private GearsES2 sharedGears = null;
+ private Object syncObjects = null;
private boolean useMappedBuffers = false;
private boolean validateBuffers = false;
private volatile boolean usesSharedGears = false;
@@ -142,16 +144,14 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
this.gear3Color = gear3Color;
}
- public void setSharedGearsObjects(final GearsObjectES2 g1, final GearsObjectES2 g2, final GearsObjectES2 g3) {
- gear1 = g1;
- gear2 = g2;
- gear3 = g3;
- }
-
public void setSharedGears(final GearsES2 shared) {
sharedGears = shared;
}
+ public void setSyncObjects(final Object sync) {
+ syncObjects = sync;
+ }
+
/**
* @return gear1
*/
@@ -244,56 +244,39 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
st.uniform(gl, colorU);
if( null != sharedGears ) {
- gear1 = new GearsObjectES2(sharedGears.getGear1(), st, pmvMatrix, pmvMatrixUniform, colorU);
- gear2 = new GearsObjectES2(sharedGears.getGear2(), st, pmvMatrix, pmvMatrixUniform, colorU);
- gear3 = new GearsObjectES2(sharedGears.getGear3(), st, pmvMatrix, pmvMatrixUniform, colorU);
- usesSharedGears = true;
- if(verbose) {
- System.err.println("gear1 "+sid()+" created w/ share: "+sharedGears.getGear1()+" -> "+gear1);
- System.err.println("gear2 "+sid()+" created w/ share: "+sharedGears.getGear2()+" -> "+gear2);
- System.err.println("gear3 "+sid()+" created w/ share: "+sharedGears.getGear3()+" -> "+gear3);
- }
+ gear1 = new GearsObjectES2(sharedGears.getGear1(), st, pmvMatrix, pmvMatrixUniform, colorU);
+ gear2 = new GearsObjectES2(sharedGears.getGear2(), st, pmvMatrix, pmvMatrixUniform, colorU);
+ gear3 = new GearsObjectES2(sharedGears.getGear3(), st, pmvMatrix, pmvMatrixUniform, colorU);
+ usesSharedGears = true;
+ if(verbose) {
+ System.err.println("gear1 "+sid()+" created w/ share: "+sharedGears.getGear1()+" -> "+gear1);
+ System.err.println("gear2 "+sid()+" created w/ share: "+sharedGears.getGear2()+" -> "+gear2);
+ System.err.println("gear3 "+sid()+" created w/ share: "+sharedGears.getGear3()+" -> "+gear3);
+ }
+ if( gl.getContext().hasRendererQuirk(GLRendererQuirks.NeedSharedObjectSync) ) {
+ syncObjects = sharedGears;
+ System.err.println("Shared GearsES2: Synchronized Objects due to quirk "+GLRendererQuirks.toString(GLRendererQuirks.NeedSharedObjectSync));
+ } else if( null == syncObjects ) {
+ syncObjects = new Object();
+ System.err.println("Shared GearsES2: Unsynchronized Objects");
+ }
} else {
- if(null == gear1) {
- gear1 = new GearsObjectES2(gl, useMappedBuffers, st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU, validateBuffers);
- if(verbose) {
- System.err.println("gear1 "+sid()+" created: "+gear1);
- }
- } else {
- final GearsObjectES2 _gear1 = gear1;
- gear1 = new GearsObjectES2(_gear1, st, pmvMatrix, pmvMatrixUniform, colorU);
- usesSharedGears = true;
- if(verbose) {
- System.err.println("gear1 "+sid()+" created w/ share: "+_gear1+" -> "+gear1);
- }
+ gear1 = new GearsObjectES2(gl, useMappedBuffers, st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU, validateBuffers);
+ if(verbose) {
+ System.err.println("gear1 "+sid()+" created: "+gear1);
}
- if(null == gear2) {
- gear2 = new GearsObjectES2(gl, useMappedBuffers, st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU, validateBuffers);
- if(verbose) {
- System.err.println("gear2 "+sid()+" created: "+gear2);
- }
- } else {
- final GearsObjectES2 _gear2 = gear2;
- gear2 = new GearsObjectES2(_gear2, st, pmvMatrix, pmvMatrixUniform, colorU);
- usesSharedGears = true;
- if(verbose) {
- System.err.println("gear2 "+sid()+" created w/ share: "+_gear2+" -> "+gear2);
- }
+ gear2 = new GearsObjectES2(gl, useMappedBuffers, st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU, validateBuffers);
+ if(verbose) {
+ System.err.println("gear2 "+sid()+" created: "+gear2);
}
- if(null == gear3) {
- gear3 = new GearsObjectES2(gl, useMappedBuffers, st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU, validateBuffers);
- if(verbose) {
- System.err.println("gear3 "+sid()+" created: "+gear2);
- }
- } else {
- final GearsObjectES2 _gear3 = gear3;
- gear3 = new GearsObjectES2(_gear3, st, pmvMatrix, pmvMatrixUniform, colorU);
- usesSharedGears = true;
- if(verbose) {
- System.err.println("gear3 "+sid()+" created w/ share: "+_gear3+" -> "+gear3);
- }
+ gear3 = new GearsObjectES2(gl, useMappedBuffers, st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU, validateBuffers);
+ if(verbose) {
+ System.err.println("gear3 "+sid()+" created: "+gear2);
+ }
+ if( null == syncObjects ) {
+ syncObjects = new Object();
}
}
@@ -352,9 +335,15 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
}
- private final float zNear = 2f;
- private final float zFar = 10000f;
- private final float zViewDist = 20.0f;
+ private float zNear = 5f;
+ private float zFar = 10000f;
+ private float zViewDist = 40.0f;
+
+ public void setZ(final float zNear, final float zFar, final float zViewDist) {
+ this.zNear = zNear;
+ this.zFar = zFar;
+ this.zViewDist = zViewDist;
+ }
void reshapeImpl(final GL2ES2 gl, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight) {
final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
@@ -487,6 +476,8 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
colorU = null;
st.destroy(gl);
st = null;
+ sharedGears = null;
+ syncObjects = null;
if(verbose) {
System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN");
@@ -560,9 +551,11 @@ public class GearsES2 implements StereoGLEventListener, TileRendererBase.TileRen
pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
- gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f);
- gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f);
- gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f);
+ synchronized ( syncObjects ) {
+ gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f);
+ gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f);
+ gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f);
+ }
pmvMatrix.glPopMatrix();
st.useProgram(gl, false);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
index 7c4c510..8e4dbfe 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java
@@ -55,7 +55,7 @@ import com.jogamp.opengl.util.glsl.ShaderState;
public class MultisampleDemoES2 implements GLEventListener {
- private boolean multisample;
+ private boolean multisample, clearBuffers;
private final ShaderState st;
private final PMVMatrix pmvMatrix;
private ShaderProgram sp0;
@@ -64,11 +64,14 @@ public class MultisampleDemoES2 implements GLEventListener {
public MultisampleDemoES2(final boolean multisample) {
this.multisample = multisample;
+ this.clearBuffers = true;
st = new ShaderState();
st.setVerbose(true);
pmvMatrix = new PMVMatrix();
}
+ public void setClearBuffers(final boolean v) { clearBuffers = v; }
+
public void init(final GLAutoDrawable glad) {
final GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -135,10 +138,12 @@ public class MultisampleDemoES2 implements GLEventListener {
if (multisample) {
gl.glEnable(GL.GL_MULTISAMPLE);
}
- gl.glClearColor(0, 0, 0, 0);
- // gl.glEnable(GL.GL_DEPTH_TEST);
- // gl.glDepthFunc(GL.GL_LESS);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ if( clearBuffers ) {
+ gl.glClearColor(0, 0, 0, 0);
+ // gl.glEnable(GL.GL_DEPTH_TEST);
+ // gl.glDepthFunc(GL.GL_LESS);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ }
st.useProgram(gl, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
index 0c5d89e..27395ea 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java
@@ -138,15 +138,13 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
st.useProgram(gl, false);
+ initFBOs(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
+
gl.glEnable(GL.GL_DEPTH_TEST);
}
private void initFBOs(final GL gl, final int width, final int height) {
- // remove all texture attachments, since MSAA uses just color-render-buffer
- // and non-MSAA uses texture2d-buffer
- fbo0.detachAllColorbuffer(gl);
-
- fbo0.reset(gl, width, height, numSamples, false);
+ fbo0.init(gl, width, height, numSamples);
numSamples = fbo0.getNumSamples();
if(numSamples>0) {
@@ -157,12 +155,12 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
fbo0Tex = fbo0.attachTexture2D(gl, 0, true);
}
numSamples=fbo0.getNumSamples();
- fbo0.attachRenderbuffer(gl, Type.DEPTH, 24);
+ fbo0.attachRenderbuffer(gl, Type.DEPTH, FBObject.CHOSEN_BITS);
fbo0.unbind(gl);
}
private void resetFBOs(final GL gl, final int width, final int height) {
- fbo0.reset(gl, width, height, numSamples, true);
+ fbo0.reset(gl, width, height, numSamples);
numSamples = fbo0.getNumSamples();
if(numSamples>0) {
fbo0Tex = fbo0.getSamplingSink().getTextureAttachment();
@@ -236,16 +234,11 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener {
gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there)
}
- if( !fbo0.isInitialized() ) {
- System.err.println("**** Reshape.Init: "+width+"x"+height);
- initFBOs(gl, width, height);
- } else {
- System.err.println("**** Reshape.Reset: "+width+"x"+height);
- if( keepTextureBound ) {
- fbo0.unuse(gl);
- }
- resetFBOs(gl, width, height);
+ System.err.println("**** Reshape.Reset: "+width+"x"+height);
+ if( keepTextureBound ) {
+ fbo0.unuse(gl);
}
+ resetFBOs(gl, width, height);
fbo0.bind(gl);
demo.reshape(drawable, x, y, width, height);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java
index dd16b88..ae11c9d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java
@@ -36,8 +36,10 @@ import java.awt.event.ComponentListener;
import java.lang.reflect.InvocationTargetException;
import javax.media.nativewindow.ScalableSurface;
+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;
import javax.media.opengl.awt.GLJPanel;
import javax.swing.JFrame;
@@ -137,6 +139,19 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
}
final SnapshotGLEventListener snap = new SnapshotGLEventListener();
glJPanel.addGLEventListener(snap);
+ glJPanel.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(final GLAutoDrawable drawable) { }
+ @Override
+ public void dispose(final GLAutoDrawable drawable) { }
+ @Override
+ public void display(final GLAutoDrawable drawable) { }
+ @Override
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ setTitle(frame, glJPanel, caps);
+ }
+
+ });
setTitle(frame, glJPanel, caps);
frame.setLocation(xpos, ypos);
@@ -213,6 +228,25 @@ public class TestGearsES2GLJPanelAWT extends UITestCase {
hasSurfacePixelScale1[0]+"x"+hasSurfacePixelScale1[1]+" (has)");
setTitle(frame, glJPanel, caps);
Assert.assertArrayEquals(hasSurfacePixelScale0, hasSurfacePixelScale1);
+ } else if(e.getKeyChar()=='m') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean msaa;
+ if( capsPre.getSampleBuffers() ) {
+ capsNew.setSampleBuffers(false);
+ msaa = false;
+ } else {
+ capsNew.setSampleBuffers(true);
+ capsNew.setNumSamples(4);
+ msaa = true;
+ }
+ System.err.println("[set MSAA "+msaa+" Caps had]: "+capsPre);
+ System.err.println("[set MSAA "+msaa+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+ glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
}
} };
new AWTKeyAdapter(kl, glJPanel).addTo(glJPanel);
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 29c5aac..40c943f 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
@@ -33,6 +33,7 @@ import java.lang.reflect.InvocationTargetException;
import java.net.URLConnection;
import com.jogamp.common.util.IOUtil;
+import com.jogamp.junit.util.JunitTracer;
import com.jogamp.newt.Display;
import com.jogamp.newt.Display.PointerIcon;
import com.jogamp.newt.NewtFactory;
@@ -194,46 +195,74 @@ public class TestGearsES2NEWT extends UITestCase {
}
});
- final PointerIcon[] pointerIcons = { null, null, null };
+ final PointerIcon[] pointerIcons = { null, null, null, null, null };
{
final Display disp = glWindow.getScreen().getDisplay();
disp.createNative();
+ int idx = 0;
{
PointerIcon _pointerIcon = null;
final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } );
try {
_pointerIcon = disp.createPointerIcon(res, 8, 8);
- System.err.println("Create PointerIcon #01: "+_pointerIcon);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
} catch (final Exception e) {
e.printStackTrace();
}
- pointerIcons[0] = _pointerIcon;
+ pointerIcons[idx] = _pointerIcon;
}
+ idx++;
{
PointerIcon _pointerIcon = null;
final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/pointer-grey-alpha-16x24.png" } );
try {
_pointerIcon = disp.createPointerIcon(res, 0, 0);
- System.err.println("Create PointerIcon #02: "+_pointerIcon);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
} catch (final Exception e) {
e.printStackTrace();
}
- pointerIcons[1] = _pointerIcon;
+ pointerIcons[idx] = _pointerIcon;
}
+ idx++;
+ {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-red-alpha-64x64.png" } );
+ try {
+ _pointerIcon = disp.createPointerIcon(res, 0, 0);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcons[idx] = _pointerIcon;
+ }
+ idx++;
+ {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-blue-alpha-64x64.png" } );
+ try {
+ _pointerIcon = disp.createPointerIcon(res, 0, 0);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcons[idx] = _pointerIcon;
+ }
+ idx++;
if( PNGIcon.isAvailable() ) {
PointerIcon _pointerIcon = null;
final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } );
try {
final URLConnection urlConn = res.resolve(0);
final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */);
- System.err.println("Create PointerIcon #03: "+image);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, image.toString());
_pointerIcon = disp.createPointerIcon(image, 32, 0);
- System.err.println("Create PointerIcon #03: "+_pointerIcon);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
} catch (final Exception e) {
e.printStackTrace();
}
- pointerIcons[2] = _pointerIcon;
+ pointerIcons[idx] = _pointerIcon;
}
+ idx++;
}
if( setPointerIcon ) {
glWindow.setPointerIcon(pointerIcons[0]);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java
index d792683..7f2bf78 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java
@@ -152,7 +152,7 @@ public class TestLandscapeES2NEWT extends UITestCase {
runTestGL(caps);
}
- static long duration = 500; // ms
+ static long duration = 1000; // ms
public static void main(final String args[]) {
mainRun = true;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java
index 0f55813..5b64ce3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java
@@ -62,7 +62,7 @@ import org.junit.runners.MethodSorters;
public class TestLandscapeES2NewtCanvasAWT extends UITestCase {
static DimensionImmutable wsize = new Dimension(500, 290);
- static long duration = 500; // ms
+ static long duration = 1000; // ms
static int swapInterval = 1;
static boolean shallUseOffscreenFBOLayer = false;
static boolean forceES2 = false;
@@ -78,6 +78,13 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase {
final Screen screen = NewtFactory.createScreen(dpy, 0);
final GLWindow glWindow = GLWindow.create(screen, caps);
+ // Enforce landscape shader to be linked once,
+ // since on some platforms (Mesa/AMD) it takes a long time!
+ final LandscapeES2 demo = new LandscapeES2(swapInterval);
+ glWindow.addGLEventListener(demo);
+ glWindow.setVisible(true);
+ glWindow.display();
+
final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow);
if ( shallUseOffscreenFBOLayer ) {
newtCanvasAWT.setShallUseOffscreenLayer(true);
@@ -91,9 +98,6 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase {
frame.add(newtCanvasAWT);
frame.setTitle("Gears NewtCanvasAWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval+", size "+wsize);
- final LandscapeES2 demo = new LandscapeES2(swapInterval);
- glWindow.addGLEventListener(demo);
-
final Animator animator = useAnimator ? new Animator() : null;
if( useAnimator ) {
animator.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD);
@@ -152,7 +156,7 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase {
frame.dispose();
}
});
- glWindow.destroy();
+ glWindow.destroy(); // removeNotify does not destroy GLWindow
}
@Test
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.fp
deleted file mode 100644
index b19c057..0000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.fp
+++ /dev/null
@@ -1,339 +0,0 @@
-// Elevated shader
-// https://www.shadertoy.com/view/MdX3Rr by inigo quilez
-
-#if __VERSION__ >= 130
- #define varying in
- out vec4 mgl_FragColor;
-#else
- #define mgl_FragColor gl_FragColor
-#endif
-
-uniform vec3 iResolution;
-uniform float iGlobalTime;
-
-// Created by inigo quilez - iq/2013
-// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
-
-//stereo thanks to Croqueteer
-//#define STEREO
-
-mat3 m = mat3( 0.00, 0.80, 0.60,
- -0.80, 0.36, -0.48,
- -0.60, -0.48, 0.64 );
-
-float hash( float n )
-{
- return fract(sin(n)*43758.5453123);
-}
-
-
-float noise( in vec3 x )
-{
- vec3 p = floor(x);
- vec3 f = fract(x);
-
- f = f*f*(3.0-2.0*f);
-
- float n = p.x + p.y*57.0 + 113.0*p.z;
-
- float res = mix(mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
- mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y),
- mix(mix( hash(n+113.0), hash(n+114.0),f.x),
- mix( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z);
- return res;
-}
-
-
-
-
-vec3 noised( in vec2 x )
-{
- vec2 p = floor(x);
- vec2 f = fract(x);
-
- vec2 u = f*f*(3.0-2.0*f);
-
- float n = p.x + p.y*57.0;
-
- float a = hash(n+ 0.0);
- float b = hash(n+ 1.0);
- float c = hash(n+ 57.0);
- float d = hash(n+ 58.0);
- return vec3(a+(b-a)*u.x+(c-a)*u.y+(a-b-c+d)*u.x*u.y,
- 30.0*f*f*(f*(f-2.0)+1.0)*(vec2(b-a,c-a)+(a-b-c+d)*u.yx));
-
-}
-
-float noise( in vec2 x )
-{
- vec2 p = floor(x);
- vec2 f = fract(x);
-
- f = f*f*(3.0-2.0*f);
-
- float n = p.x + p.y*57.0;
-
- float res = mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
- mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);
-
- return res;
-}
-
-float fbm( vec3 p )
-{
- float f = 0.0;
-
- f += 0.5000*noise( p ); p = m*p*2.02;
- f += 0.2500*noise( p ); p = m*p*2.03;
- f += 0.1250*noise( p ); p = m*p*2.01;
- f += 0.0625*noise( p );
-
- return f/0.9375;
-}
-
-mat2 m2 = mat2(1.6,-1.2,1.2,1.6);
-
-float fbm( vec2 p )
-{
- float f = 0.0;
-
- f += 0.5000*noise( p ); p = m2*p*2.02;
- f += 0.2500*noise( p ); p = m2*p*2.03;
- f += 0.1250*noise( p ); p = m2*p*2.01;
- f += 0.0625*noise( p );
-
- return f/0.9375;
-}
-
-float terrain( in vec2 x )
-{
- vec2 p = x*0.003;
- float a = 0.0;
- float b = 1.0;
- vec2 d = vec2(0.0);
- for(int i=0;i<5; i++)
- {
- vec3 n = noised(p);
- d += n.yz;
- a += b*n.x/(1.0+dot(d,d));
- b *= 0.5;
- p=mat2(1.6,-1.2,1.2,1.6)*p;
- }
-
- return 140.0*a;
-}
-
-float terrain2( in vec2 x )
-{
- vec2 p = x*0.003;
- float a = 0.0;
- float b = 1.0;
- vec2 d = vec2(0.0);
- for(int i=0;i<14; i++)
- {
- vec3 n = noised(p);
- d += n.yz;
- a += b*n.x/(1.0+dot(d,d));
- b *= 0.5;
- p=m2*p;
- }
-
- return 140.0*a;
-}
-
-
-float map( in vec3 p )
-{
- float h = terrain(p.xz);
-
- float ss = 0.03;
- float hh = h*ss;
- float fh = fract(hh);
- float ih = floor(hh);
- fh = mix( sqrt(fh), fh, smoothstep(50.0,140.0,h) );
- h = (ih+fh)/ss;
-
- return p.y - h;
-}
-
-float map2( in vec3 p )
-{
- float h = terrain2(p.xz);
-
-
- float ss = 0.03;
- float hh = h*ss;
- float fh = fract(hh);
- float ih = floor(hh);
- fh = mix( sqrt(fh), fh, smoothstep(50.0,140.0,h) );
- h = (ih+fh)/ss;
-
- return p.y - h;
-}
-
-bool jinteresct(in vec3 rO, in vec3 rD, out float resT )
-{
- float h = 0.0;
- float t = 0.0;
- for( int j=0; j<120; j++ )
- {
- //if( t>2000.0 ) break;
-
- vec3 p = rO + t*rD;
-if( p.y>300.0 ) break;
- h = map( p );
-
- if( h<0.1 )
- {
- resT = t;
- return true;
- }
- t += max(0.1,0.5*h);
-
- }
-
- if( h<5.0 )
- {
- resT = t;
- return true;
- }
- return false;
-}
-
-float sinteresct(in vec3 rO, in vec3 rD )
-{
- float res = 1.0;
- float t = 0.0;
- for( int j=0; j<50; j++ )
- {
- //if( t>1000.0 ) break;
- vec3 p = rO + t*rD;
-
- float h = map( p );
-
- if( h<0.1 )
- {
- return 0.0;
- }
- res = min( res, 16.0*h/t );
- t += h;
-
- }
-
- return clamp( res, 0.0, 1.0 );
-}
-
-vec3 calcNormal( in vec3 pos, float t )
-{
- float e = 0.001;
- e = 0.001*t;
- vec3 eps = vec3(e,0.0,0.0);
- vec3 nor;
- nor.x = map2(pos+eps.xyy) - map2(pos-eps.xyy);
- nor.y = map2(pos+eps.yxy) - map2(pos-eps.yxy);
- nor.z = map2(pos+eps.yyx) - map2(pos-eps.yyx);
- return normalize(nor);
-}
-
-vec3 camPath( float time )
-{
- vec2 p = 600.0*vec2( cos(1.4+0.37*time),
- cos(3.2+0.31*time) );
-
- return vec3( p.x, 0.0, p.y );
-}
-
-void main(void)
-{
- vec2 xy = -1.0 + 2.0*gl_FragCoord.xy / iResolution.xy;
-
- vec2 s = xy*vec2(1.75,1.0);
-
- #ifdef STEREO
- float isCyan = mod(gl_FragCoord.x + mod(gl_FragCoord.y,2.0),2.0);
- #endif
-
- float time = iGlobalTime*.15;
-
- vec3 light1 = normalize( vec3( 0.4, 0.22, 0.6 ) );
- vec3 light2 = vec3( -0.707, 0.000, -0.707 );
-
-
- vec3 campos = camPath( time );
- vec3 camtar = camPath( time + 3.0 );
- campos.y = terrain( campos.xz ) + 15.0;
- camtar.y = campos.y*0.5;
-
- float roll = 0.1*cos(0.1*time);
- vec3 cw = normalize(camtar-campos);
- vec3 cp = vec3(sin(roll), cos(roll),0.0);
- vec3 cu = normalize(cross(cw,cp));
- vec3 cv = normalize(cross(cu,cw));
- vec3 rd = normalize( s.x*cu + s.y*cv + 1.6*cw );
-
- #ifdef STEREO
- campos += 2.0*cu*isCyan; // move camera to the right - the rd vector is still good
- #endif
-
- float sundot = clamp(dot(rd,light1),0.0,1.0);
- vec3 col;
- float t;
- if( !jinteresct(campos,rd,t) )
- {
- col = 0.9*vec3(0.97,.99,1.0)*(1.0-0.3*rd.y);
- col += 0.2*vec3(0.8,0.7,0.5)*pow( sundot, 4.0 );
- }
- else
- {
- vec3 pos = campos + t*rd;
-
- vec3 nor = calcNormal( pos, t );
-
- float dif1 = clamp( dot( light1, nor ), 0.0, 1.0 );
- float dif2 = clamp( 0.2 + 0.8*dot( light2, nor ), 0.0, 1.0 );
- float sh = 1.0;
- if( dif1>0.001 )
- sh = sinteresct(pos+light1*20.0,light1);
-
- vec3 dif1v = vec3(dif1);
- dif1v *= vec3( sh, sh*sh*0.5+0.5*sh, sh*sh );
-
- float r = noise( 7.0*pos.xz );
-
- col = (r*0.25+0.75)*0.9*mix( vec3(0.10,0.05,0.03), vec3(0.13,0.10,0.08), clamp(terrain2( vec2(pos.x,pos.y*48.0))/200.0,0.0,1.0) );
- col = mix( col, 0.17*vec3(0.5,.23,0.04)*(0.50+0.50*r),smoothstep(0.70,0.9,nor.y) );
- col = mix( col, 0.10*vec3(0.2,.30,0.00)*(0.25+0.75*r),smoothstep(0.95,1.0,nor.y) );
- col *= 0.75;
- // snow
- #if 1
- float h = smoothstep(55.0,80.0,pos.y + 25.0*fbm(0.01*pos.xz) );
- float e = smoothstep(1.0-0.5*h,1.0-0.1*h,nor.y);
- float o = 0.3 + 0.7*smoothstep(0.0,0.1,nor.x+h*h);
- float s = h*e*o;
- s = smoothstep( 0.1, 0.9, s );
- col = mix( col, 0.4*vec3(0.6,0.65,0.7), s );
- #endif
-
-
- vec3 brdf = 2.0*vec3(0.17,0.19,0.20)*clamp(nor.y,0.0,1.0);
- brdf += 6.0*vec3(1.00,0.95,0.80)*dif1v;
- brdf += 2.0*vec3(0.20,0.20,0.20)*dif2;
-
- col *= brdf;
-
- float fo = 1.0-exp(-pow(0.0015*t,1.5));
- vec3 fco = vec3(0.7) + 0.6*vec3(0.8,0.7,0.5)*pow( sundot, 4.0 );
- col = mix( col, fco, fo );
- }
-
- col = sqrt(col);
-
- vec2 uv = xy*0.5+0.5;
- col *= 0.7 + 0.3*pow(16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y),0.1);
-
- #ifdef STEREO
- col *= vec3( isCyan, 1.0-isCyan, 1.0-isCyan );
- #endif
-
- mgl_FragColor = vec4(col,1.0);
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
index dbc760d..28328fc 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java
@@ -20,6 +20,7 @@ import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.event.awt.AWTKeyAdapter;
import com.jogamp.newt.event.awt.AWTMouseAdapter;
+import com.jogamp.opengl.GLRendererQuirks;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.util.TileRendererBase;
@@ -33,6 +34,8 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
private float view_rotx = 20.0f, view_roty = 30.0f;
private final float view_rotz = 0.0f;
private int gear1=0, gear2=0, gear3=0;
+ private Gears sharedGears = null;
+ private Object syncObjects = null;
private float angle = 0.0f;
private boolean doRotate = true;
private final int swapInterval;
@@ -42,6 +45,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
private boolean doRotateBeforePrinting;
private boolean verbose = true;
private boolean flipVerticalInGLOrientation = false;
+ private volatile boolean isInit = false;
// private boolean mouseRButtonDown = false;
private int prevMouseX, prevMouseY;
@@ -78,10 +82,8 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
public void setVerbose(final boolean v) { verbose = v; }
public void setFlipVerticalInGLOrientation(final boolean v) { flipVerticalInGLOrientation=v; }
- public void setGears(final int g1, final int g2, final int g3) {
- gear1 = g1;
- gear2 = g2;
- gear3 = g3;
+ public void setSharedGears(final Gears shared) {
+ sharedGears = shared;
}
/**
@@ -103,21 +105,57 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
public void init(final GLAutoDrawable drawable) {
final GL2 gl = drawable.getGL().getGL2();
- init(gl);
-
- final Object upstreamWidget = drawable.getUpstreamWidget();
- if (upstreamWidget instanceof Window) {
- final Window window = (Window) upstreamWidget;
- window.addMouseListener(gearsMouse);
- window.addKeyListener(gearsKeys);
- } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) {
- final java.awt.Component comp = (java.awt.Component) upstreamWidget;
- new AWTMouseAdapter(gearsMouse, drawable).addTo(comp);
- new AWTKeyAdapter(gearsKeys, drawable).addTo(comp);
+ if( init(gl) ) {
+ final Object upstreamWidget = drawable.getUpstreamWidget();
+ if (upstreamWidget instanceof Window) {
+ final Window window = (Window) upstreamWidget;
+ window.addMouseListener(gearsMouse);
+ window.addKeyListener(gearsKeys);
+ } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) {
+ final java.awt.Component comp = (java.awt.Component) upstreamWidget;
+ new AWTMouseAdapter(gearsMouse, drawable).addTo(comp);
+ new AWTKeyAdapter(gearsKeys, drawable).addTo(comp);
+ }
+ } else {
+ drawable.setGLEventListenerInitState(this, false);
+ }
+ }
+
+ boolean enableCullFace = false;
+
+ private void enableStates(final GL gl, final boolean enable) {
+ final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
+ if( enable ) {
+ if( enableCullFace ) {
+ gl.glEnable(GL.GL_CULL_FACE);
+ }
+ gl.glEnable(GLLightingFunc.GL_LIGHTING);
+ gl.glEnable(GLLightingFunc.GL_LIGHT0);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL.GL_LESS); // default
+ gl.glEnable(GLLightingFunc.GL_NORMALIZE);
+ if( msaa ) {
+ gl.glEnable(GL.GL_MULTISAMPLE);
+ }
+ } else {
+ if( enableCullFace ) {
+ gl.glDisable(GL.GL_CULL_FACE);
+ }
+ gl.glDisable(GLLightingFunc.GL_LIGHTING);
+ gl.glDisable(GLLightingFunc.GL_LIGHT0);
+ gl.glDisable(GL.GL_DEPTH_TEST);
+ gl.glDisable(GLLightingFunc.GL_NORMALIZE);
+ if( msaa ) {
+ gl.glDisable(GL.GL_MULTISAMPLE);
+ }
}
}
- public void init(final GL2 gl) {
+ public boolean init(final GL2 gl) {
+ if(null != sharedGears && !sharedGears.isInit() ) {
+ System.err.println(Thread.currentThread()+" GearsES1.init.0: pending shared Gears .. re-init later XXXXX");
+ return false;
+ }
final float lightPos[] = { 5.0f, 5.0f, 10.0f, 0.0f };
final float red[] = { 0.8f, 0.1f, 0.0f, 0.7f };
final float green[] = { 0.0f, 0.8f, 0.2f, 0.7f };
@@ -134,51 +172,63 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_POSITION, lightPos, 0);
if( ! ( flipVerticalInGLOrientation && gl.getContext().getGLDrawable().isGLOriented() ) ) {
// Only possible if we do not flip the projection matrix
- gl.glEnable(GL.GL_CULL_FACE);
+ enableCullFace = true;
+ } else {
+ enableCullFace = false;
}
- gl.glEnable(GLLightingFunc.GL_LIGHTING);
- gl.glEnable(GLLightingFunc.GL_LIGHT0);
- gl.glEnable(GL.GL_DEPTH_TEST);
+ enableStates(gl, true);
/* make the gears */
- if(0>=gear1) {
+ if( null != sharedGears ) {
+ gear1 = sharedGears.getGear1();
+ gear2 = sharedGears.getGear2();
+ gear3 = sharedGears.getGear3();
+ System.err.println("gear1 list reused: "+gear1);
+ System.err.println("gear2 list reused: "+gear2);
+ System.err.println("gear3 list reused: "+gear3);
+ if( gl.getContext().hasRendererQuirk(GLRendererQuirks.NeedSharedObjectSync) ) {
+ syncObjects = sharedGears;
+ System.err.println("Shared Gears: Synchronized Objects due to quirk "+GLRendererQuirks.toString(GLRendererQuirks.NeedSharedObjectSync));
+ } else {
+ syncObjects = new Object();
+ System.err.println("Shared Gears: Unsynchronized Objects");
+ }
+ } else {
gear1 = gl.glGenLists(1);
gl.glNewList(gear1, GL2.GL_COMPILE);
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT_AND_DIFFUSE, red, 0);
gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f);
gl.glEndList();
System.err.println("gear1 list created: "+gear1);
- } else {
- System.err.println("gear1 list reused: "+gear1);
- }
- if(0>=gear2) {
gear2 = gl.glGenLists(1);
gl.glNewList(gear2, GL2.GL_COMPILE);
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT_AND_DIFFUSE, green, 0);
gear(gl, 0.5f, 2.0f, 2.0f, 10, 0.7f);
gl.glEndList();
System.err.println("gear2 list created: "+gear2);
- } else {
- System.err.println("gear2 list reused: "+gear2);
- }
- if(0>=gear3) {
gear3 = gl.glGenLists(1);
gl.glNewList(gear3, GL2.GL_COMPILE);
gl.glMaterialfv(GL.GL_FRONT, GLLightingFunc.GL_AMBIENT_AND_DIFFUSE, blue, 0);
gear(gl, 1.3f, 2.0f, 0.5f, 10, 0.7f);
gl.glEndList();
System.err.println("gear3 list created: "+gear3);
- } else {
- System.err.println("gear3 list reused: "+gear3);
+
+ syncObjects = new Object();
}
- gl.glEnable(GLLightingFunc.GL_NORMALIZE);
+ enableStates(gl, false);
+
+ isInit = true;
+ return true;
}
+ public final boolean isInit() { return isInit; }
+
@Override
public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) {
+ if( !isInit ) { return; }
final GL2 gl = glad.getGL().getGL2();
if(-1 != swapInterval) {
gl.setSwapInterval(swapInterval);
@@ -190,18 +240,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
public void reshapeTile(final TileRendererBase tr,
final int tileX, final int tileY, final int tileWidth, final int tileHeight,
final int imageWidth, final int imageHeight) {
+ if( !isInit ) { return; }
final GL2 gl = tr.getAttachedDrawable().getGL().getGL2();
gl.setSwapInterval(0);
reshape(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight);
}
public void reshape(final GL2 gl, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight) {
- final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
- System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse);
-
- if( msaa ) {
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
+ System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", tileRendererInUse "+tileRendererInUse);
// compute projection parameters 'normal'
float left, right, bottom, top;
@@ -244,14 +290,12 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -40.0f);
-
- if( msaa ) {
- gl.glDisable(GL.GL_MULTISAMPLE);
- }
}
@Override
public void dispose(final GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
+ isInit = false;
System.err.println(Thread.currentThread()+" Gears.dispose: tileRendererInUse "+tileRendererInUse);
try {
final Object upstreamWidget = drawable.getUpstreamWidget();
@@ -261,18 +305,21 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
window.removeKeyListener(gearsKeys);
}
} catch (final Exception e) { System.err.println("Caught: "); e.printStackTrace(); }
- setGears(0, 0, 0);
+ gear1 = 0;
+ gear2 = 0;
+ gear3 = 0;
+ sharedGears = null;
+ syncObjects = null;
}
@Override
public void display(final GLAutoDrawable drawable) {
+ if( !isInit ) { return; }
+
// Get the GL corresponding to the drawable we are animating
final GL2 gl = drawable.getGL().getGL2();
- final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
- if( msaa ) {
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
+ enableStates(gl, true);
if( null == tileRendererInUse ) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -291,15 +338,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
displayImpl(gl);
- if( msaa ) {
- gl.glDisable(GL.GL_MULTISAMPLE);
- }
+
+ enableStates(gl, false);
}
+
public void display(final GL2 gl) {
- final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers();
- if( msaa ) {
- gl.glEnable(GL.GL_MULTISAMPLE);
- }
+ if( !isInit ) { return; }
+ enableStates(gl, true);
+
if( null == tileRendererInUse ) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
} else {
@@ -307,14 +353,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
}
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
displayImpl(gl);
- if( msaa ) {
- gl.glDisable(GL.GL_MULTISAMPLE);
- }
+
+ enableStates(gl, false);
}
+
private void displayImpl(final GL2 gl) {
if( doRotate ) {
// Turn the gears' teeth
- angle += 2.0f;
+ angle += 0.5f;
}
// Rotate the entire assembly of gears based on how the user
// dragged the mouse around
@@ -324,25 +370,27 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
// Place the first gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(-3.0f, -2.0f, 0.0f);
- gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
- gl.glCallList(gear1);
- gl.glPopMatrix();
-
- // Place the second gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(3.1f, -2.0f, 0.0f);
- gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
- gl.glCallList(gear2);
- gl.glPopMatrix();
-
- // Place the third gear and call its display list
- gl.glPushMatrix();
- gl.glTranslatef(-3.1f, 4.2f, 0.0f);
- gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
- gl.glCallList(gear3);
- gl.glPopMatrix();
+ synchronized ( syncObjects ) {
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.0f, -2.0f, 0.0f);
+ gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear1);
+ gl.glPopMatrix();
+
+ // Place the second gear and call its display list
+ gl.glPushMatrix();
+ gl.glTranslatef(3.1f, -2.0f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear2);
+ gl.glPopMatrix();
+
+ // Place the third gear and call its display list
+ gl.glPushMatrix();
+ gl.glTranslatef(-3.1f, 4.2f, 0.0f);
+ gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
+ gl.glCallList(gear3);
+ gl.glPopMatrix();
+ }
// Remember that every push needs a pop; this one is paired with
// rotating the entire gear assembly
@@ -451,7 +499,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList
gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
gl.glEnd();
- gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
+ gl.glShadeModel(GLLightingFunc.GL_SMOOTH); // default
/* draw inside radius cylinder */
gl.glBegin(GL2.GL_QUAD_STRIP);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
index d29688b..96d6fdb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Teapot.java
@@ -24,10 +24,46 @@ public class Teapot implements GLEventListener {
private GLUT glut;
/* glTexGen stuff: */
- private final float sgenparams[] = { 1.0f, 1.0f, 1.0f, 0.0f };
+ // private final float sgenparams[] = { 1.0f, 1.0f, 1.0f, 0.0f };
private Texture tex = null;
+ private void enableStates(final GL2 gl, final boolean enable) {
+ if( enable ) {
+ if( null != tex ) {
+ tex.bind(gl);
+ }
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glDepthFunc(GL.GL_LESS); // default
+ // gl.glEnable(GL2.GL_TEXTURE_GEN_S);
+ // gl.glEnable(GL2.GL_TEXTURE_1D);
+ gl.glEnable(GL.GL_TEXTURE_2D);
+ gl.glEnable(GL.GL_CULL_FACE);
+ gl.glEnable(GLLightingFunc.GL_LIGHTING);
+ gl.glEnable(GLLightingFunc.GL_LIGHT0);
+ gl.glEnable(GL2.GL_AUTO_NORMAL);
+ gl.glEnable(GLLightingFunc.GL_NORMALIZE);
+ gl.glFrontFace(GL.GL_CW);
+ gl.glCullFace(GL.GL_BACK); // default
+ gl.glMaterialf(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 64.0f);
+ gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
+ } else {
+ if( null != tex ) {
+ gl.glBindTexture(tex.getTarget(), 0);
+ }
+ gl.glDisable(GL.GL_DEPTH_TEST);
+ // gl.glDisable(GL2.GL_TEXTURE_GEN_S);
+ // gl.glDisable(GL2.GL_TEXTURE_1D);
+ gl.glDisable(GL.GL_TEXTURE_2D);
+ gl.glDisable(GL.GL_CULL_FACE);
+ gl.glDisable(GLLightingFunc.GL_LIGHTING);
+ gl.glDisable(GLLightingFunc.GL_LIGHT0);
+ gl.glDisable(GL2.GL_AUTO_NORMAL);
+ gl.glDisable(GLLightingFunc.GL_NORMALIZE);
+ gl.glFrontFace(GL.GL_CCW); // default
+ }
+ }
+
@Override
public void init(final GLAutoDrawable drawable) {
final GL2 gl = drawable.getGL().getGL2();
@@ -41,7 +77,7 @@ public class Teapot implements GLEventListener {
} catch (final Exception e) {
e.printStackTrace();
}
- tex.bind(gl);
+ // tex.bind(gl);
// uncomment this and comment the above to see a working texture
// makeStripeImage();
@@ -57,24 +93,10 @@ public class Teapot implements GLEventListener {
// gl.glTexImage1D(GL2.GL_TEXTURE_1D, 0, 3, stripeImageWidth, 0,
// GL.GL_RGB, GL.GL_UNSIGNED_BYTE, stripeImageBuf);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
+ // gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
// gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR);
// gl.glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, sgenparams, 0);
-
- gl.glEnable(GL.GL_DEPTH_TEST);
- gl.glDepthFunc(GL.GL_LESS);
- // gl.glEnable(GL2.GL_TEXTURE_GEN_S);
- // gl.glEnable(GL2.GL_TEXTURE_1D);
- gl.glEnable(GL.GL_TEXTURE_2D);
- gl.glEnable(GL.GL_CULL_FACE);
- gl.glEnable(GLLightingFunc.GL_LIGHTING);
- gl.glEnable(GLLightingFunc.GL_LIGHT0);
- gl.glEnable(GL2.GL_AUTO_NORMAL);
- gl.glEnable(GLLightingFunc.GL_NORMALIZE);
- gl.glFrontFace(GL.GL_CW);
- gl.glCullFace(GL.GL_BACK);
- gl.glMaterialf(GL.GL_FRONT, GLLightingFunc.GL_SHININESS, 64.0f);
}
float angleZ = 0.0f;
@@ -85,8 +107,7 @@ public class Teapot implements GLEventListener {
public void display(final GLAutoDrawable gLDrawable) {
final GL2 gl = gLDrawable.getGL().getGL2();
- tex.bind(gl);
- gl.glEnable(GL.GL_TEXTURE_2D);
+ enableStates(gl, true);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glPushMatrix();
@@ -101,13 +122,14 @@ public class Teapot implements GLEventListener {
rotDir = +1.0f;
}
angleZ += rotIncr * rotDir;
+
+ enableStates(gl, false);
}
@Override
public void reshape(final GLAutoDrawable gLDrawable, final int x, final int y, final int w, final int h) {
final GL2 gl = gLDrawable.getGL().getGL2();
- gl.glViewport(0, 0, w, h);
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity();
if (w <= h) {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelAndGLCanvasApplet.java
similarity index 90%
rename from src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java
rename to src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelAndGLCanvasApplet.java
index 8280919..a153fc7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelApplet.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/Bug818GLJPanelAndGLCanvasApplet.java
@@ -27,7 +27,9 @@
*/
package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
+import java.awt.ComponentOrientation;
import java.awt.Dimension;
+import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.InputStream;
@@ -47,8 +49,10 @@ import javax.media.opengl.fixedfunc.GLLightingFunc;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.media.opengl.fixedfunc.GLPointerFunc;
import javax.swing.JApplet;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
+import javax.swing.SwingConstants;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.opengl.JoglVersion;
@@ -57,7 +61,7 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureIO;
/**
- * Bug 818: OSX GLJPanel Crash
+ * Bug 818: OSX GLJPanel [and GLCanvas] Crash
* <pre>
* - NVIDIA GeForce GT 330M
* - GL_VENDOR: "NVIDIA Corporation"
@@ -66,7 +70,7 @@ import com.jogamp.opengl.util.texture.TextureIO;
* - Mac OSX 10.6.8
* </pre>
*/
-public class Bug818GLJPanelApplet extends JApplet {
+public class Bug818GLJPanelAndGLCanvasApplet extends JApplet {
private static final long serialVersionUID = 1L;
@@ -81,7 +85,7 @@ public class Bug818GLJPanelApplet extends JApplet {
static public void main(final String args[]) {
isApplet = false;
- final JApplet myApplet = new Bug818GLJPanelApplet();
+ final JApplet myApplet = new Bug818GLJPanelAndGLCanvasApplet();
appletHolder = new JPanel();
@@ -115,19 +119,25 @@ public class Bug818GLJPanelApplet extends JApplet {
public void init() {
final JPanel panel = new JPanel();
+ panel.setLayout(new GridLayout(2, 2));
+ System.err.println("Pre Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
+ panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+ System.err.println("Post Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
setContentPane(panel);
-
- final GLCanvas glCanvas = new GLCanvas();
- glCanvas.addGLEventListener(new JOGLQuad(true));
- animatorCanvas = new Animator(glCanvas);
- glCanvas.setPreferredSize(new Dimension(300, 300));
- panel.add(glCanvas);
+ panel.add(new JLabel("GLJPanel", SwingConstants.CENTER));
+ panel.add(new JLabel("GLCanvas", SwingConstants.CENTER));
final GLJPanel gljPanel = new GLJPanel();
gljPanel.addGLEventListener(new JOGLQuad(false));
animatorPanel = new Animator(gljPanel);
gljPanel.setPreferredSize(new Dimension(300, 300));
panel.add(gljPanel);
+
+ final GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(new JOGLQuad(true));
+ animatorCanvas = new Animator(glCanvas);
+ glCanvas.setPreferredSize(new Dimension(300, 300));
+ panel.add(glCanvas);
}
@Override
@@ -271,7 +281,7 @@ public class Bug818GLJPanelApplet extends JApplet {
// set the color of the quad
if (canvas) {
- gl.glColor3f(0.2f, 1.0f, 1.0f);
+ gl.glColor3f(0.2f, 0.2f, 1.0f);
} else {
gl.glColor3f(1.0f, 0.2f, 0.2f);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java
new file mode 100644
index 0000000..fcff9e5
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/GLJPanelsAndGLCanvasDemoGL2Applet.java
@@ -0,0 +1,180 @@
+/**
+ * Copyright 2013 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 com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
+
+import java.awt.ComponentOrientation;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.media.opengl.awt.GLCanvas;
+import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JApplet;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JFrame;
+import javax.swing.SwingConstants;
+
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.Teapot;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ */
+public class GLJPanelsAndGLCanvasDemoGL2Applet extends JApplet {
+
+ private static final long serialVersionUID = 1L;
+
+ private Animator[] animator;
+
+ public static JFrame frame;
+ public static JPanel appletHolder;
+ public static boolean isApplet = true;
+
+ static public void main(final String args[]) {
+ isApplet = false;
+
+ final JApplet myApplet = new GLJPanelsAndGLCanvasDemoGL2Applet();
+
+ appletHolder = new JPanel();
+
+ frame = new JFrame("Bug818GLJPanelApplet");
+ frame.getContentPane().add(myApplet);
+
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(final WindowEvent e) {
+ System.exit(0);
+ }
+ });
+
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ myApplet.init();
+ frame.validate();
+ frame.pack();
+ frame.setVisible(true);
+ } } );
+ } catch( final Throwable throwable ) {
+ throwable.printStackTrace();
+ }
+
+ myApplet.start();
+ }
+
+
+ @Override
+ public void init() {
+
+ final JPanel panel = new JPanel();
+ panel.setLayout(new GridLayout(3, 2));
+ System.err.println("Pre Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
+ panel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
+ System.err.println("Post Orientation L2R: "+panel.getComponentOrientation().isLeftToRight());
+ setContentPane(panel);
+
+ animator = new Animator[3*2];
+ int animIdx = 0;
+
+ panel.add(new JLabel("GLJPanel Auto V-Flip", SwingConstants.CENTER));
+ {
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.addGLEventListener(new Teapot());
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.addGLEventListener(new Gears(0));
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ }
+ panel.add(new JLabel("GLJPanel User V-Flip", SwingConstants.CENTER));
+ {
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.setSkipGLOrientationVerticalFlip(true);
+ gljPanel.addGLEventListener(new Teapot());
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ {
+ final GLJPanel gljPanel = new GLJPanel();
+ gljPanel.setSkipGLOrientationVerticalFlip(true);
+ gljPanel.addGLEventListener(new Gears(0));
+ animator[animIdx++] = new Animator(gljPanel);
+ gljPanel.setPreferredSize(new Dimension(300, 300));
+ panel.add(gljPanel);
+ }
+ }
+
+ panel.add(new JLabel("GLCanvas", SwingConstants.CENTER));
+ {
+ {
+ final GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(new Teapot());
+ animator[animIdx++] = new Animator(glCanvas);
+ glCanvas.setPreferredSize(new Dimension(300, 300));
+ panel.add(glCanvas);
+ }
+ {
+ final GLCanvas glCanvas = new GLCanvas();
+ glCanvas.addGLEventListener(new Gears(1));
+ animator[animIdx++] = new Animator(glCanvas);
+ glCanvas.setPreferredSize(new Dimension(300, 300));
+ panel.add(glCanvas);
+ }
+ }
+ }
+
+ @Override
+ public void start() {
+ for(int i=0; i<animator.length; i++) {
+ animator[i].start();
+ animator[i].setUpdateFPSFrames(60, System.err);
+ }
+ }
+
+ @Override
+ public void stop() {
+ for(int i=0; i<animator.length; i++) {
+ animator[i].stop();
+ }
+ }
+
+ @Override
+ public void destroy() {}
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java
index 3650e49..f47a9b7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java
@@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.gl2.awt;
import javax.media.opengl.*;
+import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.TraceKeyAdapter;
import com.jogamp.newt.event.TraceWindowAdapter;
import com.jogamp.newt.event.awt.AWTKeyAdapter;
@@ -121,6 +122,56 @@ public class TestGearsGLJPanelAWT extends UITestCase {
new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter), glJPanel).addTo(glJPanel);
new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glJPanel).addTo(frame);
+ final com.jogamp.newt.event.KeyListener kl = new com.jogamp.newt.event.KeyAdapter() {
+ @Override
+ public void keyPressed(final KeyEvent e) {
+ if( e.isAutoRepeat() ) {
+ return;
+ }
+ if(e.getKeyChar()=='m') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean msaa;
+ if( capsPre.getSampleBuffers() ) {
+ capsNew.setSampleBuffers(false);
+ capsNew.setDoubleBuffered(false);
+ msaa = false;
+ } else {
+ capsNew.setSampleBuffers(true);
+ capsNew.setNumSamples(4);
+ msaa = true;
+ }
+ System.err.println("[set MSAA "+msaa+" Caps had]: "+capsPre);
+ System.err.println("[set MSAA "+msaa+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+ glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
+ } else if(e.getKeyChar()=='b') {
+ final GLCapabilitiesImmutable capsPre = glJPanel.getChosenGLCapabilities();
+ final GLCapabilities capsNew = new GLCapabilities(capsPre.getGLProfile());
+ capsNew.copyFrom(capsPre);
+ final boolean bmp;
+ if( capsPre.isBitmap() ) {
+ capsNew.setBitmap(false); // auto-choose
+ bmp = false;
+ } else {
+ capsNew.setBitmap(true);
+ capsNew.setFBO(false);
+ capsNew.setPBuffer(false);
+ bmp = true;
+ }
+ System.err.println("[set Bitmap "+bmp+" Caps had]: "+capsPre);
+ System.err.println("[set Bitmap "+bmp+" Caps new]: "+capsNew);
+ System.err.println("XXX-A1: "+animator.toString());
+ glJPanel.setRequestedGLCapabilities(capsNew);
+ System.err.println("XXX-A2: "+animator.toString());
+ System.err.println("XXX: "+glJPanel.toString());
+ }
+ } };
+ new AWTKeyAdapter(kl, glJPanel).addTo(glJPanel);
+
final long t0 = System.currentTimeMillis();
long t1 = t0;
boolean triggerSnap = false;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java
new file mode 100644
index 0000000..223eb1a
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01aGLSL440CoreHardcoded.java
@@ -0,0 +1,225 @@
+/**
+ * Copyright 2014 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 com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2ES3;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GL4;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+
+/**
+ * JOGL Tessellation ShaderCode GL4 test case.
+ * <p>
+ * Demonstrates tessellation-control and -evaluation shaders.
+ * </p>
+ *
+ * @author Raymond L. Rivera, 2014
+ * @author Sven Gothel
+ */
+public class TessellationShader01aGLSL440CoreHardcoded implements GLEventListener {
+ private static final double ANIMATION_RATE = 950.0;
+
+ private ShaderProgram program;
+ private final int[] vertexArray = new int[1];
+ private FloatBuffer vertexOffset;
+ private FloatBuffer backgroundColor;
+
+
+ @Override
+ public void init(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ program = createProgram(auto);
+ if( null == program ) {
+ return;
+ }
+
+ final double theta = System.currentTimeMillis() / ANIMATION_RATE;
+ vertexOffset = FloatBuffer.allocate(4);
+ vertexOffset.put(0, (float)(Math.sin(theta) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(theta) * 0.6f));
+ vertexOffset.put(2, 0.0f);
+ vertexOffset.put(3, 0.0f);
+
+ backgroundColor = FloatBuffer.allocate(4);
+ backgroundColor.put(0, 0.25f);
+ backgroundColor.put(1, 0.25f);
+ backgroundColor.put(2, 0.25f);
+ backgroundColor.put(3, 1.0f);
+
+ gl.glGenVertexArrays(vertexArray.length, vertexArray, 0);
+ gl.glBindVertexArray(vertexArray[0]);
+ gl.glPatchParameteri(GL4.GL_PATCH_VERTICES, 3);
+ gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE);
+ }
+
+ @Override
+ public void display(final GLAutoDrawable auto) {
+ if( null == program ) {
+ return;
+ }
+ final GL4 gl = auto.getGL().getGL4();
+ final double value = System.currentTimeMillis() / ANIMATION_RATE;
+ gl.glClearBufferfv(GL2ES3.GL_COLOR, 0, backgroundColor);
+ gl.glUseProgram(program.program());
+ vertexOffset.put(0, (float)(Math.sin(value) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(value) * 0.6f));
+ gl.glVertexAttrib4fv(0, vertexOffset);
+ gl.glDrawArrays(GL4.GL_PATCHES, 0, 3);
+ }
+
+ @Override
+ public void dispose(final GLAutoDrawable auto) {
+ if( null == program ) {
+ return;
+ }
+ final GL4 gl = auto.getGL().getGL4();
+ gl.glDeleteVertexArrays(vertexArray.length, vertexArray, 0);
+ program.destroy(gl);
+ }
+
+ @Override
+ public void reshape(final GLAutoDrawable auto, final int x, final int y, final int width, final int height) {
+ // final GL4 gl = auto.getGL().getGL4();
+ }
+
+ private ShaderProgram createProgram(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ final String vertexSource =
+ "#version 440 core \n" +
+ " \n" +
+ "layout (location = 0) in vec4 offset; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " const vec4 vertices[3] = vec4[3] ( \n" +
+ " vec4( 0.25, 0.25, 0.5, 1.0), \n" +
+ " vec4(-0.25, -0.25, 0.5, 1.0), \n" +
+ " vec4( 0.25, -0.25, 0.5, 1.0)); \n" +
+ " gl_Position = vertices[gl_VertexID] + offset; \n" +
+ "} \n";
+ final String tessCtrlSource =
+ "#version 440 core \n" +
+ "layout (vertices = 3) out; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " if (gl_InvocationID == 0) \n" +
+ " { \n" +
+ " gl_TessLevelInner[0] = 5.0; \n" +
+ " gl_TessLevelOuter[0] = 5.0; \n" +
+ " gl_TessLevelOuter[1] = 5.0; \n" +
+ " gl_TessLevelOuter[2] = 5.0; \n" +
+ " } \n" +
+ " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n" +
+ "} \n";
+ final String tessEvalSource =
+ "#version 440 core \n" +
+ " \n" +
+ "layout (triangles, equal_spacing, cw) in; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) + \n" +
+ " (gl_TessCoord.y * gl_in[1].gl_Position) + \n" +
+ " (gl_TessCoord.z * gl_in[2].gl_Position); \n" +
+ "} \n";
+ final String fragmentSource =
+ "#version 440 core \n" +
+ " \n" +
+ "out vec4 color; \n" +
+ " \n" +
+ "void main(void) \n" +
+ "{ \n" +
+ " color = vec4(1.0, 1.0, 1.0, 1.0); \n" +
+ "} \n";
+
+ final ShaderCode vertexShader = createShader(gl, GL2ES2.GL_VERTEX_SHADER, vertexSource);
+ if( null == vertexShader ) {
+ return null;
+ }
+ final ShaderCode tessCtrlShader = createShader(gl, GL4.GL_TESS_CONTROL_SHADER, tessCtrlSource);
+ if( null == tessCtrlShader ) {
+ vertexShader.destroy(gl);
+ return null;
+ }
+ final ShaderCode tessEvalShader = createShader(gl, GL4.GL_TESS_EVALUATION_SHADER, tessEvalSource);
+ if( null == tessEvalShader ) {
+ vertexShader.destroy(gl);
+ tessCtrlShader.destroy(gl);
+ return null;
+ }
+ final ShaderCode fragmentShader = createShader(gl, GL2ES2.GL_FRAGMENT_SHADER, fragmentSource);
+ if( null == fragmentShader ) {
+ vertexShader.destroy(gl);
+ tessCtrlShader.destroy(gl);
+ tessEvalShader.destroy(gl);
+ return null;
+ }
+
+ final ShaderProgram program = new ShaderProgram();
+
+ program.init(gl);
+ program.add(vertexShader);
+ program.add(tessCtrlShader);
+ program.add(tessEvalShader);
+ program.add(fragmentShader);
+
+ program.link(gl, System.err);
+ if( !program.validateProgram(gl, System.out) ) {
+ System.err.println("[error] Program linking failed.");
+ program.destroy(gl);
+ return null;
+ } else {
+ return program;
+ }
+ }
+
+ private ShaderCode createShader(final GL4 gl, final int shaderType, final String source) {
+ final String[][] sources = new String[1][1];
+ sources[0] = new String[]{ source };
+ final ShaderCode shader = new ShaderCode(shaderType, sources.length, sources);
+
+ final boolean compiled = shader.compile(gl, System.err);
+ if (!compiled) {
+ System.err.println("[error] Shader compilation failed.");
+ shader.destroy(gl);
+ return null;
+ } else {
+ return shader;
+ }
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java
new file mode 100644
index 0000000..bcf4fa6
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/TessellationShader01bGL4.java
@@ -0,0 +1,154 @@
+/**
+ * Copyright 2014 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 com.jogamp.opengl.test.junit.jogl.demos.gl4;
+
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2ES3;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GL4;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+
+/**
+ * JOGL Tessellation ShaderCode GL4 test case.
+ * <p>
+ * Demonstrates tessellation-control and -evaluation shaders.
+ * </p>
+ *
+ * @author Raymond L. Rivera, 2014
+ * @author Sven Gothel
+ */
+public class TessellationShader01bGL4 implements GLEventListener {
+ private static final double ANIMATION_RATE = 950.0;
+
+ private ShaderProgram program;
+ private final int[] vertexArray = new int[1];
+ private FloatBuffer vertexOffset;
+ private FloatBuffer backgroundColor;
+
+
+ @Override
+ public void init(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+ program = createProgram(auto);
+ if( null == program ) {
+ return;
+ }
+
+ final double theta = System.currentTimeMillis() / ANIMATION_RATE;
+ vertexOffset = FloatBuffer.allocate(4);
+ vertexOffset.put(0, (float)(Math.sin(theta) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(theta) * 0.6f));
+ vertexOffset.put(2, 0.0f);
+ vertexOffset.put(3, 0.0f);
+
+ backgroundColor = FloatBuffer.allocate(4);
+ backgroundColor.put(0, 0.25f);
+ backgroundColor.put(1, 0.25f);
+ backgroundColor.put(2, 0.25f);
+ backgroundColor.put(3, 1.0f);
+
+ gl.glGenVertexArrays(vertexArray.length, vertexArray, 0);
+ gl.glBindVertexArray(vertexArray[0]);
+ gl.glPatchParameteri(GL4.GL_PATCH_VERTICES, 3);
+ gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE);
+ }
+
+ @Override
+ public void display(final GLAutoDrawable auto) {
+ if( null == program ) {
+ return;
+ }
+ final GL4 gl = auto.getGL().getGL4();
+ final double value = System.currentTimeMillis() / ANIMATION_RATE;
+ gl.glClearBufferfv(GL2ES3.GL_COLOR, 0, backgroundColor);
+ gl.glUseProgram(program.program());
+ vertexOffset.put(0, (float)(Math.sin(value) * 0.5f));
+ vertexOffset.put(1, (float)(Math.cos(value) * 0.6f));
+ gl.glVertexAttrib4fv(0, vertexOffset);
+ gl.glDrawArrays(GL4.GL_PATCHES, 0, 3);
+ }
+
+ @Override
+ public void dispose(final GLAutoDrawable auto) {
+ if( null == program ) {
+ return;
+ }
+ final GL4 gl = auto.getGL().getGL4();
+ gl.glDeleteVertexArrays(vertexArray.length, vertexArray, 0);
+ program.destroy(gl);
+ }
+
+ @Override
+ public void reshape(final GLAutoDrawable auto, final int x, final int y, final int width, final int height) {
+ // final GL4 gl = auto.getGL().getGL4();
+ }
+
+ static final String shaderBasename = "tess_example01";
+
+ private ShaderProgram createProgram(final GLAutoDrawable auto) {
+ final GL4 gl = auto.getGL().getGL4();
+
+ final ShaderProgram sp;
+ {
+ final ShaderCode vs, tcs, tes, fs;
+ vs = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ tcs = ShaderCode.create(gl, GL4.GL_TESS_CONTROL_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ tes = ShaderCode.create(gl, GL4.GL_TESS_EVALUATION_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ fs = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ vs.defaultShaderCustomization(gl, true, true);
+ tcs.defaultShaderCustomization(gl, true, true);
+ tes.defaultShaderCustomization(gl, true, true);
+ fs.defaultShaderCustomization(gl, true, true);
+
+ sp = new ShaderProgram();
+ sp.add(gl, vs, System.err);
+ sp.add(gl, tcs, System.err);
+ sp.add(gl, tes, System.err);
+ sp.add(gl, fs, System.err);
+ }
+ if( !sp.link(gl, System.err) ) {
+ System.err.println("[error] Couldn't link program: "+sp);
+ sp.destroy(gl);
+ return null;
+ } else {
+ return sp;
+ }
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestTessellationShader01GL4NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestTessellationShader01GL4NEWT.java
new file mode 100644
index 0000000..ca26385
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/newt/TestTessellationShader01GL4NEWT.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2014 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 com.jogamp.opengl.test.junit.jogl.demos.gl4.newt;
+
+import java.io.IOException;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.gl4.TessellationShader01aGLSL440CoreHardcoded;
+import com.jogamp.opengl.test.junit.jogl.demos.gl4.TessellationShader01bGL4;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+/**
+ * Test Geometry shader demo TessellationShader01aGL4 and TessellationShader01bGL4
+ */
+ at FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestTessellationShader01GL4NEWT extends UITestCase {
+ static long duration = 500; // ms
+
+ static GLCapabilities getCaps(final String profile) {
+ if( !GLProfile.isAvailable(profile) ) {
+ System.err.println("Profile "+profile+" n/a");
+ return null;
+ }
+ return new GLCapabilities(GLProfile.get(profile));
+ }
+
+ @Test
+ public void test01_01a() throws InterruptedException {
+ final GLCapabilities caps = getCaps(GLProfile.GL4);
+ if( null == caps ) { return; }
+ testImpl(caps, new TessellationShader01aGLSL440CoreHardcoded());
+ }
+
+ @Test
+ public void test02_01b() throws InterruptedException {
+ final GLCapabilities caps = getCaps(GLProfile.GL4);
+ if( null == caps ) { return; }
+ testImpl(caps, new TessellationShader01bGL4());
+ }
+
+ private void testImpl(final GLCapabilities caps, final GLEventListener glel) throws InterruptedException {
+ final GLWindow glWindow = GLWindow.create(caps);
+ Assert.assertNotNull(glWindow);
+ glWindow.setSize(800, 600);
+ glWindow.setVisible(true);
+ glWindow.setTitle("JOGL Tessellation Shader Test");
+ Assert.assertTrue(glWindow.isNativeValid());
+
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+ glWindow.addGLEventListener( glel );
+
+ final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener();
+ glWindow.addGLEventListener(snapshotGLEventListener);
+
+ final Animator animator = new Animator(glWindow);
+ animator.start();
+
+ animator.setUpdateFPSFrames(60, System.err);
+ snapshotGLEventListener.setMakeSnapshot();
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ glWindow.destroy();
+ }
+
+ public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestTessellationShader01GL4NEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.fp
new file mode 100644
index 0000000..8a3b232
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.fp
@@ -0,0 +1,6 @@
+
+out vec4 color;
+
+void main(void) {
+ color = vec4(1.0, 1.0, 1.0, 1.0);
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tcp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tcp
new file mode 100644
index 0000000..b76aa58
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tcp
@@ -0,0 +1,12 @@
+
+layout (vertices = 3) out;
+
+void main(void) {
+ if (gl_InvocationID == 0) {
+ gl_TessLevelInner[0] = 5.0;
+ gl_TessLevelOuter[0] = 5.0;
+ gl_TessLevelOuter[1] = 5.0;
+ gl_TessLevelOuter[2] = 5.0;
+ }
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tep b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tep
new file mode 100644
index 0000000..9c307f5
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.tep
@@ -0,0 +1,8 @@
+
+layout (triangles, equal_spacing, cw) in;
+
+void main(void) {
+ gl_Position = (gl_TessCoord.x * gl_in[0].gl_Position) +
+ (gl_TessCoord.y * gl_in[1].gl_Position) +
+ (gl_TessCoord.z * gl_in[2].gl_Position);
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.vp
new file mode 100644
index 0000000..c207c13
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl4/shader/tess_example01.vp
@@ -0,0 +1,12 @@
+
+layout (location = 0) in vec4 offset;
+
+void main(void)
+{
+ const vec4 vertices[3] =
+ vec4[3] (
+ vec4( 0.25, 0.25, 0.5, 1.0),
+ vec4(-0.25, -0.25, 0.5, 1.0),
+ vec4( 0.25, -0.25, 0.5, 1.0) );
+ gl_Position = vertices[gl_VertexID] + offset;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
index 92785ef..0db2afc 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java
@@ -31,6 +31,8 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.media.opengl.GLAnimatorControl;
@@ -52,13 +54,15 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
/**
- * Multiple GLJPanels in a JFrame's Grid
+ * Tests multiple [GLJPanels, GLCanvas or NewtCanvasAWT] in a JFrame's Grid
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestPerf001GLJPanelInit01AWT extends UITestCase {
@@ -69,15 +73,26 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
GLProfile.initSingleton();
}
+ static enum CanvasType { GLCanvas_T, GLJPanel_T, NewtCanvasAWT_T };
+
+ static class GLADComp {
+ GLADComp(final GLAutoDrawable glad, final Component comp) {
+ this.glad = glad;
+ this.comp = comp;
+ }
+ final GLAutoDrawable glad;
+ final Component comp;
+ }
public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, final int rows,
- final int columns, final boolean useGLJPanel, final boolean useAnim) {
+ final int columns, final CanvasType canvasType, final boolean useAnim) {
final GLAnimatorControl animator = useAnim ? new Animator() : null;
final JFrame frame;
final JPanel panel;
+ final List<NewtCanvasAWT> newtCanvasAWTList = new ArrayList<NewtCanvasAWT>();
panel = new JPanel();
- frame = new JFrame("DemoGLJPanelGridAWT");
+ frame = new JFrame(getSimpleTestName("."));
panel.setLayout(new GridLayout(rows, columns));
// panel.setBounds(0, 0, width, height);
@@ -94,8 +109,21 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
public void run() {
t[0] = Platform.currentTimeMillis();
for(int i=0; i<panelCount; i++) {
- final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(caps, useGears, animator, eSize) : createGLCanvas(caps, useGears, animator, eSize);
- glad.addGLEventListener(new GLEventListener() {
+ final GLADComp gladComp;
+ switch(canvasType) {
+ case GLCanvas_T:
+ gladComp = createGLCanvas(caps, useGears, animator, eSize);
+ break;
+ case GLJPanel_T:
+ gladComp = createGLJPanel(caps, useGears, animator, eSize);
+ break;
+ case NewtCanvasAWT_T:
+ gladComp = createNewtCanvasAWT(caps, useGears, animator, eSize);
+ newtCanvasAWTList.add((NewtCanvasAWT)gladComp.comp);
+ break;
+ default: throw new InternalError("XXX");
+ }
+ gladComp.glad.addGLEventListener(new GLEventListener() {
@Override
public void init(final GLAutoDrawable drawable) {
initCount.getAndIncrement();
@@ -107,7 +135,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
});
- panel.add((Component)glad);
+ panel.add(gladComp.comp);
}
t[1] = Platform.currentTimeMillis();
frame.getContentPane().add(panel);
@@ -136,7 +164,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
final double panelCountF = initCount.get();
System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
initCount.get(),
- useGLJPanel?"GLJPanel":"GLCanvas",
+ canvasType,
t[1]-t[0], (t[1]-t[0])/panelCountF,
t[3]-t[1], (t[3]-t[1])/panelCountF,
t[3]-t[0], (t[3]-t[0])/panelCountF);
@@ -144,15 +172,24 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
if( wait ) {
UITestCase.waitForKey("Post-Init");
}
+ if( null != animator ) {
+ animator.start();
+ }
try {
Thread.sleep(duration);
} catch (final InterruptedException e1) {
e1.printStackTrace();
}
+ if( null != animator ) {
+ animator.stop();
+ }
t[4] = Platform.currentTimeMillis();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ while( !newtCanvasAWTList.isEmpty() ) {
+ newtCanvasAWTList.remove(0).destroy(); // removeNotify does not destroy GLWindow
+ }
frame.dispose();
} } );
} catch (final Exception e1) {
@@ -166,46 +203,76 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
System.err.println("Total: "+(t[4]-t[0]));
}
- private GLAutoDrawable createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createNewtCanvasAWT(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ final GLWindow window = GLWindow.create(caps);
+ final NewtCanvasAWT canvas = new NewtCanvasAWT(window);
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ window.addGLEventListener(g);
+ }
+ if( null != anim ) {
+ anim.add(window);
+ }
+ return new GLADComp(window, canvas);
+ }
+ private GLADComp createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLCanvas canvas = new GLCanvas(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ canvas.addGLEventListener(new GearsES2(0));
}
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- private GLAutoDrawable createGLJPanel(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createGLJPanel(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLJPanel canvas = new GLJPanel(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
if( useGears ) {
- canvas.addGLEventListener(new GearsES2());
+ canvas.addGLEventListener(new GearsES2(0));
}
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- @Test
- public void test01NopGLJPanelDef() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/);
+ // @Test
+ public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, false /*useAnim*/);
}
- @Test
- public void test02NopGLJPanelBitmap() throws InterruptedException, InvocationTargetException {
+ // @Test
+ public void test02NopGLJPanelBMP() throws InterruptedException, InvocationTargetException {
final GLCapabilities caps = new GLCapabilities(null);
caps.setBitmap(true);
- test(caps, false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/);
+ test(caps, false /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, false /*useAnim*/);
+ }
+
+ // @Test
+ public void test03NopGLCanvas() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, CanvasType.GLCanvas_T, false /*useAnim*/);
+ }
+
+ // @Test
+ public void test11GearsGLJPanel() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.GLJPanel_T, true /*useAnim*/);
+ }
+
+ // @Test
+ public void test13GearsGLCanvas() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.GLCanvas_T, true /*useAnim*/);
}
@Test
- public void test11NopGLCanvasDef() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/);
+ public void test14GearsNewtCanvasAWT() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, width, height, rows, cols, CanvasType.NewtCanvasAWT_T, true /*useAnim*/);
}
static long duration = 0; // ms
@@ -215,7 +282,8 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
AtomicInteger initCount = new AtomicInteger(0);
public static void main(final String[] args) {
- boolean useGLJPanel = true, useGears = false, manual=false;
+ CanvasType canvasType = CanvasType.GLJPanel_T;
+ boolean useGears = false, manual=false;
boolean waitMain = false;
for(int i=0; i<args.length; i++) {
@@ -230,8 +298,10 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
rows = MiscUtils.atoi(args[++i], rows);
} else if(args[i].equals("-cols")) {
cols = MiscUtils.atoi(args[++i], cols);
- } else if(args[i].equals("-glcanvas")) {
- useGLJPanel = false;
+ } else if(args[i].equals("-type")) {
+ i++;
+ canvasType = CanvasType.valueOf(args[i]);
+ manual = true;
} else if(args[i].equals("-gears")) {
useGears = true;
} else if(args[i].equals("-wait")) {
@@ -250,7 +320,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase {
if( manual ) {
GLProfile.initSingleton();
final TestPerf001GLJPanelInit01AWT demo = new TestPerf001GLJPanelInit01AWT();
- demo.test(null, useGears, width, height, rows, cols, useGLJPanel, false /*useAnim*/);
+ demo.test(null, useGears, width, height, rows, cols, canvasType, useGears /*useAnim*/);
} else {
org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit01AWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
index c60c395..9f2e25f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java
@@ -32,6 +32,8 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.media.opengl.GLAnimatorControl;
@@ -54,13 +56,15 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import com.jogamp.common.os.Platform;
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.test.junit.util.UITestCase;
import com.jogamp.opengl.util.Animator;
/**
- * Multiple GLJPanels in a JFrame
+ * Tests multiple JFrames each with a [GLJPanels, GLCanvas or NewtCanvasAWT]
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@@ -71,13 +75,23 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
GLProfile.initSingleton();
}
+ static enum CanvasType { NOP_T, GLCanvas_T, GLJPanel_T, NewtCanvasAWT_T };
+
+ static class GLADComp {
+ GLADComp(final GLAutoDrawable glad, final Component comp) {
+ this.glad = glad;
+ this.comp = comp;
+ }
+ final GLAutoDrawable glad;
+ final Component comp;
+ }
+
public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final int width,
- final int height, final int frameCount, final boolean initMT, final boolean useGLJPanel,
- final boolean useSwingDoubleBuffer, final boolean useGLCanvas, final boolean useAnim, final boolean overlap) {
+ final int height, final int frameCount, final boolean initMT,
+ final boolean useSwingDoubleBuffer, final CanvasType canvasType, final boolean useAnim, final boolean overlap) {
final GLAnimatorControl animator;
if( useAnim ) {
animator = new Animator();
- animator.start();
} else {
animator = null;
}
@@ -91,6 +105,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
System.err.println("Frame size: "+width+"x"+height+" -> "+frameCount+" x "+eWidth+"x"+eHeight+", overlap "+overlap);
System.err.println("SkipGLOrientationVerticalFlip "+skipGLOrientationVerticalFlip+", useGears "+useGears+", initMT "+initMT+", useAnim "+useAnim);
final JFrame[] frame = new JFrame[frameCount];
+ final List<NewtCanvasAWT> newtCanvasAWTList = new ArrayList<NewtCanvasAWT>();
+
final long[] t = new long[10];
if( wait ) {
UITestCase.waitForKey("Pre-Init");
@@ -103,7 +119,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
t[0] = Platform.currentTimeMillis();
int x = 32, y = 32;
for(int i=0; i<frameCount; i++) {
- frame[i] = new JFrame("frame_"+i+"/"+frameCount);
+ frame[i] = new JFrame(i+"/"+frameCount);
frame[i].setLocation(x, y);
if(!overlap) {
x+=eWidth+32;
@@ -117,9 +133,26 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
panel.setDoubleBuffered(useSwingDoubleBuffer);
// panel.setBounds(0, 0, width, height);
final Dimension eSize = new Dimension(eWidth, eHeight);
- final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null );
- if( null != glad ) {
- glad.addGLEventListener(new GLEventListener() {
+ final GLADComp gladComp;
+ switch(canvasType) {
+ case GLCanvas_T:
+ gladComp = createGLCanvas(caps, useGears, animator, eSize);
+ break;
+ case GLJPanel_T:
+ gladComp = createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize);
+ break;
+ case NewtCanvasAWT_T:
+ gladComp = createNewtCanvasAWT(caps, useGears, animator, eSize);
+ newtCanvasAWTList.add((NewtCanvasAWT)gladComp.comp);
+ break;
+ case NOP_T:
+ gladComp = null;
+ break;
+ default: throw new InternalError("XXX");
+ }
+
+ if( null != gladComp ) {
+ gladComp.glad.addGLEventListener(new GLEventListener() {
@Override
public void init(final GLAutoDrawable drawable) {
initCount.incrementAndGet();
@@ -131,7 +164,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Override
public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
});
- panel.add((Component)glad);
+ panel.add(gladComp.comp);
} else {
@SuppressWarnings("serial")
final JTextArea c = new JTextArea("area "+i) {
@@ -192,7 +225,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
final double panelCountF = initCount.get();
System.err.printf("P: %d %s%s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n",
initCount.get(),
- useGLJPanel?"GLJPanel":(useGLCanvas?"GLCanvas":"No_GL"), initMT?" (mt)":" (01)",
+ canvasType, initMT?" (mt)":" (01)",
t[1]-t[0], (t[1]-t[0])/panelCountF,
t[3]-t[1], (t[3]-t[1])/panelCountF,
t[3]-t[0], (t[3]-t[0])/panelCountF);
@@ -201,15 +234,24 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( wait ) {
UITestCase.waitForKey("Post-Init");
}
+ if( null != animator ) {
+ animator.start();
+ }
try {
Thread.sleep(duration);
} catch (final InterruptedException e1) {
e1.printStackTrace();
}
+ if( null != animator ) {
+ animator.stop();
+ }
t[4] = Platform.currentTimeMillis();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
+ while( !newtCanvasAWTList.isEmpty() ) {
+ newtCanvasAWTList.remove(0).destroy(); // removeNotify does not destroy GLWindow
+ }
for(int i=0; i<frameCount; i++) {
frame[i].dispose();
}
@@ -226,7 +268,22 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
System.err.println("Total: "+(t[4]-t[0]));
}
- private GLAutoDrawable createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createNewtCanvasAWT(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
+ final GLWindow window = GLWindow.create(caps);
+ final NewtCanvasAWT canvas = new NewtCanvasAWT(window);
+ canvas.setSize(size);
+ canvas.setPreferredSize(size);
+ if( useGears ) {
+ final GearsES2 g = new GearsES2(0);
+ g.setVerbose(false);
+ window.addGLEventListener(g);
+ }
+ if( null != anim ) {
+ anim.add(window);
+ }
+ return new GLADComp(window, canvas);
+ }
+ private GLADComp createGLCanvas(final GLCapabilitiesImmutable caps, final boolean useGears, final GLAnimatorControl anim, final Dimension size) {
final GLCanvas canvas = new GLCanvas(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
@@ -238,9 +295,9 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( null != anim ) {
anim.add(canvas);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
- private GLAutoDrawable createGLJPanel(final boolean initMT, final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final GLAnimatorControl anim, final Dimension size) {
+ private GLADComp createGLJPanel(final boolean initMT, final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final GLAnimatorControl anim, final Dimension size) {
final GLJPanel canvas = new GLJPanel(caps);
canvas.setSize(size);
canvas.setPreferredSize(size);
@@ -260,7 +317,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
if( initMT ) {
canvas.initializeBackend(true /* offthread */);
}
- return canvas;
+ return new GLADComp(canvas, canvas);
}
static GLCapabilitiesImmutable caps = null;
@@ -272,31 +329,37 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Test
public void test00NopNoGLDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.NOP_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test01NopGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test02NopGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test03NopGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
}
@Test
public void test04NopGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false /* overlap */);
+ }
+
+ @Test
+ public void test05NopNewtCanvasAWTDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, false /*useAnim*/, false /* overlap */);
}
//
@@ -304,35 +367,34 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
//
@Test
- public void test10GearsNoGLDefGrid() throws InterruptedException, InvocationTargetException {
- test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
- }
-
- @Test
public void test11GearsGLCanvasDefGrid() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test12GearsGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test13GearsGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
@Test
public void test14GearsGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, true /*useAnim*/, false /* overlap */);
}
+ @Test
+ public void test15GearsNewtCanvasAWTDefGrid() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, true /*useAnim*/, false /* overlap */);
+ }
//
// Overlap + NOP
@@ -342,31 +404,37 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
@Test
public void test20NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException {
test(null, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.NOP_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test21NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLCanvas_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test22NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
}
@Test
public void test23NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
+ }
+
+ @Test
+ public void test25NopNewtCanvasAWTDefOverlap() throws InterruptedException, InvocationTargetException {
+ test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
+ false /*useSwingDoubleBuffer*/, CanvasType.NewtCanvasAWT_T, false /*useAnim*/, true /* overlap */);
}
// @Test
public void testXXNopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException {
test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, true /* overlap */);
}
// @Test
@@ -374,7 +442,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities(null);
caps.setBitmap(true);
test(caps, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */,
- true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false);
+ false /*useSwingDoubleBuffer*/, CanvasType.GLJPanel_T, false /*useAnim*/, false);
}
static long duration = 0; // ms
@@ -386,7 +454,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
public static void main(final String[] args) {
boolean manual=false;
boolean waitMain = false;
- boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useSwingDoubleBuffer=false;
+ CanvasType canvasType = CanvasType.GLJPanel_T;
+ boolean initMT = false, useSwingDoubleBuffer=false;
boolean useGears = false, skipGLOrientationVerticalFlip=false, useAnim = false;
boolean overlap = false;
@@ -403,16 +472,12 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
} else if(args[i].equals("-initMT")) {
initMT = true;
manual = true;
- } else if(args[i].equals("-glcanvas")) {
- useGLJPanel = false;
- useGLCanvas = true;
+ } else if(args[i].equals("-type")) {
+ i++;
+ canvasType = CanvasType.valueOf(args[i]);
manual = true;
} else if(args[i].equals("-swingDoubleBuffer")) {
useSwingDoubleBuffer = true;
- } else if(args[i].equals("-glnone")) {
- useGLJPanel = false;
- useGLCanvas = false;
- manual = true;
} else if(args[i].equals("-gears")) {
useGears = true;
} else if(args[i].equals("-anim")) {
@@ -438,7 +503,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase {
GLProfile.initSingleton();
final TestPerf001GLJPanelInit02AWT demo = new TestPerf001GLJPanelInit02AWT();
demo.test(null, useGears, skipGLOrientationVerticalFlip, width, height, frameCount,
- initMT, useGLJPanel, useSwingDoubleBuffer, useGLCanvas, useAnim, overlap);
+ initMT, useSwingDoubleBuffer, canvasType, useAnim, overlap);
} else {
org.junit.runner.JUnitCore.main(TestPerf001GLJPanelInit02AWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
index 142c941..a256124 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/stereo/StereoDemo01.java
@@ -191,6 +191,7 @@ public class StereoDemo01 {
upstream = movieSimple;
} else {
final GearsES2 demo = new GearsES2(0);
+ demo.setZ(2f, 10000f, 20f); // start closer to eye
demo.setVerbose(false);
upstream = demo;
movieSimple = null;
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java
new file mode 100644
index 0000000..0e11ff1
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestMultipleNewtCanvasAWT.java
@@ -0,0 +1,185 @@
+/**
+ * Copyright 2011 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 com.jogamp.opengl.test.junit.newt;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.io.IOException;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.newt.awt.NewtCanvasAWT;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+
+/**
+ * TestMultipleNewtCanvasAWT
+ */
+ at FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMultipleNewtCanvasAWT extends UITestCase {
+
+ static long durationPerTest = 1000;
+
+ @BeforeClass
+ public static void initClass() {
+ if(!GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ setTestSupported(false);
+ }
+ }
+
+ @Test
+ public void test01() throws InterruptedException {
+ testImpl();
+ }
+
+ public void testImpl() throws InterruptedException {
+ final JFrame frame = new JFrame(this.getSimpleTestName("."));
+
+ //
+ // GLDrawableFactory factory = GLDrawableFactory.getFactory(GLProfile.get(GLProfile.GL2));
+ // GLContext sharedContext = factory.getOrCreateSharedContext(factory.getDefaultDevice());
+ //
+ final GLCapabilities glCapabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2));
+ glCapabilities.setSampleBuffers(true);
+ glCapabilities.setNumSamples(4);
+
+ final GearsES2 eventListener1 = new GearsES2(0);
+ final GearsES2 eventListener2 = new GearsES2(1);
+
+ final Component openGLComponent1;
+ final Component openGLComponent2;
+ final GLAutoDrawable openGLAutoDrawable1;
+ final GLAutoDrawable openGLAutoDrawable2;
+
+ final GLWindow glWindow1 = GLWindow.create(glCapabilities);
+ final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1);
+ newtCanvasAWT1.setPreferredSize(new Dimension(640, 480));
+ glWindow1.addGLEventListener(eventListener1);
+ //
+ final GLWindow glWindow2 = GLWindow.create(glCapabilities);
+ final NewtCanvasAWT newtCanvasAWT2 = new NewtCanvasAWT(glWindow2);
+ newtCanvasAWT2.setPreferredSize(new Dimension(640, 480));
+ glWindow2.addGLEventListener(eventListener2);
+
+ openGLComponent1 = newtCanvasAWT1;
+ openGLComponent2 = newtCanvasAWT2;
+ openGLAutoDrawable1 = glWindow1;
+ openGLAutoDrawable2 = glWindow2;
+
+ // group both OpenGL canvases / windows into a horizontal panel
+ final JPanel openGLPanel = new JPanel();
+ openGLPanel.setLayout(new BoxLayout(openGLPanel, BoxLayout.LINE_AXIS));
+ openGLPanel.add(openGLComponent1);
+ openGLPanel.add(Box.createHorizontalStrut(5));
+ openGLPanel.add(openGLComponent2);
+
+ final JPanel mainPanel = (JPanel) frame.getContentPane();
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
+ mainPanel.add(Box.createHorizontalGlue());
+ mainPanel.add(openGLPanel);
+ mainPanel.add(Box.createHorizontalGlue());
+
+ final Animator animator = new Animator(Thread.currentThread().getThreadGroup());
+ animator.setUpdateFPSFrames(1, null);
+ animator.add(openGLAutoDrawable1);
+ animator.add(openGLAutoDrawable2);
+
+ // make the window visible using the EDT
+ SwingUtilities.invokeLater( new Runnable() {
+ public void run() {
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, true));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, true));
+
+ animator.start();
+
+ // sleep for test duration, then request the window to close, wait for the window to close,s and stop the animation
+ while(animator.isAnimating() && animator.getTotalFPSDuration() < durationPerTest) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+
+ // ask the EDT to dispose of the frame;
+ // if using newt, explicitly dispose of the canvases because otherwise it seems our destroy methods are not called
+ SwingUtilities.invokeLater( new Runnable() {
+ public void run() {
+ newtCanvasAWT1.destroy(); // removeNotify does not destroy GLWindow
+ newtCanvasAWT2.destroy(); // removeNotify does not destroy GLWindow
+ frame.dispose();
+ }
+ });
+ Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, false));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent1, false));
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(openGLComponent2, false));
+ }
+
+ static int atoi(final String a) {
+ int i=0;
+ try {
+ i = Integer.parseInt(a);
+ } catch (final Exception ex) { ex.printStackTrace(); }
+ return i;
+ }
+
+ public static void main(final String[] args) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ if (++i < args.length) {
+ durationPerTest = atoi(args[i]);
+ }
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestMultipleNewtCanvasAWT.class.getName());
+ }
+
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowAndPointerIconNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowAndPointerIconNEWT.java
new file mode 100644
index 0000000..868d897
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowAndPointerIconNEWT.java
@@ -0,0 +1,142 @@
+/**
+ * Copyright 2011 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 com.jogamp.opengl.test.junit.newt;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.opengl.GLCapabilities;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.newt.Display;
+import com.jogamp.newt.Display.PointerIcon;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.AWTRobotUtil;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.AnimatorBase;
+
+ at FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestWindowAndPointerIconNEWT extends UITestCase {
+
+ static long duration = 1000; // ms
+
+ // As early as possible
+ static {
+ setPointerIcons();
+ }
+
+ static void setPointerIcons() {
+ final Properties sysp = System.getProperties();
+ sysp.put("jnlp.newt.window.icons", "red-16x16.png red-32x32.png");
+ }
+
+ @AfterClass
+ public static void unsetPointerIcons() {
+ final Properties sysp = System.getProperties();
+ sysp.remove("jnlp.newt.window.icons");
+ }
+
+ @Test
+ public void test() throws InterruptedException {
+ final GLWindow glWindow = GLWindow.create(new GLCapabilities(null));
+ Assert.assertNotNull(glWindow);
+
+ glWindow.setSize(800, 600);
+
+ final GearsES2 demo = new GearsES2(1);
+ glWindow.addGLEventListener(demo);
+
+ final QuitAdapter quitAdapter = new QuitAdapter();
+ glWindow.addKeyListener(quitAdapter);
+ glWindow.addWindowListener(quitAdapter);
+
+ final PointerIcon pointerIcon;
+ {
+ final Display disp = glWindow.getScreen().getDisplay();
+ disp.createNative();
+ final int idx = 0;
+ {
+ PointerIcon _pointerIcon = null;
+ final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "arrow-red-alpha-64x64.png" } );
+ try {
+ _pointerIcon = disp.createPointerIcon(res, 0, 0);
+ System.err.printf("Create PointerIcon #%02d: %s%n", idx, _pointerIcon.toString());
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ pointerIcon = _pointerIcon;
+ }
+ }
+ glWindow.setPointerIcon(pointerIcon);
+ System.err.println("Set PointerIcon: "+glWindow.getPointerIcon());
+
+ final Animator animator = new Animator();
+ animator.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD);
+ animator.add(glWindow);
+ animator.start();
+
+ glWindow.setVisible(true);
+ glWindow.warpPointer(3*glWindow.getSurfaceWidth()/4, 3*glWindow.getSurfaceHeight()/4);
+
+ final long t0 = System.currentTimeMillis();
+ long t1 = t0;
+ while(!quitAdapter.shouldQuit() && t1-t0<duration) {
+ Thread.sleep(100);
+ t1 = System.currentTimeMillis();
+ }
+
+ animator.stop();
+
+ glWindow.destroy();
+ if( NativeWindowFactory.isAWTAvailable() ) {
+ Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, false));
+ }
+ }
+
+ public static void main(final String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestWindowAndPointerIconNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
index 68a08b8..8605606 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java
@@ -29,6 +29,7 @@
package com.jogamp.opengl.test.junit.newt.mm;
import java.io.IOException;
+
import javax.media.nativewindow.NativeWindowFactory;
import org.junit.Assert;
@@ -48,9 +49,11 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import java.util.Iterator;
import java.util.List;
+
import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.Rectangle;
+import javax.media.nativewindow.util.RectangleImmutable;
import javax.media.nativewindow.util.SurfaceSize;
import javax.media.opengl.GLProfile;
@@ -192,6 +195,21 @@ public class TestScreenMode00aNEWT extends UITestCase {
Assert.assertNotNull(sm_c);
Assert.assertEquals(sm_o, sm_c);
}
+
+ final RectangleImmutable zero = new Rectangle();
+
+ final Rectangle monitorViewPU = new Rectangle();
+ final Rectangle monitorViewWU = new Rectangle();
+ MonitorDevice.unionOfViewports(monitorViewPU, monitorViewWU, monitors);
+ System.err.println("Test.0: Monitor union viewport: "+monitorViewPU+" [pu] / "+monitorViewWU+" [wu]");
+ Assert.assertNotEquals(zero, monitorViewPU);
+ Assert.assertNotEquals(zero, monitorViewWU);
+
+ final RectangleImmutable screenViewPU = screen.getViewport();
+ final RectangleImmutable screenViewWU = screen.getViewportInWindowUnits();
+ System.err.println("Test.1: Screen viewport: "+screenViewPU+" [pu] / "+screenViewWU+" [wu]");
+ Assert.assertNotEquals(zero, screenViewPU);
+ Assert.assertNotEquals(zero, screenViewWU);
screen.removeReference();
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java
index 6b353f8..3744045 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java
@@ -70,7 +70,7 @@ public class TestScreenMode00cNEWT extends UITestCase {
static int width, height;
static final int waitTimeShort = 2000;
- static long duration = waitTimeShort;
+ static long duration = 4000;
static int mm_width = 800;
static int mm_height = 600;
@@ -211,8 +211,15 @@ public class TestScreenMode00cNEWT extends UITestCase {
Assert.assertEquals(true,window0.isVisible());
// WARNING: See note in 'UITestCase.resetXRandRIfX11();'
- UITestCase.resetXRandRIfX11();
- System.err.println("XRandR Reset :"+monitor.queryCurrentMode());
+ final int xrandrErrorCode;
+ if( 0 == ( xrandrErrorCode = UITestCase.resetXRandRIfX11() ) ) {
+ System.err.println("XRandR Reset :"+monitor.queryCurrentMode());
+ } else {
+ System.err.println("XRandR Reset : Failed w/ errorCode "+xrandrErrorCode+", fall back to manual reset");
+ final boolean smOk = monitor.setCurrentMode(mmOrig);
+ System.err.println("[X] changeOK : "+smOk);
+ }
+ Thread.sleep(duration);
validateScreenModeReset0(mmOrig);
destroyWindow(window0);
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java
index 5ca1333..6ddea55 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java
@@ -76,7 +76,7 @@ public class TestScreenMode01aNEWT extends UITestCase {
static int width, height;
static long waitTimeShort = 2000;
- static long duration = 2000;
+ static long duration = 4000;
static int mm_width = 800;
static int mm_height = 600;
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 e401534..943a99d 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java
@@ -175,6 +175,13 @@ public class MiscUtils {
this.prefix = prefix;
this.sync = sync;
}
+ public StreamDump(final StringBuilder sb, final String prefix, final InputStream is, final Object sync) {
+ this.is = is;
+ this.outString = sb;
+ this.outStream = null;
+ this.prefix = prefix;
+ this.sync = sync;
+ }
public StreamDump(final StringBuilder sb, final InputStream is, final Object sync) {
this.is = is;
this.outString = sb;
@@ -214,21 +221,23 @@ public class MiscUtils {
}
}
- public static void dumpSharedGLContext(final GLContext self) {
+ public static void dumpSharedGLContext(final String prefix, final GLContext self) {
int i = 0, j = 0;
- System.err.println("Myself: hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+")");
+ final GLContext master = self.getSharedMaster();
+ final int masterHash = null != master ? master.hashCode() : 0;
+ System.err.println(prefix+": hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+", master 0x"+Integer.toHexString(masterHash)+")");
{
final List<GLContext> set = self.getCreatedShares();
for (final Iterator<GLContext> iter = set.iterator(); iter.hasNext(); ) {
final GLContext c = iter.next();
- System.err.println("Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ System.err.println(" Created Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
}
}
{
final List<GLContext> set = self.getDestroyedShares();
for (final Iterator<GLContext> iter = set.iterator(); iter.hasNext(); ) {
final GLContext c = iter.next();
- System.err.println("Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
+ System.err.println(" Destroyed Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")");
}
}
System.err.println("\t Total created "+i+" + destroyed "+j+" = "+(i+j));
diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
index c2b309c..fe333ca 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
@@ -110,71 +110,74 @@ public abstract class UITestCase {
* With NV drivers, one need to add the Modes in proper order to the Screen's Subsection "Display",
* otherwise they are either in unsorted resolution order or even n/a!
* </p>
+ * @return error-code with {@code zero} for no error
*/
@SuppressWarnings("unused")
- public static void resetXRandRIfX11() {
+ public static int resetXRandRIfX11() {
+ int errorCode = 0;
if( NativeWindowFactory.isInitialized() && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) {
try {
final List<String> outputDevices = new ArrayList<String>();
// final List<String> outputSizes = new ArrayList<String>();
- final Object ioSync = new Object();
- synchronized ( ioSync ) {
- final StringBuilder out = new StringBuilder();
- final ProcessBuilder pb = new ProcessBuilder("xrandr", "-q");
- pb.redirectErrorStream(true);
- System.err.println("XRandR Query: "+pb.command());
- final Process p = pb.start();
- final MiscUtils.StreamDump dump = new MiscUtils.StreamDump( out, p.getInputStream(), ioSync );
- dump.start();
- while( !dump.eos() ) {
- ioSync.wait();
- }
- p.waitFor(); // should be fine by now ..
- final int errorCode = p.exitValue();
- if( 0 == errorCode ) {
- // Parse connected output devices !
- final BufferedReader in = new BufferedReader( new StringReader( out.toString() ) );
- String line = null;
- while ( ( line = in.readLine() ) != null) {
- final String lline = line.toLowerCase();
- if( lline.contains("connected") && !lline.contains("disconnected") ) {
- final String od = getFirst(line);
- if( null != od ) {
- outputDevices.add( od );
- /**
- if ( ( line = in.readLine() ) != null ) {
- outputSizes.add( getFirst(line) );
- } else {
- outputSizes.add( null );
- } */
- }
+ final StringBuilder out = new StringBuilder();
+ final String[] cmdlineQuery = new String[] { "xrandr", "-q" };
+ errorCode = processCommand(cmdlineQuery, null, out, "xrandr-query> ");
+ if( 0 != errorCode ) {
+ System.err.println("XRandR Query Error Code "+errorCode);
+ System.err.println(out.toString());
+ } else {
+ // Parse connected output devices !
+ final BufferedReader in = new BufferedReader( new StringReader( out.toString() ) );
+ String line = null;
+ while ( ( line = in.readLine() ) != null) {
+ final String lline = line.toLowerCase();
+ if( lline.contains("connected") && !lline.contains("disconnected") ) {
+ final String od = getFirst(line);
+ if( null != od ) {
+ outputDevices.add( od );
+ /**
+ if ( ( line = in.readLine() ) != null ) {
+ outputSizes.add( getFirst(line) );
+ } else {
+ outputSizes.add( null );
+ } */
}
}
- } else {
- System.err.println("XRandR Query Error Code "+errorCode);
- System.err.println(out.toString());
}
- }
- for(int i=0; i<outputDevices.size(); i++) {
- final String outputDevice = outputDevices.get(i);
- final String outputSize = null; // outputSizes.get(i);
- final String[] cmdline;
- if( null != outputSize ) {
- cmdline = new String[] { "xrandr", "--output", outputDevice, "--mode", outputSize, "--rotate", "normal" };
- } else {
- cmdline = new String[] { "xrandr", "--output", outputDevice, "--preferred", "--rotate", "normal" };
+ for(int i=0; i<outputDevices.size(); i++) {
+ final String outputDevice = outputDevices.get(i);
+ final String outputSize = null; // outputSizes.get(i)
+ final String[] cmdline;
+ if( null != outputSize ) {
+ cmdline = new String[] { "xrandr", "--output", outputDevice, "--mode", outputSize, "--rotate", "normal" };
+ } else {
+ cmdline = new String[] { "xrandr", "--output", outputDevice, "--preferred", "--rotate", "normal" };
+ }
+ System.err.println("XRandR 1.2 Reset: "+Arrays.asList(cmdline));
+ errorCode = processCommand(cmdline, System.err, null, "xrandr-1.2-reset> ");
+ if( 0 != errorCode ) {
+ System.err.println("XRandR 1.2 Reset Error Code "+errorCode);
+ break;
+ }
}
- System.err.println("XRandR Reset: "+Arrays.asList(cmdline));
- final int errorCode = processCommand(cmdline, System.err, "xrandr-reset> ");
+ /**
+ * RandR 1.1 reset does not work ..
if( 0 != errorCode ) {
- System.err.println("XRandR Reset Error Code "+errorCode);
- }
+ final String[] cmdline = new String[] { "xrandr", "-s", "0", "-o", "normal" };
+ System.err.println("XRandR 1.1 Reset: "+Arrays.asList(cmdline));
+ errorCode = processCommand(cmdline, System.err, null, "xrandr-1.1-reset> ");
+ if( 0 != errorCode ) {
+ System.err.println("XRandR 1.1 Reset Error Code "+errorCode);
+ }
+ } */
}
} catch (final Exception e) {
System.err.println("Caught "+e.getClass().getName()+": "+e.getMessage());
e.printStackTrace();
+ errorCode = -1;
}
}
+ return errorCode;
}
private static String getFirst(final String line) {
final StringTokenizer tok = new StringTokenizer(line);
@@ -187,7 +190,7 @@ public abstract class UITestCase {
return null;
}
- public static int processCommand(final String[] cmdline, final OutputStream outstream, final String outPrefix) {
+ public static int processCommand(final String[] cmdline, final OutputStream outstream, final StringBuilder outstring, final String outPrefix) {
int errorCode = 0;
final Object ioSync = new Object();
try {
@@ -195,7 +198,14 @@ public abstract class UITestCase {
final ProcessBuilder pb = new ProcessBuilder(cmdline);
pb.redirectErrorStream(true);
final Process p = pb.start();
- final MiscUtils.StreamDump dump = new MiscUtils.StreamDump( outstream, outPrefix, p.getInputStream(), ioSync);
+ final MiscUtils.StreamDump dump;
+ if( null != outstream ) {
+ dump = new MiscUtils.StreamDump( outstream, outPrefix, p.getInputStream(), ioSync);
+ } else if( null != outstring ) {
+ dump = new MiscUtils.StreamDump( outstring, outPrefix, p.getInputStream(), ioSync);
+ } else {
+ throw new IllegalArgumentException("Output stream and string are null");
+ }
dump.start();
while( !dump.eos() ) {
ioSync.wait();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libjogl2-java.git
More information about the pkg-java-commits
mailing list