summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build-common.xml4
-rw-r--r--make/build-jogl.xml29
-rw-r--r--make/build-nativewindow.xml4
-rw-r--r--make/build-newt.xml1
-rw-r--r--make/build.xml6
-rw-r--r--make/config/jogl/gl-es1.cfg1
-rw-r--r--make/config/jogl/gl-es2.cfg1
-rw-r--r--make/config/jogl/gl-gl4bc.cfg1
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-desktop.java77
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-embedded.java41
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java92
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gles1.java54
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gles2.java60
-rwxr-xr-xmake/scripts/java-win32-dbg.bat4
-rwxr-xr-xmake/scripts/java-win32.bat4
-rwxr-xr-xmake/scripts/java-win64-dbg.bat4
-rwxr-xr-xmake/scripts/java-win64.bat4
-rwxr-xr-xmake/scripts/make.jogl.all.linux-x86_64.sh2
-rwxr-xr-xmake/scripts/make.jogl.all.win32.bat4
-rwxr-xr-xmake/scripts/make.jogl.all.win64.bat4
-rwxr-xr-xmake/scripts/tests-javaws-x64.bat2
-rwxr-xr-xmake/scripts/tests-x32.bat5
-rwxr-xr-xmake/scripts/tests-x64.bat5
-rwxr-xr-xmake/scripts/tests.sh6
-rw-r--r--make/stub_includes/gluegen/gluegen_types.h44
-rw-r--r--make/stub_includes/gluegen/inttypes.h7
-rw-r--r--make/stub_includes/gluegen/stdarg.h7
-rw-r--r--make/stub_includes/gluegen/stddef.h6
-rw-r--r--make/stub_includes/gluegen/stdint.h7
-rw-r--r--make/stub_includes/khr/KHR/khrplatform.h104
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/FileUtil.java89
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java412
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java136
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java181
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/Locator.java178
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java98
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java1
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java69
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java14
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java1
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java7
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java58
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java8
-rw-r--r--src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java5
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java2
-rw-r--r--src/jogl/native/openmax/omx_tool.h19
-rw-r--r--src/nativewindow/native/windows/GDImisc.c18
-rw-r--r--src/nativewindow/native/x11/XineramaHelper.c2
-rw-r--r--src/newt/native/BroadcomEGL.c6
-rw-r--r--src/newt/native/IntelGDL.c2
-rw-r--r--src/newt/native/KDWindow.c22
-rw-r--r--src/newt/native/WindowsWindow.c19
-rw-r--r--src/newt/native/X11Window.c9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java108
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java39
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java319
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java37
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java106
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java41
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/SingletonInstance.java164
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/UITestCase.java13
73 files changed, 1314 insertions, 1550 deletions
diff --git a/make/build-common.xml b/make/build-common.xml
index aac3849e0..454e5d1aa 100644
--- a/make/build-common.xml
+++ b/make/build-common.xml
@@ -58,7 +58,9 @@
<property name="make" value="." />
<property name="config" value="${make}/config" />
<property name="stub.includes" value="stub_includes" /> <!-- NOTE: this MUST be relative for FileSet -->
- <property name="stub.includes.common" value="${stub.includes}/gluegen" />
+
+ <property name="stub.includes.gluegen.gg" value="${gluegen.root}/make/stub_includes/gluegen" />
+ <property name="stub.includes.gluegen.cc" value="${gluegen.root}/make/stub_includes/platform" />
<tstamp>
<format property="version.timestamp" pattern="yyyyMMdd"/>
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index d11d70c21..64609fb13 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -228,10 +228,10 @@
<include name="${stub.includes}/macosx/**" />
<include name="${stub.includes}/win32/**" />
<include name="${stub.includes}/x11/**" />
- <include name="${stub.includes}/gluegen/**" />
<include name="${stub.includes}/khr/**" />
<include name="${stub.includes}/jni/**" />
</dirset>
+
<fileset id="stub.includes.dependencies.fileset.1" dir="${stub.includes}">
<include name="opengl/**" />
<include name="macosx/**" />
@@ -253,8 +253,8 @@
<include name="${stub.includes}/macosx/**" />
<include name="${stub.includes}/win32/**" />
<include name="${stub.includes}/x11/**" />
- <include name="${stub.includes}/gluegen/**" />
<include name="${stub.includes}/khr/**" />
+ <include name="${stub.includes}/jni/**" />
</dirset>
<fileset id="stub.includes.cg.dependencies.fileset" dir=".">
<include name="${stub.includes}/cg/**" />
@@ -397,7 +397,8 @@
<gluegen src="${stub.includes.opengl}/gles2.c"
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl.cfg"
- includeRefid="stub.includes.fileset.all.gldesktop"
+ includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter"
debug="false">
<classpath refid="gluegen-gl.classpath" />
@@ -411,6 +412,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl2_es1.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -423,6 +425,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl2_es2.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -435,6 +438,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl3-subset.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter"
debug="false">
<classpath refid="gluegen-gl.classpath" />
@@ -443,6 +447,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl2_gl3.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -455,6 +460,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl2.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -467,6 +473,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl3.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -479,6 +486,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl3bc.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -491,6 +499,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-if-gl4.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -503,6 +512,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-gl4bc.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter"
debug="false">
<classpath refid="gluegen-gl.classpath" />
@@ -516,6 +526,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-es1.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter"
debug="false">
<classpath refid="gluegen-gl.classpath" />
@@ -529,6 +540,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/gl-es2.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -541,6 +553,7 @@
<gluegen src="${gl.c}"
config="${gl.cfg.nsig}"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.nativesig.NativeSignatureEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -553,6 +566,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/glu-base.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -565,6 +579,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/glu-gl2es1.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -577,6 +592,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/glu-gl2.cfg"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -589,6 +605,7 @@
outputRootDir="${build.jogl}"
config="${glext.platform.cfg}"
includeRefid="stub.includes.fileset.all.gldesktop"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -602,6 +619,7 @@
outputRootDir="${build.jogl}"
config="${window.es.cfg}"
includeRefid="stub.includes.fileset.platform"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter"
debug="false">
<classpath refid="gluegen-gl.classpath" />
@@ -616,6 +634,7 @@
outputRootDir="${build.jogl}"
config="${window.es.ext.cfg}"
includeRefid="stub.includes.fileset.platform"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter"
debug="false">
<classpath refid="gluegen-gl.classpath" />
@@ -629,6 +648,7 @@
outputRootDir="${build.jogl}"
config="${window.os0.cfg}"
includeRefid="stub.includes.fileset.platform"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -641,6 +661,7 @@
outputRootDir="${build.jogl}"
config="${window.os1.cfg}"
includeRefid="stub.includes.fileset.platform"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.opengl.GLEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -772,6 +793,7 @@
outputRootDir="${build.jogl}"
config="${config.jogl}/cg-common.cfg"
includeRefid="stub.includes.cg.fileset.all"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.procaddress.ProcAddressEmitter">
<classpath refid="gluegen-gl.classpath" />
</gluegen>
@@ -1290,6 +1312,7 @@
<compiler extends="@{compiler.cfg.id}" >
<sysincludepath path="${java.includes.dir}"/>
<sysincludepath path="${java.includes.dir.platform}"/>
+ <sysincludepath path="${stub.includes.gluegen.cc}"/>
<includepath path="stub_includes/khr"/>
<includepath path="stub_includes/egl"/>
<includepath path="stub_includes/opengl"/>
diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml
index 475904b06..da32f1809 100644
--- a/make/build-nativewindow.xml
+++ b/make/build-nativewindow.xml
@@ -232,6 +232,7 @@
outputRootDir="${build.nativewindow}"
config="${windowlib.os.cfg}"
includeRefid="stub.includes.fileset.platform"
+ literalInclude="${stub.includes.gluegen.gg}"
emitter="com.jogamp.gluegen.JavaEmitter">
<classpath refid="gluegen.classpath" />
</gluegen>
@@ -246,8 +247,8 @@
<gluegen src="${jawt.platform.header}"
outputRootDir="${build.nativewindow}"
config="${jawt.cfg}"
- literalInclude="${stub.includes}/jni"
includeRefid="stub.includes.fileset.platform"
+ literalInclude="${stub.includes.gluegen.gg}, ${stub.includes}/jni"
emitter="com.jogamp.gluegen.JavaEmitter">
<classpath refid="gluegen.classpath" />
</gluegen>
@@ -578,6 +579,7 @@
<compiler extends="@{compiler.cfg.id}" >
<sysincludepath path="${java.includes.dir}"/>
<sysincludepath path="${java.includes.dir.platform}"/>
+ <sysincludepath path="${stub.includes.gluegen.cc}"/>
<!-- This is for the generated headers for handwritten C code -->
<includepath path="${src.generated.c}" />
<includepath path="${src.generated.c}/X11" if="isX11"/>
diff --git a/make/build-newt.xml b/make/build-newt.xml
index d062f9276..178824f01 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -468,6 +468,7 @@
<compiler extends="@{compiler.cfg.id}" >
<sysincludepath path="${java.includes.dir}"/>
<sysincludepath path="${java.includes.dir.platform}"/>
+ <sysincludepath path="${stub.includes.gluegen.cc}"/>
<includepath path="stub_includes/khr"/>
<includepath path="stub_includes/egl"/>
<!-- This is for finding Xrandr.h on Solaris. -->
diff --git a/make/build.xml b/make/build.xml
index 066b81382..ea8c949ca 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -130,15 +130,15 @@
<fileset dir="${build}" includes="jogl-java-src.zip" />
<fileset dir="${build}" includes="newt-java-src.zip" />
</delete-->
- <zip destfile="${build}/nativewindow-java-src.zip">
+ <zip destfile="${build}/nativewindow-java-src.zip" level="0">
<fileset dir="${src}/nativewindow/classes"/>
<fileset dir="${build}/nativewindow/gensrc/classes"/>
</zip>
- <zip destfile="${build}/jogl-java-src.zip">
+ <zip destfile="${build}/jogl-java-src.zip" level="0">
<fileset dir="${src}/jogl/classes"/>
<fileset dir="${build}/jogl/gensrc/classes"/>
</zip>
- <zip destfile="${build}/newt-java-src.zip">
+ <zip destfile="${build}/newt-java-src.zip" level="0">
<fileset dir="${src}/newt/classes"/>
</zip>
</target>
diff --git a/make/config/jogl/gl-es1.cfg b/make/config/jogl/gl-es1.cfg
index 5c69be9b7..88ce09569 100644
--- a/make/config/jogl/gl-es1.cfg
+++ b/make/config/jogl/gl-es1.cfg
@@ -98,3 +98,4 @@ Import javax.media.opengl.GLES1
Import javax.media.opengl.GLES2
Import javax.media.opengl.GL2
Import com.jogamp.common.nio.Buffers
+Import com.jogamp.opengl.util.GLBuffers
diff --git a/make/config/jogl/gl-es2.cfg b/make/config/jogl/gl-es2.cfg
index dcdc39b29..f529ddbf7 100644
--- a/make/config/jogl/gl-es2.cfg
+++ b/make/config/jogl/gl-es2.cfg
@@ -85,5 +85,6 @@ Import javax.media.opengl.GL2
Import javax.media.opengl.GLArrayData
Import javax.media.opengl.GLUniformData
Import com.jogamp.common.nio.Buffers
+Import com.jogamp.opengl.util.GLBuffers
Import java.io.PrintStream
diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg
index aafb9166b..6833d24d5 100644
--- a/make/config/jogl/gl-gl4bc.cfg
+++ b/make/config/jogl/gl-gl4bc.cfg
@@ -105,4 +105,5 @@ Import javax.media.opengl.GL3
Import javax.media.opengl.GL3bc
Import javax.media.opengl.GL4
Import com.jogamp.common.nio.Buffers
+Import com.jogamp.opengl.util.GLBuffers
Import java.io.PrintStream
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
index 93a275269..4edb28272 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java
@@ -1,80 +1,7 @@
private int[] imageSizeTemp = new int[1];
- /** Helper for more precise computation of number of bytes that will
- be touched by a pixel pack or unpack operation. */
- private int imageSizeInBytes(int bytesPerElement,
- int width, int height, int depth, boolean pack) {
- int rowLength = 0;
- int skipRows = 0;
- int skipPixels = 0;
- int alignment = 1;
- int imageHeight = 0;
- int skipImages = 0;
-
- if (pack) {
- glGetIntegerv(GL_PACK_ROW_LENGTH, imageSizeTemp, 0);
- rowLength = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_SKIP_ROWS, imageSizeTemp, 0);
- skipRows = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_SKIP_PIXELS, imageSizeTemp, 0);
- skipPixels = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
- if (depth > 1) {
- glGetIntegerv(GL_PACK_IMAGE_HEIGHT, imageSizeTemp, 0);
- imageHeight = imageSizeTemp[0];
- glGetIntegerv(GL_PACK_SKIP_IMAGES, imageSizeTemp, 0);
- skipImages = imageSizeTemp[0];
- }
- } else {
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, imageSizeTemp, 0);
- rowLength = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_SKIP_ROWS, imageSizeTemp, 0);
- skipRows = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_SKIP_PIXELS, imageSizeTemp, 0);
- skipPixels = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
- if (depth > 1) {
- glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, imageSizeTemp, 0);
- imageHeight = imageSizeTemp[0];
- glGetIntegerv(GL_UNPACK_SKIP_IMAGES, imageSizeTemp, 0);
- skipImages = imageSizeTemp[0];
- }
- }
- // Try to deal somewhat correctly with potentially invalid values
- width = Math.max(0, width );
- height = Math.max(1, height); // min 1D
- depth = Math.max(1, depth ); // min 1 * imageSize
- skipRows = Math.max(0, skipRows);
- skipPixels = Math.max(0, skipPixels);
- alignment = Math.max(1, alignment);
- skipImages = Math.max(0, skipImages);
-
- imageHeight = ( imageHeight > 0 ) ? imageHeight : height;
- rowLength = ( rowLength > 0 ) ? rowLength : width;
-
- int rowLengthInBytes = rowLength * bytesPerElement;
-
- if (alignment > 1) {
- int padding = rowLengthInBytes % alignment;
- if (padding > 0) {
- rowLengthInBytes += alignment - padding;
- }
- }
-
- /**
- * skipPixels and skipRows is a static one time offset.
- *
- * skipImages and depth are in multiples of image size.
- *
- * rowlenght is the actual repeating offset
- * to go from line n to line n+1 at the same x-axis position.
- */
- return
- ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // whole images
- ( skipRows + height - 1 ) * rowLengthInBytes + // lines with padding
- ( skipPixels + width ) * bytesPerElement; // last line
+ private final int imageSizeInBytes(int format, int type, int width, int height, int depth, boolean pack) {
+ return GLBuffers.sizeof(this, imageSizeTemp, format, type, width, height, depth, pack) ;
}
public final boolean isGL4bc() {
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java
index 0408c21a1..e1273e679 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-embedded.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-embedded.java
@@ -1,42 +1,7 @@
-private int[] imageSizeTemp = new int[1];
-/** Helper for more precise computation of number of bytes that will
- be touched by a pixel pack or unpack operation. */
-private int imageSizeInBytes(int bytesPerElement,
- int rowLength, int imageHeight, int depth, boolean pack) {
- int alignment = 1;
+ private int[] imageSizeTemp = new int[1];
- if (pack) {
- glGetIntegerv(GL_PACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
- } else {
- glGetIntegerv(GL_UNPACK_ALIGNMENT, imageSizeTemp, 0);
- alignment = imageSizeTemp[0];
+ private final int imageSizeInBytes(int format, int type, int width, int height, int depth, boolean pack) {
+ return GLBuffers.sizeof(this, imageSizeTemp, format, type, width, height, depth, pack) ;
}
- // Try to deal somewhat correctly with potentially invalid values
- rowLength = Math.max(0, rowLength );
- imageHeight = Math.max(1, imageHeight); // min 1D
- depth = Math.max(1, depth ); // min 1 * imageSize
- alignment = Math.max(1, alignment);
-
- int rowLengthInBytes = rowLength * bytesPerElement;
-
- if (alignment > 1) {
- int padding = rowLengthInBytes % alignment;
- if (padding > 0) {
- rowLengthInBytes += alignment - padding;
- }
- }
-
- /**
- * depth is in multiples of image size.
- *
- * rowlenght is the actual repeating offset
- * to go from line n to line n+1 at the same x-axis position.
- */
- return
- ( depth - 1 ) * imageHeight * rowLengthInBytes + // whole images
- ( imageHeight - 1 ) * rowLengthInBytes + // lines with padding
- ( rowLength ) * bytesPerElement; // last line
-}
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
index dbfa3ef4d..e977204e3 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java
@@ -35,98 +35,6 @@ public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2,
// Helpers for ensuring the correct amount of texture data
//
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- elements = 1;
- break;
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- case GL_BGR:
- elements = 3;
- break;
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- elements = 4;
- break;
- /* FIXME ??
- case GL_HILO_NV:
- elements = 2;
- break; */
- default:
- return 0;
- }
- switch (type) {
- case GL_BITMAP:
- if (format == GL_COLOR_INDEX) {
- return (d * (h * ((w+7)/8)));
- } else {
- return 0;
- }
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- esize = 1;
- elements = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- esize = 4;
- elements = 1;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
private GLBufferSizeTracker bufferSizeTracker;
private GLBufferStateTracker bufferStateTracker;
private GLStateTracker glStateTracker;
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
index 0a0f87897..98ec4e550 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
@@ -98,60 +98,6 @@ public final GL2GL3 getGL2GL3() throws GLException {
// Helpers for ensuring the correct amount of texture data
//
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_ALPHA:
- case GL_LUMINANCE:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- elements = 3;
- break;
- case GL_RGBA:
- elements = 4;
- break;
- default:
- return 0;
- }
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- esize = 2;
- elements = 1;
- break;
- case GL_FLOAT:
- esize = 4;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
private GLBufferSizeTracker bufferSizeTracker;
private GLBufferStateTracker bufferStateTracker;
private GLStateTracker glStateTracker;
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
index e096d2185..760ec375e 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java
@@ -102,66 +102,6 @@ public final GL2GL3 getGL2GL3() throws GLException {
// Helpers for ensuring the correct amount of texture data
//
-/** Returns the number of bytes required to fill in the appropriate
- texture. This is computed as closely as possible based on the
- pixel pack or unpack parameters. The logic in this routine is
- based on code in the SGI OpenGL sample implementation. */
-
-private int imageSizeInBytes(int format, int type, int w, int h, int d,
- boolean pack) {
- int elements = 0;
- int esize = 0;
-
- if (w < 0) return 0;
- if (h < 0) return 0;
- if (d < 0) return 0;
- switch (format) {
- case GL_STENCIL_INDEX:
- elements = 1;
- break;
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- elements = 3;
- break;
- case GL_RGBA:
- elements = 4;
- break;
- default:
- return 0;
- }
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- default:
- return 0;
- }
- return imageSizeInBytes(elements * esize, w, h, d, pack);
-}
-
private GLBufferSizeTracker bufferSizeTracker;
private GLBufferStateTracker bufferStateTracker;
private GLStateTracker glStateTracker;
diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat
index 2b15410ff..8552111a8 100755
--- a/make/scripts/java-win32-dbg.bat
+++ b/make/scripts/java-win32-dbg.bat
@@ -1,7 +1,7 @@
set BLD_SUB=build-win32
-set J2RE_HOME=c:\jre1.6.0_24_x32
-set JAVA_HOME=c:\jdk1.6.0_24_x32
+set J2RE_HOME=c:\jre1.6.0_26_x32
+set JAVA_HOME=c:\jdk1.6.0_26_x32
set ANT_PATH=C:\apache-ant-1.8.2
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat
index 368501cb4..07b921afc 100755
--- a/make/scripts/java-win32.bat
+++ b/make/scripts/java-win32.bat
@@ -1,7 +1,7 @@
set BLD_SUB=build-win32
-set J2RE_HOME=c:\jre1.6.0_24_x32
-set JAVA_HOME=c:\jdk1.6.0_24_x32
+set J2RE_HOME=c:\jre1.6.0_26_x32
+set JAVA_HOME=c:\jdk1.6.0_26_x32
set ANT_PATH=C:\apache-ant-1.8.2
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat
index a8a322449..950b6a92e 100755
--- a/make/scripts/java-win64-dbg.bat
+++ b/make/scripts/java-win64-dbg.bat
@@ -1,7 +1,7 @@
set BLD_SUB=build-win64
-set J2RE_HOME=c:\jre1.6.0_24_x64
-set JAVA_HOME=c:\jdk1.6.0_24_x64
+set J2RE_HOME=c:\jre1.6.0_26_x64
+set JAVA_HOME=c:\jdk1.6.0_26_x64
set ANT_PATH=C:\apache-ant-1.8.2
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat
index 320db5725..dc2a7c226 100755
--- a/make/scripts/java-win64.bat
+++ b/make/scripts/java-win64.bat
@@ -1,7 +1,7 @@
set BLD_SUB=build-win64
-set J2RE_HOME=c:\jre1.6.0_24_x64
-set JAVA_HOME=c:\jdk1.6.0_24_x64
+set J2RE_HOME=c:\jre1.6.0_26_x64
+set JAVA_HOME=c:\jdk1.6.0_26_x64
set ANT_PATH=C:\apache-ant-1.8.2
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh
index aab3eecae..b89de7465 100755
--- a/make/scripts/make.jogl.all.linux-x86_64.sh
+++ b/make/scripts/make.jogl.all.linux-x86_64.sh
@@ -52,7 +52,7 @@ echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF
# -Djavacdebug="true" \
# -Djavacdebuglevel="source,lines,vars" \
-# BUILD_ARCHIVE=true \
+BUILD_ARCHIVE=true \
ant \
$CUSTOMLIBDIR \
-Djavacdebuglevel="source,lines,vars" \
diff --git a/make/scripts/make.jogl.all.win32.bat b/make/scripts/make.jogl.all.win32.bat
index f73a332d3..09cbfbe4e 100755
--- a/make/scripts/make.jogl.all.win32.bat
+++ b/make/scripts/make.jogl.all.win32.bat
@@ -1,7 +1,7 @@
set THISDIR="C:\JOGL"
-set J2RE_HOME=c:\jre1.6.0_24_x32
-set JAVA_HOME=c:\jdk1.6.0_24_x32
+set J2RE_HOME=c:\jre1.6.0_26_x32
+set JAVA_HOME=c:\jdk1.6.0_26_x32
set ANT_PATH=C:\apache-ant-1.8.2
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 76e459ae7..7b43f73c1 100755
--- a/make/scripts/make.jogl.all.win64.bat
+++ b/make/scripts/make.jogl.all.win64.bat
@@ -1,7 +1,7 @@
set THISDIR="C:\JOGL"
-set J2RE_HOME=c:\jre1.6.0_24_x64
-set JAVA_HOME=c:\jdk1.6.0_24_x64
+set J2RE_HOME=c:\jre1.6.0_26_x64
+set JAVA_HOME=c:\jdk1.6.0_26_x64
set ANT_PATH=C:\apache-ant-1.8.2
set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;c:\mingw\bin;%PATH%
diff --git a/make/scripts/tests-javaws-x64.bat b/make/scripts/tests-javaws-x64.bat
index c25ccf335..23d01a2ff 100755
--- a/make/scripts/tests-javaws-x64.bat
+++ b/make/scripts/tests-javaws-x64.bat
@@ -1,4 +1,4 @@
-set JRE_PATH=C:\jre1.6.0_24_x64\bin
+set JRE_PATH=C:\jre1.6.0_26_x64\bin
set LOG_PATH=%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\log
%JRE_PATH%\javaws -uninstall
diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat
index 2e7d1ea80..bd5d30895 100755
--- a/make/scripts/tests-x32.bat
+++ b/make/scripts/tests-x32.bat
@@ -38,5 +38,8 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GL
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %1 %2 %3 %4
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn $*
-scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
+REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
+
+scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01
+REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01
diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat
index b657102ff..ceb282ece 100755
--- a/make/scripts/tests-x64.bat
+++ b/make/scripts/tests-x64.bat
@@ -65,5 +65,8 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtD
REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01
REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02
-scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
+REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
+
+scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01
+REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index c8cf79e9f..fd6cc7845 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -97,6 +97,7 @@ function jrun() {
echo "Test Start: $*"
echo
echo $javaexe $X_ARGS $D_ARGS $C_ARG $*
+ # LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64:$LD_LIBRARY_PATH \
$javaexe $X_ARGS $D_ARGS $C_ARG $*
echo
echo "Test End: $*"
@@ -198,9 +199,6 @@ function testawtmt() {
#testawt $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT
-#
-
#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot
#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot
#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $*
@@ -220,5 +218,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
+
$spath/count-edt-start.sh java-run.log
diff --git a/make/stub_includes/gluegen/gluegen_types.h b/make/stub_includes/gluegen/gluegen_types.h
deleted file mode 100644
index c854d3345..000000000
--- a/make/stub_includes/gluegen/gluegen_types.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef __gluegen_types_h
-#define __gluegen_types_h
-
-/**
- * These are standard include replacement files
- * for gluegen processing only!
- *
- * Don't include this folder to your native compiler!
- *
- * Purpose of all files within this folder is to define a fixed bitsize
- * across all platforms to allow the resulting java type comfort all.
- * IE a 'intptr_t' shall always be 64bit.
- *
- * We use one size fits all.
- */
-#if defined(__STDC_VERSION__) || defined(__GNUC__) || defined (__ARMCC_2__) || \
- defined(__VMS) || defined(__sgi) || defined(__sun__) || defined(__digital__) || defined(__unix__) || defined(__SCO__) || defined(OPENSTEP) || \
- defined(BSD) || defined(FREEBSD) || defined(_HPUX) || defined(SOLARIS) || defined(macosx) || \
- defined(_WIN32) || defined(_WIN32_WCE) || defined(WINVER) || defined(_WIN32_WINNT) || defined(__CYGWIN__) || \
- defined(__SCITECH_SNAP__) || defined (__SYMBIAN32__) || \
- defined(__arch64__) || defined(_LP64)
-
- #error PLATFORM or COMPILER DEFINES FOUND, not allowed within GLUEGEN HEADER
-
-#endif
-
-/**
- * Look in the GlueGen.java API documentation for the build-in types (terminal symbols)
- * definition.
- *
- * The following types are build-in:
- *
- * __int32
- * int32_t
- * uint32_t
- * __int64
- * int64_t
- * uint64_t
- * ptrdiff_t
- * size_t
- */
-
-#endif /* __gluegen_types_h */
-
diff --git a/make/stub_includes/gluegen/inttypes.h b/make/stub_includes/gluegen/inttypes.h
deleted file mode 100644
index b4ac3d40f..000000000
--- a/make/stub_includes/gluegen/inttypes.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __inttypes_h
-#define __inttypes_h
-
-#include <gluegen_types.h>
-
-#endif /* __stdint_h */
-
diff --git a/make/stub_includes/gluegen/stdarg.h b/make/stub_includes/gluegen/stdarg.h
deleted file mode 100644
index b5b585baa..000000000
--- a/make/stub_includes/gluegen/stdarg.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __stdarg_h
-#define __stdarg_h
-
-#include <gluegen_types.h>
-
-#endif /* __stdarg_h */
-
diff --git a/make/stub_includes/gluegen/stddef.h b/make/stub_includes/gluegen/stddef.h
deleted file mode 100644
index a3890b08a..000000000
--- a/make/stub_includes/gluegen/stddef.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __stddef_h
-#define __stddef_h
-
-#include <gluegen_types.h>
-
-#endif /* __stddef_h */
diff --git a/make/stub_includes/gluegen/stdint.h b/make/stub_includes/gluegen/stdint.h
deleted file mode 100644
index dd03d2d1e..000000000
--- a/make/stub_includes/gluegen/stdint.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __stdint_h
-#define __stdint_h
-
-#include <gluegen_types.h>
-
-#endif /* __stdint_h */
-
diff --git a/make/stub_includes/khr/KHR/khrplatform.h b/make/stub_includes/khr/KHR/khrplatform.h
index 1c578feb8..1f10e5c0a 100644
--- a/make/stub_includes/khr/KHR/khrplatform.h
+++ b/make/stub_includes/khr/KHR/khrplatform.h
@@ -132,16 +132,14 @@
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
-#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
-
/*
- * Using <stddef.h>
- * Using <stdint.h>
+ * Using <gluegen_stddef.h>
+ * Using <gluegen_stdint.h>
*/
-#include <stddef.h>
+#include <gluegen_stddef.h>
#define HAS_STDDEF 1
-#include <stdint.h>
+#include <gluegen_stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
@@ -149,100 +147,14 @@ typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
-#elif defined(__VMS ) || defined(__sgi)
-
-/*
- * Using <stddef.h>
- * Using <inttypes.h>
- */
-#include <stddef.h>
-#define HAS_STDDEF 1
-#include <inttypes.h>
-typedef int32_t khronos_int32_t;
-typedef uint32_t khronos_uint32_t;
-typedef int64_t khronos_int64_t;
-typedef uint64_t khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64 1
-#define KHRONOS_SUPPORT_FLOAT 1
-
-#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
-
-/*
- * Win32
- */
-typedef __int32 khronos_int32_t;
-typedef unsigned __int32 khronos_uint32_t;
-typedef __int64 khronos_int64_t;
-typedef unsigned __int64 khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64 1
-#define KHRONOS_SUPPORT_FLOAT 1
-
-#elif defined(__sun__) || defined(__digital__)
-
-/*
- * Sun or Digital
- */
-typedef int khronos_int32_t;
-typedef unsigned int khronos_uint32_t;
-#if defined(__arch64__) || defined(_LP64)
-typedef long int khronos_int64_t;
-typedef unsigned long int khronos_uint64_t;
-#else
-typedef long long int khronos_int64_t;
-typedef unsigned long long int khronos_uint64_t;
-#endif /* __arch64__ */
-#define KHRONOS_SUPPORT_INT64 1
-#define KHRONOS_SUPPORT_FLOAT 1
-
-#elif 0
-
-/*
- * Hypothetical platform with no float or int64 support
- */
-typedef int khronos_int32_t;
-typedef unsigned int khronos_uint32_t;
-#define KHRONOS_SUPPORT_INT64 0
-#define KHRONOS_SUPPORT_FLOAT 0
-
-#else
-
-/*
- * Generic fallback
- *
- * Using <stddef.h>
- * Using <stdint.h>
- */
-#include <stddef.h>
-#define HAS_STDDEF 1
-#include <stdint.h>
-typedef int32_t khronos_int32_t;
-typedef uint32_t khronos_uint32_t;
-typedef int64_t khronos_int64_t;
-typedef uint64_t khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64 1
-#define KHRONOS_SUPPORT_FLOAT 1
-
-#endif
-
-
-/*
- * Types that are (so far) the same on all platforms
- */
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
-#ifndef HAS_STDDEF
- typedef signed long int khronos_intptr_t;
- typedef unsigned long int khronos_uintptr_t;
- typedef signed long int khronos_ssize_t;
- typedef unsigned long int khronos_usize_t;
-#else
- typedef ptrdiff_t khronos_intptr_t;
- typedef size_t khronos_uintptr_t;
- typedef ptrdiff_t khronos_ssize_t;
- typedef size_t khronos_usize_t;
-#endif
+typedef ptrdiff_t khronos_intptr_t;
+typedef size_t khronos_uintptr_t;
+typedef ptrdiff_t khronos_ssize_t;
+typedef size_t khronos_usize_t;
#if KHRONOS_SUPPORT_FLOAT
/*
diff --git a/src/jogl/classes/com/jogamp/opengl/util/FileUtil.java b/src/jogl/classes/com/jogamp/opengl/util/FileUtil.java
deleted file mode 100644
index 6ad0da825..000000000
--- a/src/jogl/classes/com/jogamp/opengl/util/FileUtil.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution 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.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.util;
-
-import java.io.*;
-
-/** Utilities for dealing with files. */
-
-public class FileUtil {
- private FileUtil() {}
-
- /**
- * Returns the lowercase suffix of the given file name (the text
- * after the last '.' in the file name). Returns null if the file
- * name has no suffix. Only operates on the given file name;
- * performs no I/O operations.
- *
- * @param file name of the file
- * @return lowercase suffix of the file name
- * @throws NullPointerException if file is null
- */
-
- public static String getFileSuffix(File file) {
- return getFileSuffix(file.getName());
- }
-
- /**
- * Returns the lowercase suffix of the given file name (the text
- * after the last '.' in the file name). Returns null if the file
- * name has no suffix. Only operates on the given file name;
- * performs no I/O operations.
- *
- * @param filename name of the file
- * @return lowercase suffix of the file name
- * @throws NullPointerException if filename is null
- */
- public static String getFileSuffix(String filename) {
- int lastDot = filename.lastIndexOf('.');
- if (lastDot < 0) {
- return null;
- }
- return toLowerCase(filename.substring(lastDot + 1));
- }
-
- private static String toLowerCase(String arg) {
- if (arg == null) {
- return null;
- }
-
- return arg.toLowerCase();
- }
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
index efe3a7675..f2e742cda 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
@@ -42,60 +42,145 @@ import com.jogamp.common.nio.Buffers;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLException;
import java.nio.*;
/**
* Utility routines for dealing with direct buffers.
* @author Kenneth Russel
+ * @author Sven Gothel
* @author Michael Bien
*/
public class GLBuffers extends Buffers {
+ /**
+ * @param glType shall be one of
+ * GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT,
+ * GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE,
+ * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
+ * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
+ * GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
+ * GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
+ * GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
+ * GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)
+ * @return -1 if glType is unhandled, otherwise the actual value > 0
+ */
public static final int sizeOfGLType(int glType) {
- switch (glType) {
- case GL.GL_UNSIGNED_BYTE:
- return SIZEOF_BYTE;
+ switch (glType) { // 25
case GL.GL_BYTE:
+ case GL.GL_UNSIGNED_BYTE:
+ case GL2GL3.GL_UNSIGNED_BYTE_3_3_2:
+ case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV:
return SIZEOF_BYTE;
- case GL.GL_UNSIGNED_SHORT:
- return SIZEOF_SHORT;
+
case GL.GL_SHORT:
+ case GL.GL_UNSIGNED_SHORT:
+ case GL.GL_UNSIGNED_SHORT_5_6_5:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV:
return SIZEOF_SHORT;
- case GL.GL_FLOAT:
- return SIZEOF_FLOAT;
+
case GL.GL_FIXED:
- return SIZEOF_INT;
case GL2ES2.GL_INT:
+ case GL.GL_UNSIGNED_INT:
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8:
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL2GL3.GL_UNSIGNED_INT_10_10_10_2:
+ case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL2GL3.GL_UNSIGNED_INT_24_8:
+ case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV:
return SIZEOF_INT;
- case GL2ES2.GL_UNSIGNED_INT:
- return SIZEOF_INT;
+
+ case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return SIZEOF_LONG;
+
+ case GL.GL_FLOAT:
+ return SIZEOF_FLOAT;
+
case GL2.GL_DOUBLE:
return SIZEOF_DOUBLE;
}
return -1;
}
-
+
+ /**
+ * @param glType shall be one of
+ * GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT,
+ * GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE,
+ * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
+ * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
+ * GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
+ * GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
+ * GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
+ * GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)
+ * @return null if glType is unhandled, otherwise the new Buffer object
+ */
public static final Buffer newDirectGLBuffer(int glType, int numElements) {
switch (glType) {
- case GL.GL_UNSIGNED_BYTE:
case GL.GL_BYTE:
+ case GL.GL_UNSIGNED_BYTE:
+ case GL2GL3.GL_UNSIGNED_BYTE_3_3_2:
+ case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV:
return newDirectByteBuffer(numElements);
- case GL.GL_UNSIGNED_SHORT:
+
case GL.GL_SHORT:
+ case GL.GL_UNSIGNED_SHORT:
+ case GL.GL_UNSIGNED_SHORT_5_6_5:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV:
return newDirectShortBuffer(numElements);
- case GL.GL_FLOAT:
- return newDirectFloatBuffer(numElements);
+
case GL.GL_FIXED:
case GL2ES2.GL_INT:
- case GL2ES2.GL_UNSIGNED_INT:
+ case GL.GL_UNSIGNED_INT:
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8:
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL2GL3.GL_UNSIGNED_INT_10_10_10_2:
+ case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL2GL3.GL_UNSIGNED_INT_24_8:
+ case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV:
return newDirectIntBuffer(numElements);
+
+ case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return newDirectLongBuffer(numElements);
+
+ case GL.GL_FLOAT:
+ return newDirectFloatBuffer(numElements);
+
case GL2.GL_DOUBLE:
return newDirectDoubleBuffer(numElements);
}
return null;
}
+ /**
+ * @param glType shall be one of
+ * GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT,
+ * GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE,
+ * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
+ * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
+ * GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
+ * GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
+ * GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
+ * GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (25)
+ * @return null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object
+ */
public static final Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType) {
if (parent == null || byteLen == 0) {
return null;
@@ -104,24 +189,309 @@ public class GLBuffers extends Buffers {
parent.limit(bytePos + byteLen);
switch (glType) {
- case GL.GL_UNSIGNED_BYTE:
case GL.GL_BYTE:
+ case GL.GL_UNSIGNED_BYTE:
+ case GL2GL3.GL_UNSIGNED_BYTE_3_3_2:
+ case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV:
return parent.slice();
- case GL.GL_UNSIGNED_SHORT:
+
case GL.GL_SHORT:
+ case GL.GL_UNSIGNED_SHORT:
+ case GL.GL_UNSIGNED_SHORT_5_6_5:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV:
return parent.asShortBuffer();
- case GL.GL_FLOAT:
- return parent.asFloatBuffer();
+
case GL.GL_FIXED:
- case GL2ES2.GL_INT:
+ case GL2GL3.GL_INT:
case GL2ES2.GL_UNSIGNED_INT:
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8:
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL2GL3.GL_UNSIGNED_INT_10_10_10_2:
+ case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL2GL3.GL_UNSIGNED_INT_24_8:
+ case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV:
return parent.asIntBuffer();
+
+ case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return parent.asLongBuffer();
+
+ case GL.GL_FLOAT:
+ return parent.asFloatBuffer();
+
case GL2.GL_DOUBLE:
return parent.asDoubleBuffer();
}
return null;
}
+ private static final int glGetInteger(GL gl, int pname, int[] tmp) {
+ gl.glGetIntegerv(pname, tmp, 0);
+ return tmp[0];
+ }
+
+ /**
+ * Returns the number of bytes required to read/write a memory buffer via OpenGL
+ * using the current GL pixel storage state and the given parameters.
+ *
+ * <p>This method is security critical, hence it throws an exception (fail-fast)
+ * in case of an invalid alignment. In case we forgot to handle
+ * proper values, please contact the maintainer.</p>
+ *
+ * @param gl the current GL object
+ *
+ * @param tmp a pass through integer array of size >= 1 used to store temp data (performance)
+ *
+ * @param bytesPerElement bytes per element
+ * @param width in pixels
+ * @param height in pixels
+ * @param depth in pixels
+ * @param pack true for read mode GPU -> CPU (pack), otherwise false for write mode CPU -> GPU (unpack)
+ * @return required minimum size of the buffer in bytes
+ * @throws GLException if alignment is invalid. Please contact the maintainer if this is our bug.
+ */
+ public static final int sizeof(GL gl, int tmp[],
+ int bytesPerElement, int width, int height, int depth,
+ boolean pack) {
+ int rowLength = 0;
+ int skipRows = 0;
+ int skipPixels = 0;
+ int alignment = 1;
+ int imageHeight = 0;
+ int skipImages = 0;
+
+ if (pack) {
+ alignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT, tmp);
+ if(gl.isGL2GL3()) {
+ rowLength = glGetInteger(gl, GL2GL3.GL_PACK_ROW_LENGTH, tmp);
+ skipRows = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_ROWS, tmp);
+ skipPixels = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_PIXELS, tmp);
+ if (depth > 1) {
+ 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 ()) {
+ rowLength = glGetInteger(gl, GL2GL3.GL_UNPACK_ROW_LENGTH, tmp);
+ skipRows = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_ROWS, tmp);
+ skipPixels = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_PIXELS, tmp);
+ if (depth > 1) {
+ imageHeight = glGetInteger(gl, GL2GL3.GL_UNPACK_IMAGE_HEIGHT, tmp);
+ skipImages = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_IMAGES, tmp);
+ }
+ }
+ }
+
+ // Try to deal somewhat correctly with potentially invalid values
+ width = Math.max(0, width );
+ height = Math.max(1, height); // min 1D
+ depth = Math.max(1, depth ); // min 1 * imageSize
+ skipRows = Math.max(0, skipRows);
+ skipPixels = Math.max(0, skipPixels);
+ alignment = Math.max(1, alignment);
+ skipImages = Math.max(0, skipImages);
+
+ imageHeight = ( imageHeight > 0 ) ? imageHeight : height;
+ rowLength = ( rowLength > 0 ) ? rowLength : width;
+
+ int rowLengthInBytes = rowLength * bytesPerElement;
+ int skipBytes = skipPixels * bytesPerElement;
+
+ switch(alignment) {
+ case 1:
+ break;
+ case 2:
+ case 4:
+ case 8: {
+ // x % 2n == x & (2n - 1)
+ int remainder = rowLengthInBytes & ( alignment - 1 );
+ if (remainder > 0) {
+ rowLengthInBytes += alignment - remainder;
+ }
+ remainder = skipBytes & ( alignment - 1 );
+ if (remainder > 0) {
+ skipBytes += alignment - remainder;
+ }
+ }
+ break;
+ default:
+ throw new GLException("Invalid alignment "+alignment+", must be 2**n (1,2,4,8). Pls notify the maintainer in case this is our bug.");
+ }
+
+ /**
+ * skipImages, depth, skipPixels and skipRows are static offsets.
+ *
+ * skipImages and depth are in multiples of image size.
+ *
+ * skipBytes and rowLengthInBytes are aligned
+ *
+ * rowLengthInBytes is the aligned byte offset
+ * from line n to line n+1 at the same x-axis position.
+ */
+ return
+ skipBytes + // aligned skipPixels * bpp
+ ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // aligned whole images
+ ( skipRows + height - 1 ) * rowLengthInBytes + // aligned lines
+ width * bytesPerElement; // last line
+ }
+
+ /**
+ * Returns the number of bytes required to read/write a memory buffer via OpenGL
+ * using the current GL pixel storage state and the given parameters.
+ *
+ * <p>This method is security critical, hence it throws an exception (fail-fast)
+ * in case either the format, type or alignment is unhandled. In case we forgot to handle
+ * proper values, please contact the maintainer.</p>
+ *
+ * @param gl the current GL object
+ *
+ * @param tmp a pass through integer array of size >= 1 used to store temp data (performance)
+ *
+ * @param format must be one of
+ * GL_COLOR_INDEX, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL,
+ * GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_LUMINANCE,
+ * GL_RG, GL_LUMINANCE_ALPHA,
+ * GL_RGB, GL_BGR, GL_RGBA, GL_BGRA, GL_ABGR_EXT,
+ * GL_RED_INTEGER, GL_GREEN_INTEGER, GL_BLUE_INTEGER,
+ * GL_RG_INTEGER, GL_RGB_INTEGER, GL_BGR_INTEGER,
+ * GL_RGBA_INTEGER, GL_BGRA_INTEGER (24)
+ *
+ * @param type must be one of
+ * GL_BITMAP,
+ * GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT,
+ * GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE,
+ * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
+ * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
+ * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
+ * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
+ * GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,
+ * GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV
+ * GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT_10F_11F_11F_REV,
+ * GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT_32_UNSIGNED_INT_24_8_REV (26)
+ *
+ * @param width in pixels
+ * @param height in pixels
+ * @param depth in pixels
+ * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU
+ * @return required minimum size of the buffer in bytes
+ * @throws GLException if format, type or alignment is not handled. Please contact the maintainer if this is our bug.
+ */
+ public static final int sizeof(GL gl, int tmp[],
+ int format, int type, int width, int height, int depth,
+ boolean pack) throws GLException {
+ int elements = 0;
+ int esize = 0;
+
+ if (width < 0) return 0;
+ if (height < 0) return 0;
+ if (depth < 0) return 0;
+
+ switch (format) /* 24 */ {
+ case GL2.GL_COLOR_INDEX:
+ case GL2GL3.GL_STENCIL_INDEX:
+ case GL2GL3.GL_DEPTH_COMPONENT:
+ case GL2GL3.GL_DEPTH_STENCIL:
+ case GL2GL3.GL_RED:
+ case GL2GL3.GL_RED_INTEGER:
+ case GL2GL3.GL_GREEN:
+ case GL2GL3.GL_GREEN_INTEGER:
+ case GL2GL3.GL_BLUE:
+ case GL2GL3.GL_BLUE_INTEGER:
+ case GL.GL_ALPHA:
+ case GL.GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL.GL_LUMINANCE_ALPHA:
+ case GL2GL3.GL_RG:
+ case GL2GL3.GL_RG_INTEGER:
+ elements = 2;
+ break;
+ case GL.GL_RGB:
+ case GL2GL3.GL_RGB_INTEGER:
+ case GL2GL3.GL_BGR:
+ case GL2GL3.GL_BGR_INTEGER:
+ elements = 3;
+ break;
+ case GL.GL_RGBA:
+ case GL2GL3.GL_RGBA_INTEGER:
+ case GL2GL3.GL_BGRA:
+ case GL2GL3.GL_BGRA_INTEGER:
+ case GL2.GL_ABGR_EXT:
+ elements = 4;
+ break;
+ /* FIXME ??
+ case GL.GL_HILO_NV:
+ elements = 2;
+ break; */
+ default:
+ throw new GLException("format 0x"+Integer.toHexString(format)+" not supported [yet], pls notify the maintainer in case this is our bug.");
+ }
+
+ switch (type) /* 26 */ {
+ case GL2.GL_BITMAP:
+ if (GL2.GL_COLOR_INDEX == format || GL2GL3.GL_STENCIL_INDEX == format) {
+ return (depth * (height * ((width+7)/8)));
+ }
+ case GL.GL_BYTE:
+ case GL.GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL.GL_SHORT:
+ case GL.GL_UNSIGNED_SHORT:
+ case GL.GL_HALF_FLOAT:
+ esize = 2;
+ break;
+ case GL2ES2.GL_INT:
+ case GL.GL_UNSIGNED_INT:
+ case GL.GL_FLOAT:
+ esize = 4;
+ break;
+ case GL2GL3.GL_DOUBLE:
+ esize = 8;
+ break;
+
+ case GL2GL3.GL_UNSIGNED_BYTE_3_3_2:
+ case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL.GL_UNSIGNED_SHORT_5_6_5:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL2GL3.GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8:
+ case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL2GL3.GL_UNSIGNED_INT_10_10_10_2:
+ case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL2GL3.GL_UNSIGNED_INT_24_8:
+ case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ esize = 8;
+ elements = 1;
+ break;
+
+ default:
+ throw new GLException("type 0x"+Integer.toHexString(type)+"/"+"format 0x"+Integer.toHexString(format)+" not supported [yet], pls notify the maintainer in case this is our bug.");
+ }
+
+ return sizeof(gl, tmp, elements * esize, width, height, depth, pack);
+ }
+
//----------------------------------------------------------------------
// Conversion routines
//
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
new file mode 100644
index 000000000..05eb67269
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java
@@ -0,0 +1,136 @@
+/**
+ * Copyright 2010 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.util;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLException;
+
+/**
+ * Utility to safely set and restore the pack and unpack pixel storage mode,
+ * regardless of the GLProfile.
+ */
+public class GLPixelStorageModes {
+ private int[] savedGL2GL3Modes = new int[8];
+ private int[] savedAlignment = new int[2];
+ private boolean saved = false;
+
+ /**
+ * Sets the {@link GL2ES2.GL_PACK_ALIGNMENT}. Saves the pixel storage modes if not saved yet.
+ */
+ public final void setPackAlignment(GL gl, int packAlignment) {
+ if(!saved) { save(gl); }
+ gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, packAlignment);
+ }
+
+ /**
+ * Sets the {@link GL2ES2.GL_UNPACK_ALIGNMENT}. Saves the pixel storage modes if not saved yet.
+ */
+ public final void setUnpackAlignment(GL gl, int unpackAlignment) {
+ if(!saved) { save(gl); }
+ gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, unpackAlignment);
+ }
+
+ /**
+ * Sets the {@link GL2ES2.GL_PACK_ALIGNMENT} and {@link GL2ES2.GL_UNPACK_ALIGNMENT}.
+ * Saves the pixel storage modes if not saved yet.
+ */
+ public final void setAlignment(GL gl, int packAlignment, int unpackAlignment) {
+ setPackAlignment(gl, packAlignment);
+ setUnpackAlignment(gl, unpackAlignment);
+ }
+
+ private final void save(GL gl) {
+ if(gl.isGL2GL3()) {
+ if(gl.isGL2()) {
+ gl.getGL2().glPushClientAttrib(GL2.GL_CLIENT_PIXEL_STORE_BIT);
+ } else {
+ gl.glGetIntegerv(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment, 0);
+ gl.glGetIntegerv(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment, 1);
+ gl.glGetIntegerv(GL2GL3.GL_PACK_ROW_LENGTH, savedGL2GL3Modes, 0);
+ gl.glGetIntegerv(GL2GL3.GL_PACK_SKIP_ROWS, savedGL2GL3Modes, 1);
+ gl.glGetIntegerv(GL2GL3.GL_PACK_SKIP_PIXELS, savedGL2GL3Modes, 2);
+ gl.glGetIntegerv(GL2GL3.GL_PACK_SWAP_BYTES, savedGL2GL3Modes, 3);
+ gl.glGetIntegerv(GL2GL3.GL_UNPACK_ROW_LENGTH, savedGL2GL3Modes, 4);
+ gl.glGetIntegerv(GL2GL3.GL_UNPACK_SKIP_ROWS, savedGL2GL3Modes, 5);
+ gl.glGetIntegerv(GL2GL3.GL_UNPACK_SKIP_PIXELS, savedGL2GL3Modes, 6);
+ gl.glGetIntegerv(GL2GL3.GL_UNPACK_SWAP_BYTES, savedGL2GL3Modes, 7);
+ }
+ gl.glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, 0);
+ gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_ROWS, 0);
+ gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_PIXELS, 0);
+ gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, 0);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_ROW_LENGTH, 0);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_ROWS, 0);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_PIXELS, 0);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_SWAP_BYTES, 0);
+ } else {
+ // embedded deals with pack/unpack alignment only
+ gl.glGetIntegerv(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment, 0);
+ gl.glGetIntegerv(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment, 1);
+ }
+ saved = true;
+ }
+
+ /**
+ * Restores the pixel storage mode.
+ * @throws GLException if not saved via one of the set methods.
+ */
+ public final void restore(GL gl) throws GLException {
+ if(!saved) {
+ throw new GLException("pixel storage modes not saved");
+ }
+
+ if(gl.isGL2GL3()) {
+ if(gl.isGL2()) {
+ gl.getGL2().glPopClientAttrib();
+ } else {
+ gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment[0]);
+ gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment[1]);
+ gl.glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, savedGL2GL3Modes[0]);
+ gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_ROWS, savedGL2GL3Modes[1]);
+ gl.glPixelStorei(GL2GL3.GL_PACK_SKIP_PIXELS, savedGL2GL3Modes[2]);
+ gl.glPixelStorei(GL2GL3.GL_PACK_SWAP_BYTES, savedGL2GL3Modes[3]);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_ROW_LENGTH, savedGL2GL3Modes[4]);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_ROWS, savedGL2GL3Modes[5]);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_SKIP_PIXELS, savedGL2GL3Modes[6]);
+ gl.glPixelStorei(GL2GL3.GL_UNPACK_SWAP_BYTES, savedGL2GL3Modes[7]);
+ }
+ } else {
+ // embedded deals with pack/unpack alignment only
+ gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment[0]);
+ gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment[1]);
+ }
+ saved = false;
+ }
+}
+
+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java
new file mode 100644
index 000000000..e5cf7d0d0
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java
@@ -0,0 +1,181 @@
+/**
+ * Copyright 2010 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.util;
+
+import com.jogamp.common.nio.Buffers;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.*;
+import javax.media.opengl.*;
+
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+/**
+ * Utility to read out the current FB to TextureData, optionally writing the data back to a texture object.
+ * <p>May be used directly to write the TextureData to file (screenshot).</p>
+ */
+public class GLReadBufferUtil {
+ protected final int components, alignment;
+ protected final Texture readTexture;
+ protected final GLPixelStorageModes psm;
+
+ protected int readPixelSizeLast = 0;
+ protected ByteBuffer readPixelBuffer = null;
+ protected TextureData readTextureData = null;
+
+ /**
+ * @param alpha true for RGBA readPixels, otherwise RGB readPixels
+ * @param write2Texture true if readPixel's TextureData shall be written to a 2d Texture
+ */
+ public GLReadBufferUtil(boolean alpha, boolean write2Texture) {
+ components = alpha ? 4 : 3 ;
+ alignment = alpha ? 4 : 1 ;
+ readTexture = write2Texture ? new Texture(GL.GL_TEXTURE_2D) : null ;
+ psm = new GLPixelStorageModes();
+ }
+
+ public boolean isValid() {
+ return null!=readTextureData && null!=readPixelBuffer ;
+ }
+
+ /**
+ * @return the raw pixel ByteBuffer, filled by {@link #readPixels(GLAutoDrawable, boolean)}
+ */
+ public ByteBuffer getPixelBuffer() { return readPixelBuffer; }
+
+ /**
+ * rewind the raw pixel ByteBuffer
+ */
+ public void rewindPixelBuffer() { if( null != readPixelBuffer ) { readPixelBuffer.rewind(); } }
+
+ /**
+ * @return the resulting TextureData, filled by {@link #readPixels(GLAutoDrawable, boolean)}
+ */
+ public TextureData getTextureData() { return readTextureData; }
+
+ /**
+ * @return the Texture object filled by {@link #readPixels(GLAutoDrawable, boolean)},
+ * if this instance writes to a 2d Texture, otherwise null.
+ * @see #GLReadBufferUtil(boolean, boolean)
+ */
+ public Texture getTexture() { return readTexture; }
+
+ /**
+ * Write the TextureData filled by {@link #readPixels(GLAutoDrawable, boolean)} to file
+ */
+ public void write(File dest) {
+ try {
+ TextureIO.write(readTextureData, dest);
+ rewindPixelBuffer();
+ } catch (IOException ex) {
+ throw new RuntimeException("can not write to file: " + dest.getAbsolutePath(), ex);
+ }
+ }
+
+ /**
+ * Read the drawable's pixels to TextureData and Texture, if requested at construction
+ *
+ * @param gl the current GL object
+ * @param drawable the drawable to read from
+ * @param flip weather to flip the data vertically or not
+ *
+ * @see #GLReadBufferUtil(boolean, boolean)
+ */
+ public void readPixels(GL gl, GLDrawable drawable, boolean flip) {
+ final int textureInternalFormat, textureDataFormat;
+ final int textureDataType = GL.GL_UNSIGNED_BYTE;
+ if(4 == components) {
+ textureInternalFormat=GL.GL_RGBA;
+ textureDataFormat=GL.GL_RGBA;
+ } else {
+ textureInternalFormat=GL.GL_RGB;
+ textureDataFormat=GL.GL_RGB;
+ }
+ final int readPixelSize = drawable.getWidth() * drawable.getHeight() * components ;
+ boolean newData = false;
+ if(readPixelSize>readPixelSizeLast) {
+ readPixelBuffer = Buffers.newDirectByteBuffer(readPixelSize);
+ readPixelSizeLast = readPixelSize ;
+ try {
+ readTextureData = new TextureData(
+ gl.getGLProfile(),
+ textureInternalFormat,
+ drawable.getWidth(), drawable.getHeight(),
+ 0,
+ textureDataFormat,
+ textureDataType,
+ false, false,
+ flip,
+ readPixelBuffer,
+ null /* Flusher */);
+ newData = true;
+ } catch (Exception e) {
+ readTextureData = null;
+ readPixelBuffer = null;
+ readPixelSizeLast = 0;
+ throw new RuntimeException("can not fetch offscreen texture", e);
+ }
+ }
+ if(null!=readPixelBuffer) {
+ psm.setAlignment(gl, alignment, alignment);
+ readPixelBuffer.clear();
+ gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), textureDataFormat, textureDataType, readPixelBuffer);
+ readPixelBuffer.rewind();
+ if(null != readTexture) {
+ if(newData) {
+ readTexture.updateImage(gl, readTextureData);
+ } else {
+ readTexture.updateSubImage(gl, readTextureData, 0,
+ 0, 0, // src offset
+ 0, 0, // dst offset
+ drawable.getWidth(), drawable.getHeight());
+ }
+ readPixelBuffer.rewind();
+ }
+ psm.restore(gl);
+ }
+ }
+
+ public void dispose(GL gl) {
+ if(null != readTexture) {
+ readTexture.destroy(gl);
+ readTextureData = null;
+ }
+ if(null != readPixelBuffer) {
+ readPixelBuffer.clear();
+ readPixelBuffer = null;
+ }
+ readPixelSizeLast = 0;
+ }
+
+}
+
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Locator.java b/src/jogl/classes/com/jogamp/opengl/util/Locator.java
deleted file mode 100644
index 0176b575a..000000000
--- a/src/jogl/classes/com/jogamp/opengl/util/Locator.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution 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.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- */
-
-package com.jogamp.opengl.util;
-
-import java.io.*;
-import java.net.*;
-
-/** Utilities for dealing with resources. */
-
-public class Locator {
- private Locator() {}
-
- /**
- * Locates the resource using 'getResource(String path, ClassLoader cl)',
- * with this context ClassLoader and the path as is,
- * as well with the context's package name path plus the path.
- *
- * @see #getResource(String, ClassLoader)
- */
- public static URL getResource(Class context, String path) {
- if(null == path) {
- return null;
- }
- ClassLoader contextCL = (null!=context)?context.getClassLoader():null;
- URL url = getResource(path, contextCL);
- if (url == null && null!=context) {
- // Try again by scoping the path within the class's package
- String className = context.getName().replace('.', '/');
- int lastSlash = className.lastIndexOf('/');
- if (lastSlash >= 0) {
- String tmpPath = className.substring(0, lastSlash + 1) + path;
- url = getResource(tmpPath, contextCL);
- }
- }
- return url;
- }
-
- /**
- * Locates the resource using the ClassLoader's facility,
- * the absolute URL and absolute file.
- *
- * @see ClassLoader#getResource(String)
- * @see ClassLoader#getSystemResource(String)
- * @see URL#URL(String)
- * @see File#File(String)
- */
- public static URL getResource(String path, ClassLoader cl) {
- if(null == path) {
- return null;
- }
- URL url = null;
- if (cl != null) {
- url = cl.getResource(path);
- if(!urlExists(url)) {
- url = null;
- }
- }
- if(null == url) {
- url = ClassLoader.getSystemResource(path);
- if(!urlExists(url)) {
- url = null;
- }
- }
- if(null == url) {
- try {
- url = new URL(path);
- if(!urlExists(url)) {
- url = null;
- }
- } catch (MalformedURLException e) { }
- }
- if(null == url) {
- try {
- File file = new File(path);
- if(file.exists()) {
- url = file.toURL();
- } else {
- }
- } catch (MalformedURLException e) {}
- }
- return url;
- }
-
- /**
- * Generates a path for the 'relativeFile' relative to the 'baseLocation'.
- *
- * @param baseLocation denotes a directory
- * @param relativeFile denotes a relative file to the baseLocation
- */
- public static String getRelativeOf(File baseLocation, String relativeFile) {
- if(null == relativeFile) {
- return null;
- }
-
- while (baseLocation != null && relativeFile.startsWith("../")) {
- baseLocation = baseLocation.getParentFile();
- relativeFile = relativeFile.substring(3);
- }
- if (baseLocation != null) {
- final File file = new File(baseLocation, relativeFile);
- // Handle things on Windows
- return file.getPath().replace('\\', '/');
- }
- return null;
- }
-
- /**
- * Generates a path for the 'relativeFile' relative to the 'baseLocation'.
- *
- * @param baseLocation denotes a URL to a file
- * @param relativeFile denotes a relative file to the baseLocation's parent directory
- */
- public static String getRelativeOf(URL baseLocation, String relativeFile) {
- String urlPath = baseLocation.getPath();
-
- if ( baseLocation.toString().startsWith("jar") ) {
- JarURLConnection jarConnection;
- try {
- jarConnection = (JarURLConnection) baseLocation.openConnection();
- urlPath = jarConnection.getEntryName();
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- // Try relative path first
- return getRelativeOf(new File(urlPath).getParentFile(), relativeFile);
- }
-
- /**
- * Returns true, if the url exists,
- * trying to open a connection.
- */
- public static boolean urlExists(URL url) {
- boolean v = false;
- if(null!=url) {
- try {
- URLConnection uc = url.openConnection();
- v = true;
- } catch (IOException ioe) { }
- }
- return v;
- }
-
-}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java b/src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java
deleted file mode 100644
index 4cf8cb1f0..000000000
--- a/src/jogl/classes/com/jogamp/opengl/util/StreamUtil.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution 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.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.opengl.util;
-
-import java.io.*;
-import java.nio.*;
-
-/** Utilities for dealing with streams. */
-
-public class StreamUtil {
- private StreamUtil() {}
-
- public static byte[] readAll2Array(InputStream stream) throws IOException {
- BytesRead bytesRead = readAllImpl(stream);
- byte[] data = bytesRead.data;
- if (bytesRead.payloadLen != data.length) {
- data = new byte[bytesRead.payloadLen];
- System.arraycopy(bytesRead.data, 0, data, 0, bytesRead.payloadLen);
- }
- return data;
- }
-
- public static ByteBuffer readAll2Buffer(InputStream stream) throws IOException {
- BytesRead bytesRead = readAllImpl(stream);
- return GLBuffers.newDirectByteBuffer(bytesRead.data, 0, bytesRead.payloadLen);
- }
-
- private static BytesRead readAllImpl(InputStream stream) throws IOException {
- // FIXME: Shall we do this here ?
- if( !(stream instanceof BufferedInputStream) ) {
- stream = new BufferedInputStream(stream);
- }
- int avail = stream.available();
- byte[] data = new byte[avail];
- int numRead = 0;
- int pos = 0;
- do {
- if (pos + avail > data.length) {
- byte[] newData = new byte[pos + avail];
- System.arraycopy(data, 0, newData, 0, pos);
- data = newData;
- }
- numRead = stream.read(data, pos, avail);
- if (numRead >= 0) {
- pos += numRead;
- }
- avail = stream.available();
- } while (avail > 0 && numRead >= 0);
-
- return new BytesRead(pos, data);
- }
-
- private static class BytesRead {
- BytesRead(int payloadLen, byte[] data) {
- this.payloadLen=payloadLen;
- this.data=data;
- }
- int payloadLen;
- byte[] data;
- }
-}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java
index 1275c9391..73d694cd9 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java
@@ -42,7 +42,6 @@ package com.jogamp.opengl.util.awt;
import java.awt.Graphics2D;
import javax.media.opengl.*;
-import com.jogamp.opengl.util.texture.*;
/** Provides a Java 2D overlay on top of an arbitrary GLDrawable,
making it easier to do things like draw text and images on top of
diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java
index 7019d720f..fa66673fd 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java
@@ -36,17 +36,20 @@
package com.jogamp.opengl.util.awt;
-import java.awt.image.*;
-import java.io.*;
-import java.nio.*;
-import java.nio.channels.*;
-import javax.imageio.*;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
-import javax.media.opengl.*;
-import javax.media.opengl.glu.*;
-import javax.media.opengl.glu.gl2.*;
+import javax.imageio.ImageIO;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLException;
+import javax.media.opengl.glu.gl2.GLUgl2;
-import com.jogamp.opengl.util.*;
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.util.GLPixelStorageModes;
+import com.jogamp.opengl.util.TGAWriter;
/** Utilities for taking screenshots of OpenGL applications. */
@@ -148,8 +151,8 @@ public class Screenshot {
GL2 gl = GLUgl2.getCurrentGL2();
// Set up pixel storage modes
- PixelStorageModes psm = new PixelStorageModes();
- psm.save(gl);
+ GLPixelStorageModes psm = new GLPixelStorageModes();
+ psm.setPackAlignment(gl, 1);
int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2.GL_BGR);
@@ -255,8 +258,8 @@ public class Screenshot {
GL2 gl = GLUgl2.getCurrentGL2();
// Set up pixel storage modes
- PixelStorageModes psm = new PixelStorageModes();
- psm.save(gl);
+ GLPixelStorageModes psm = new GLPixelStorageModes();
+ psm.setPackAlignment(gl, 1);
// read the BGR values into the image
gl.glReadPixels(x, y, width, height, readbackType,
@@ -375,7 +378,7 @@ public class Screenshot {
int width,
int height,
boolean alpha) throws IOException, GLException {
- String fileSuffix = FileUtil.getFileSuffix(file);
+ String fileSuffix = IOUtil.getFileSuffix(file);
if (alpha && (fileSuffix.equals("jpg") || fileSuffix.equals("jpeg"))) {
// JPEGs can't deal properly with alpha channels
alpha = false;
@@ -387,46 +390,10 @@ public class Screenshot {
}
}
- private static int glGetInteger(GL2 gl, int pname, int[] tmp) {
- gl.glGetIntegerv(pname, tmp, 0);
- return tmp[0];
- }
-
private static void checkExtABGR() {
GL2 gl = GLUgl2.getCurrentGL2();
if (!gl.isExtensionAvailable("GL_EXT_abgr")) {
throw new IllegalArgumentException("Saving alpha channel requires GL_EXT_abgr");
}
- }
-
- static class PixelStorageModes {
- int packAlignment;
- int packRowLength;
- int packSkipRows;
- int packSkipPixels;
- int packSwapBytes;
- int[] tmp = new int[1];
-
- void save(GL2 gl) {
- packAlignment = glGetInteger(gl, GL2.GL_PACK_ALIGNMENT, tmp);
- packRowLength = glGetInteger(gl, GL2.GL_PACK_ROW_LENGTH, tmp);
- packSkipRows = glGetInteger(gl, GL2.GL_PACK_SKIP_ROWS, tmp);
- packSkipPixels = glGetInteger(gl, GL2.GL_PACK_SKIP_PIXELS, tmp);
- packSwapBytes = glGetInteger(gl, GL2.GL_PACK_SWAP_BYTES, tmp);
-
- gl.glPixelStorei(GL2.GL_PACK_ALIGNMENT, 1);
- gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, 0);
- gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, 0);
- gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, 0);
- gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, 0);
- }
-
- void restore(GL2 gl) {
- gl.glPixelStorei(GL2.GL_PACK_ALIGNMENT, packAlignment);
- gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, packRowLength);
- gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, packSkipRows);
- gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, packSkipPixels);
- gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, packSwapBytes);
- }
- }
+ }
}
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 ad17dd288..12d80e42c 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -29,6 +29,8 @@
package com.jogamp.opengl.util.glsl;
import com.jogamp.common.nio.Buffers;
+import com.jogamp.common.util.IOUtil;
+
import javax.media.opengl.*;
import com.jogamp.opengl.util.*;
import jogamp.opengl.Debug;
@@ -299,13 +301,13 @@ public class ShaderCode {
URL nextURL = null;
// Try relative path first
- String next = Locator.getRelativeOf(url, includeFile);
+ String next = IOUtil.getRelativeOf(url, includeFile);
if(null != next) {
- nextURL = Locator.getResource(context, next);
+ nextURL = IOUtil.getResource(context, next);
}
if (nextURL == null) {
// Try absolute path
- nextURL = Locator.getResource(context, includeFile);
+ nextURL = IOUtil.getResource(context, includeFile);
}
if (nextURL == null) {
// Fail
@@ -335,7 +337,7 @@ public class ShaderCode {
}
public static String readShaderSource(Class context, String path) {
- URL url = Locator.getResource(context, path);
+ URL url = IOUtil.getResource(context, path);
if (url == null) {
return null;
}
@@ -346,11 +348,11 @@ public class ShaderCode {
public static ByteBuffer readShaderBinary(Class context, String path) {
try {
- URL url = Locator.getResource(context, path);
+ URL url = IOUtil.getResource(context, path);
if (url == null) {
return null;
}
- return StreamUtil.readAll2Buffer(new BufferedInputStream(url.openStream()));
+ return IOUtil.copyStream2ByteBuffer( new BufferedInputStream( url.openStream() ) );
} catch (IOException e) {
throw new RuntimeException(e);
}
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 a0eed50ea..1f79890dc 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
@@ -1,5 +1,7 @@
package com.jogamp.opengl.util.glsl.sdk;
+import com.jogamp.common.util.IOUtil;
+
import javax.media.opengl.*;
import com.jogamp.opengl.util.*;
import com.jogamp.opengl.util.glsl.*;
@@ -51,7 +53,7 @@ public abstract class CompileShader {
String justName = basename(resourceName);
outName = justName.substring(0, justName.length() - suffixLen) +
ShaderCode.getFileSuffix(true, type);
- URL resourceURL = Locator.getResource(null, resourceName);
+ URL resourceURL = IOUtil.getResource(null, resourceName);
String dirName = dirname(resourceURL.getPath());
outName = dirName + File.separator + "bin" + File.separator +
@@ -63,7 +65,7 @@ public abstract class CompileShader {
public void processOneShader(String resourceName, String outName, int type)
throws IOException, UnsupportedEncodingException, InterruptedException
{
- URL resourceURL = Locator.getResource(null, resourceName);
+ URL resourceURL = IOUtil.getResource(null, resourceName);
String dirName = dirname(resourceURL.getPath());
String shader = ShaderCode.readShaderSource(null, resourceName);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
index 35604ba30..08f56ef27 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
@@ -43,7 +43,6 @@ import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.media.nativewindow.NativeWindowFactory;
import jogamp.opengl.*;
-import com.jogamp.opengl.util.texture.*;
import com.jogamp.opengl.util.texture.spi.*;
/**
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java
index f598422bf..149a2d46c 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java
@@ -36,10 +36,11 @@
package com.jogamp.opengl.util.texture;
-import java.nio.*;
+import java.nio.Buffer;
-import javax.media.opengl.*;
-import com.jogamp.opengl.util.*;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.opengl.util.GLBuffers;
/**
* Represents the data for an OpenGL texture. This is separated from
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 792f80ff8..5be7f922b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 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
@@ -39,16 +40,33 @@
package com.jogamp.opengl.util.texture;
-import java.io.*;
-import java.net.*;
-import java.nio.*;
-import java.util.*;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
-import javax.media.opengl.*;
-import javax.media.opengl.glu.*;
import jogamp.opengl.Debug;
-import com.jogamp.opengl.util.*;
-import com.jogamp.opengl.util.texture.spi.*;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.util.texture.spi.DDSImage;
+import com.jogamp.opengl.util.texture.spi.NetPbmTextureWriter;
+import com.jogamp.opengl.util.texture.spi.SGIImage;
+import com.jogamp.opengl.util.texture.spi.TGAImage;
+import com.jogamp.opengl.util.texture.spi.TextureProvider;
+import com.jogamp.opengl.util.texture.spi.TextureWriter;
/** <P> Provides input and output facilities for both loading OpenGL
textures from disk and streams as well as writing textures already
@@ -177,7 +195,7 @@ public class TextureIO {
boolean mipmap,
String fileSuffix) throws IOException {
if (fileSuffix == null) {
- fileSuffix = FileUtil.getFileSuffix(file);
+ fileSuffix = IOUtil.getFileSuffix(file);
}
return newTextureDataImpl(glp, file, 0, 0, mipmap, fileSuffix);
}
@@ -234,7 +252,7 @@ public class TextureIO {
boolean mipmap,
String fileSuffix) throws IOException {
if (fileSuffix == null) {
- fileSuffix = FileUtil.getFileSuffix(url.getPath());
+ fileSuffix = IOUtil.getFileSuffix(url.getPath());
}
return newTextureDataImpl(glp, url, 0, 0, mipmap, fileSuffix);
}
@@ -288,7 +306,7 @@ public class TextureIO {
}
if (fileSuffix == null) {
- fileSuffix = FileUtil.getFileSuffix(file);
+ fileSuffix = IOUtil.getFileSuffix(file);
}
return newTextureDataImpl(glp, file, internalFormat, pixelFormat, mipmap, fileSuffix);
@@ -380,7 +398,7 @@ public class TextureIO {
}
if (fileSuffix == null) {
- fileSuffix = FileUtil.getFileSuffix(url.getPath());
+ fileSuffix = IOUtil.getFileSuffix(url.getPath());
}
return newTextureDataImpl(glp, url, internalFormat, pixelFormat, mipmap, fileSuffix);
@@ -437,7 +455,7 @@ public class TextureIO {
public static Texture newTexture(File file, boolean mipmap) throws IOException, GLException {
GL gl = GLContext.getCurrentGL();
GLProfile glp = gl.getGLProfile();
- TextureData data = newTextureData(glp, file, mipmap, FileUtil.getFileSuffix(file));
+ TextureData data = newTextureData(glp, file, mipmap, IOUtil.getFileSuffix(file));
Texture texture = newTexture(gl, data);
data.flush();
return texture;
@@ -494,7 +512,7 @@ public class TextureIO {
*/
public static Texture newTexture(URL url, boolean mipmap, String fileSuffix) throws IOException, GLException {
if (fileSuffix == null) {
- fileSuffix = FileUtil.getFileSuffix(url.getPath());
+ fileSuffix = IOUtil.getFileSuffix(url.getPath());
}
GL gl = GLContext.getCurrentGL();
GLProfile glp = gl.getGLProfile();
@@ -878,7 +896,7 @@ public class TextureIO {
boolean mipmap,
String fileSuffix) throws IOException {
if (DDS.equals(fileSuffix) ||
- DDS.equals(FileUtil.getFileSuffix(file))) {
+ DDS.equals(IOUtil.getFileSuffix(file))) {
DDSImage image = DDSImage.read(file);
return newTextureData(glp, image, internalFormat, pixelFormat, mipmap);
}
@@ -893,7 +911,7 @@ public class TextureIO {
String fileSuffix) throws IOException {
if (DDS.equals(fileSuffix) ||
DDSImage.isDDSImage(stream)) {
- byte[] data = StreamUtil.readAll2Array(stream);
+ byte[] data = IOUtil.copyStream2ByteArray(stream);
ByteBuffer buf = ByteBuffer.wrap(data);
DDSImage image = DDSImage.read(buf);
return newTextureData(glp, image, internalFormat, pixelFormat, mipmap);
@@ -1014,7 +1032,7 @@ public class TextureIO {
internalFormat,
pixelFormat,
mipmap,
- ((fileSuffix != null) ? fileSuffix : FileUtil.getFileSuffix(file)));
+ ((fileSuffix != null) ? fileSuffix : IOUtil.getFileSuffix(file)));
} finally {
inStream.close();
}
@@ -1113,7 +1131,7 @@ public class TextureIO {
static class DDSTextureWriter implements TextureWriter {
public boolean write(File file,
TextureData data) throws IOException {
- if (DDS.equals(FileUtil.getFileSuffix(file))) {
+ if (DDS.equals(IOUtil.getFileSuffix(file))) {
// See whether the DDS writer can handle this TextureData
int pixelFormat = data.getPixelFormat();
int pixelType = data.getPixelType();
@@ -1162,7 +1180,7 @@ public class TextureIO {
static class SGITextureWriter implements TextureWriter {
public boolean write(File file,
TextureData data) throws IOException {
- String fileSuffix = FileUtil.getFileSuffix(file);
+ String fileSuffix = IOUtil.getFileSuffix(file);
if (SGI.equals(fileSuffix) ||
SGI_RGB.equals(fileSuffix)) {
// See whether the SGI writer can handle this TextureData
@@ -1206,7 +1224,7 @@ public class TextureIO {
static class TGATextureWriter implements TextureWriter {
public boolean write(File file,
TextureData data) throws IOException {
- if (TGA.equals(FileUtil.getFileSuffix(file))) {
+ if (TGA.equals(IOUtil.getFileSuffix(file))) {
// See whether the TGA writer can handle this TextureData
int pixelFormat = data.getPixelFormat();
int pixelType = data.getPixelType();
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java
index 499dce7fb..ae9618490 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java
@@ -40,13 +40,12 @@
package com.jogamp.opengl.util.texture.spi;
import java.io.*;
-import java.net.*;
import java.nio.*;
import javax.media.opengl.*;
-import com.jogamp.opengl.util.*;
+
+import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.util.texture.*;
-import com.jogamp.opengl.util.texture.spi.*;
public class NetPbmTextureWriter implements TextureWriter {
int magic;
@@ -87,17 +86,17 @@ public class NetPbmTextureWriter implements TextureWriter {
// file suffix selection
if (0==magic) {
- if (PPM.equals(FileUtil.getFileSuffix(file))) {
+ if (PPM.equals(IOUtil.getFileSuffix(file))) {
magic = 6;
- } else if (PAM.equals(FileUtil.getFileSuffix(file))) {
+ } else if (PAM.equals(IOUtil.getFileSuffix(file))) {
magic = 7;
} else {
return false;
}
}
- int pixelFormat = data.getPixelFormat();
- int pixelType = data.getPixelType();
+ final int pixelFormat = data.getPixelFormat();
+ final int pixelType = data.getPixelType();
if ((pixelFormat == GL.GL_RGB ||
pixelFormat == GL.GL_RGBA) &&
(pixelType == GL.GL_BYTE ||
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java
index 405211204..89d0d20a1 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java
@@ -42,12 +42,12 @@ package com.jogamp.opengl.util.texture.spi.awt;
import java.awt.Graphics;
import java.awt.image.*;
import java.io.*;
-import java.net.*;
import java.nio.*;
import javax.imageio.*;
import javax.media.opengl.*;
-import com.jogamp.opengl.util.*;
+
+import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.util.awt.*;
import com.jogamp.opengl.util.texture.*;
import com.jogamp.opengl.util.texture.spi.*;
@@ -101,7 +101,7 @@ public class IIOTextureWriter implements TextureWriter {
ImageUtil.flipImageVertically(image);
// Happened to notice that writing RGBA images to JPEGS is broken
- if (TextureIO.JPG.equals(FileUtil.getFileSuffix(file)) &&
+ if (TextureIO.JPG.equals(IOUtil.getFileSuffix(file)) &&
image.getType() == BufferedImage.TYPE_4BYTE_ABGR) {
BufferedImage tmpImage = new BufferedImage(image.getWidth(), image.getHeight(),
BufferedImage.TYPE_3BYTE_BGR);
@@ -111,7 +111,7 @@ public class IIOTextureWriter implements TextureWriter {
image = tmpImage;
}
- return ImageIO.write(image, FileUtil.getFileSuffix(file), file);
+ return ImageIO.write(image, IOUtil.getFileSuffix(file), file);
}
throw new IOException("ImageIO writer doesn't support this pixel format / type (only GL_RGB/A + bytes)");
diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
index 31990af37..572955fd3 100644
--- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
+++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java
@@ -31,10 +31,11 @@ import java.io.IOException;
import javax.media.opengl.GLException;
import com.jogamp.common.util.IntObjectHashMap;
+import com.jogamp.common.util.IOUtil;
+
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.font.FontFactory;
-import com.jogamp.opengl.util.Locator;
import java.net.URL;
public class UbuntuFontLoader implements FontSet {
@@ -121,7 +122,7 @@ public class UbuntuFontLoader implements FontSet {
Font abspath(String fname, int family, int style) {
final String err = "Problem loading font "+fname+", stream "+relPath+fname;
try {
- URL url = Locator.getResource(UbuntuFontLoader.class, relPath+fname);
+ URL url = IOUtil.getResource(UbuntuFontLoader.class, relPath+fname);
if(null == url) {
throw new GLException(err);
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
index 179e4ed2c..cb0d1a372 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
@@ -56,7 +56,7 @@ public class TypecastFontConstructor implements FontConstructor {
public Font create(URL furl) throws IOException {
final File tf = File.createTempFile( "joglfont", ".ttf");
- final int len = IOUtil.copyURLToFile(furl, tf);
+ final int len = IOUtil.copyURL2File(furl, tf);
if(len==0) {
tf.delete();
throw new GLException("Font of stream "+furl+" was zero bytes");
diff --git a/src/jogl/native/openmax/omx_tool.h b/src/jogl/native/openmax/omx_tool.h
index dbc375dd7..d566507c1 100644
--- a/src/jogl/native/openmax/omx_tool.h
+++ b/src/jogl/native/openmax/omx_tool.h
@@ -10,25 +10,10 @@
// __declspec(dllimport) void __stdcall Sleep(unsigned long dwMilliseconds);
#define usleep(t) Sleep((t) / 1000)
-
- #ifdef _MSC_VER
- /* This typedef is apparently needed for Microsoft compilers before VC8,
- and on Windows CE */
- #if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1400 )
- #ifdef _WIN64
- typedef long long intptr_t;
- #else
- typedef int intptr_t;
- #endif
- #endif
- #else
- #include <inttypes.h>
- #endif
-#else
- #include <unistd.h>
- #include <inttypes.h>
#endif
+#include <gluegen_stdint.h>
+
#include <OMX_Core.h>
#include <OMX_Component.h>
#include <OMX_Index.h>
diff --git a/src/nativewindow/native/windows/GDImisc.c b/src/nativewindow/native/windows/GDImisc.c
index 9bead17ec..e8285008e 100644
--- a/src/nativewindow/native/windows/GDImisc.c
+++ b/src/nativewindow/native/windows/GDImisc.c
@@ -9,23 +9,7 @@
#include <wingdi.h>
#include <stddef.h>
-#ifdef _WIN32
- #ifdef _MSC_VER
- /* This typedef is apparently needed for Microsoft compilers before VC8,
- and on Windows CE */
- #if (_MSC_VER < 1400) || defined(UNDER_CE)
- #ifdef _WIN64
- typedef long long intptr_t;
- #else
- typedef int intptr_t;
- #endif
- #endif
- #else
- #include <inttypes.h>
- #endif
-#else
- #include <inttypes.h>
-#endif
+#include <gluegen_stdint.h>
#include <stdio.h>
diff --git a/src/nativewindow/native/x11/XineramaHelper.c b/src/nativewindow/native/x11/XineramaHelper.c
index 899bbba55..25a79645b 100644
--- a/src/nativewindow/native/x11/XineramaHelper.c
+++ b/src/nativewindow/native/x11/XineramaHelper.c
@@ -35,7 +35,7 @@
determine whether the Xinerama extension is in use and therefore to
treat the multiple AWT screens as one large screen. */
-#include <inttypes.h>
+#include <gluegen_stdint.h>
#include <X11/Xlib.h>
#ifdef __sun
diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c
index 0cca90420..80b482130 100644
--- a/src/newt/native/BroadcomEGL.c
+++ b/src/newt/native/BroadcomEGL.c
@@ -31,11 +31,7 @@
*
*/
-#ifdef _WIN32
- #include <windows.h>
-#else
- #include <inttypes.h>
-#endif
+#include <gluegen_stdint.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/newt/native/IntelGDL.c b/src/newt/native/IntelGDL.c
index 953181ccc..e287ad1fa 100644
--- a/src/newt/native/IntelGDL.c
+++ b/src/newt/native/IntelGDL.c
@@ -31,7 +31,7 @@
*
*/
-#include <inttypes.h>
+#include <gluegen_stdint.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c
index be0488fd1..b314f9d44 100644
--- a/src/newt/native/KDWindow.c
+++ b/src/newt/native/KDWindow.c
@@ -39,27 +39,7 @@
#include <stdio.h>
#include <string.h>
-#ifdef _WIN32
- /* This typedef is apparently needed for Microsoft compilers before VC8,
- and on Windows CE */
- #if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1400 )
- #ifdef _WIN64
- typedef long long intptr_t;
- #else
- typedef int intptr_t;
- #endif
- #elif !defined(__MINGW64__) && _MSC_VER <= 1500
- #ifdef _WIN64 // [
- typedef __int64 intptr_t;
- #else // _WIN64 ][
- typedef int intptr_t;
- #endif // _WIN64 ]
- #else
- #include <inttypes.h>
- #endif
-#else
- #include <inttypes.h>
-#endif
+#include <gluegen_stdint.h>
#include <KD/kd.h>
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 95f036b39..5e666631b 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -36,28 +36,13 @@
#include <Windowsx.h>
#include <tchar.h>
#include <stdlib.h>
+
// NOTE: it looks like SHFullScreen and/or aygshell.dll is not available on the APX 2500 any more
// #ifdef UNDER_CE
// #include "aygshell.h"
// #endif
-/* This typedef is apparently needed for Microsoft compilers before VC8,
- and on Windows CE and MingW32 */
-#if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1400 )
- #ifdef _WIN64
- typedef long long intptr_t;
- #else
- typedef int intptr_t;
- #endif
-#elif !defined(__MINGW64__) && _MSC_VER <= 1500
- #ifdef _WIN64 // [
- typedef __int64 intptr_t;
- #else // _WIN64 ][
- typedef int intptr_t;
- #endif // _WIN64 ]
-#else
- #include <inttypes.h>
-#endif
+#include <gluegen_stdint.h>
#if !defined(__MINGW64__) && _MSC_VER <= 1500
// FIXME: Determine for which MSVC versions ..
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 53dd97d44..5414de966 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -36,12 +36,9 @@
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
-// Building on obsolete platform on SPARC right now
-#ifdef __sparc
- #include <inttypes.h>
-#else
- #include <stdint.h>
-#endif
+
+#include <gluegen_stdint.h>
+
#include <unistd.h>
#include <errno.h>
#include <X11/Xlib.h>
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
index 0ecc8f67b..a837c56f8 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java
@@ -27,6 +27,7 @@
*/
package com.jogamp.opengl.test.junit.graph.demos;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -48,6 +49,7 @@ import com.jogamp.graph.curve.opengl.Renderer;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.util.GLReadBufferUtil;
/**
*
@@ -60,7 +62,7 @@ import com.jogamp.newt.opengl.GLWindow;
* - s: screenshot
*/
public abstract class GPURendererListenerBase01 implements GLEventListener {
- private Screenshot screenshot;
+ private GLReadBufferUtil screenshot;
private Renderer renderer;
private int renderModes;
private boolean debug;
@@ -88,7 +90,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
this.renderModes = renderModes;
this.debug = debug;
this.trace = trace;
- this.screenshot = new Screenshot();
+ this.screenshot = new GLReadBufferUtil(false, false);
}
public final Renderer getRenderer() { return renderer; }
@@ -191,8 +193,9 @@ public abstract class GPURendererListenerBase01 implements GLEventListener {
PrintWriter pw = new PrintWriter(sw);
pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), texSize, objName);
- String filename = dir + tech + sw +".tga";
- screenshot.surface2File(drawable, filename /*, exportAlpha */);
+ final String filename = dir + tech + sw +".tga";
+ screenshot.readPixels(drawable.getGL(), drawable, false);
+ screenshot.write(new File(filename));
}
int screenshot_num = 0;
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java
deleted file mode 100644
index dc1ea2da3..000000000
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ReadBufferUtil.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Copyright 2010 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.demos;
-
-import com.jogamp.opengl.util.GLBuffers;
-import java.nio.*;
-import javax.media.opengl.*;
-
-import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureData;
-
-public class ReadBufferUtil {
- protected int readPixelSizeLast = 0;
- protected Buffer readPixelBuffer = null;
- protected TextureData readTextureData = null;
- protected Texture readTexture = new Texture(GL.GL_TEXTURE_2D);
-
- public Buffer getPixelBuffer() { return readPixelBuffer; }
- public void rewindPixelBuffer() { readPixelBuffer.rewind(); }
-
- public TextureData getTextureData() { return readTextureData; }
- public Texture getTexture() { return readTexture; }
-
- public boolean isValid() {
- return null!=readTexture && null!=readTextureData && null!=readPixelBuffer ;
- }
-
- public void fetchOffscreenTexture(GLDrawable drawable, GL gl) {
- int readPixelSize = drawable.getWidth() * drawable.getHeight() * 3 ; // RGB
- boolean newData = false;
- if(readPixelSize>readPixelSizeLast) {
- readPixelBuffer = GLBuffers.newDirectGLBuffer(GL.GL_UNSIGNED_BYTE, readPixelSize);
- readPixelSizeLast = readPixelSize ;
- try {
- readTextureData = new TextureData(
- gl.getGLProfile(),
- // gl.isGL2GL3()?gl.GL_RGBA:gl.GL_RGB,
- GL.GL_RGB,
- drawable.getWidth(), drawable.getHeight(),
- 0,
- GL.GL_RGB,
- GL.GL_UNSIGNED_BYTE,
- false, false,
- false /* flip */,
- readPixelBuffer,
- null /* Flusher */);
- newData = true;
- } catch (Exception e) {
- readTextureData = null;
- readPixelBuffer = null;
- readPixelSizeLast = 0;
- throw new RuntimeException("can not fetch offscreen texture", e);
- }
- }
- if(null!=readPixelBuffer) {
- readPixelBuffer.clear();
- gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE, readPixelBuffer);
- readPixelBuffer.rewind();
- if(newData) {
- readTexture.updateImage(gl, readTextureData);
- } else {
- readTexture.updateSubImage(gl, readTextureData, 0,
- 0, 0, // src offset
- 0, 0, // dst offset
- drawable.getWidth(), drawable.getHeight());
- }
- readPixelBuffer.rewind();
- }
- }
-
- public void dispose(GL gl) {
- readTexture.destroy(gl);
- readTextureData = null;
- if(null != readPixelBuffer) {
- readPixelBuffer.clear();
- readPixelBuffer = null;
- }
- readPixelSizeLast = 0;
- }
-
-}
-
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java
deleted file mode 100644
index f4b6f6dd9..000000000
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/Screenshot.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.jogamp.opengl.test.junit.graph.demos;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
-
-import com.jogamp.opengl.util.texture.TextureIO;
-
-public class Screenshot {
-
- ReadBufferUtil readBufferUtil = new ReadBufferUtil();
-
- public void dispose(GL gl) {
- readBufferUtil.dispose(gl);
- }
-
- public void surface2File(GLAutoDrawable drawable, String filename) {
- GL gl = drawable.getGL();
- // FIXME glFinish() is an expensive paranoia sync, should not be necessary due to spec
- gl.glFinish();
- readBufferUtil.fetchOffscreenTexture(drawable, gl);
- gl.glFinish();
- try {
- surface2File(filename);
- } catch (IOException ex) {
- throw new RuntimeException("can not write survace to file", ex);
- }
- }
-
- void surface2File(String filename) throws IOException {
- File file = new File(filename);
- TextureIO.write(readBufferUtil.getTextureData(), file);
- System.err.println("Wrote: " + file.getAbsolutePath() + ", ...");
- readBufferUtil.rewindPixelBuffer();
- }
-
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
index df2dca4fb..b89f87be4 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java
@@ -27,6 +27,7 @@
*/
package com.jogamp.opengl.test.junit.graph.demos.ui;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -41,13 +42,12 @@ import javax.media.opengl.GLPipelineFactory;
import javax.media.opengl.GLRunnable;
import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.curve.opengl.TextRenderer;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.test.junit.graph.demos.Screenshot;
+import com.jogamp.opengl.util.GLReadBufferUtil;
/**
*
@@ -60,7 +60,7 @@ import com.jogamp.opengl.test.junit.graph.demos.Screenshot;
* - s: screenshot
*/
public abstract class UIListenerBase01 implements GLEventListener {
- private Screenshot screenshot;
+ private GLReadBufferUtil screenshot;
private RegionRenderer rRenderer;
private boolean debug;
private boolean trace;
@@ -85,7 +85,7 @@ public abstract class UIListenerBase01 implements GLEventListener {
this.rRenderer = rRenderer;
this.debug = debug;
this.trace = trace;
- this.screenshot = new Screenshot();
+ this.screenshot = new GLReadBufferUtil(false, false);
}
public final RegionRenderer getRegionRenderer() { return rRenderer; }
@@ -179,8 +179,9 @@ public abstract class UIListenerBase01 implements GLEventListener {
PrintWriter pw = new PrintWriter(sw);
pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), 0, objName);
- String filename = dir + tech + sw +".tga";
- screenshot.surface2File(drawable, filename /*, exportAlpha */);
+ final String filename = dir + tech + sw +".tga";
+ screenshot.readPixels(drawable.getGL(), drawable, false);
+ screenshot.write(new File(filename));
}
int screenshot_num = 0;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
new file mode 100644
index 000000000..a328a2bac
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
@@ -0,0 +1,319 @@
+/**
+ * Copyright 2010 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 com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.util.GLPixelStorageModes;
+import com.jogamp.opengl.test.junit.util.NEWTGLContext;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestGPUMemSec01NEWT extends UITestCase {
+ static String hexString(int i) {
+ return "0x"+Integer.toHexString(i);
+ }
+ static String exceptionMsg(String pre, int format, int type, int components, int width, int height, int rl1, int rl4, int rl8) {
+ return pre +
+ ": fmt "+hexString(format)+", type "+hexString(type)+", comps "+components+
+ ", "+width+"x"+height+
+ ", rowlenA1 "+rl1+", rowlenA4 "+rl4+", rowlenA8 "+rl8;
+ }
+
+ static NEWTGLContext.WindowContext createCurrentGLOffscreenWindow(int width, int height) throws GLException, InterruptedException {
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getGL2ES2(), width, height, true);
+ final GL _gl = winctx.context.getGL();
+ Assert.assertTrue(_gl.isGL2GL3());
+ final GL2GL3 gl = _gl.getGL2GL3();
+
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ // misc GL setup
+ gl.glClearColor(1, 1, 1, 1);
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ gl.glViewport(0, 0, width, height);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ return winctx;
+ }
+
+ static int readPixelsCheck(GL gl, int format, int type, int components, int width, int height) throws InterruptedException {
+ int expectedExceptions = 0;
+
+ final int rowlenA1 = width * components;
+
+ final int rowlenA4 = ( ( width * components + 3 ) / 4 ) * 4 ;
+ Assert.assertTrue(rowlenA4 % 4 == 0);
+
+ final int rowlenA8 = ( ( width * components + 7 ) / 8 ) * 8 ;
+ Assert.assertTrue(rowlenA8 % 8 == 0);
+
+ GLPixelStorageModes psm = new GLPixelStorageModes();
+ psm.setPackAlignment(gl, 1);
+
+ Exception ee = null;
+
+ // ok size !
+ try {
+ ByteBuffer bb = Buffers.newDirectByteBuffer(height*rowlenA1);
+ gl.glReadPixels(0, 0, width, height, format, type, bb);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ } catch(IndexOutOfBoundsException e) {
+ ee = e;
+ }
+ Assert.assertNull(
+ exceptionMsg("Unexpected IndexOutOfBoundsException (size ok, alignment 1)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ ee = null;
+
+
+ // too small -10 !
+ try {
+ ByteBuffer bb = Buffers.newDirectByteBuffer(height*rowlenA1-10);
+ gl.glReadPixels(0, 0, width, height, format, type, bb);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ } catch(IndexOutOfBoundsException e) {
+ ee = e;
+ System.err.println(
+ exceptionMsg("OK Expected IndexOutOfBoundsException (size-10 bytes)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8)+
+ ": "+ee.getMessage());
+ expectedExceptions++;
+ }
+ Assert.assertNotNull(
+ exceptionMsg("Expected IndexOutOfBoundsException (size-10 bytes)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ ee = null;
+
+ // too small size/4 !
+ try {
+ ByteBuffer bb = Buffers.newDirectByteBuffer(height*rowlenA1/4);
+ gl.glReadPixels(0, 0, width, height, format, type, bb);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ } catch(IndexOutOfBoundsException e) {
+ ee = e;
+ System.err.println(
+ exceptionMsg("OK Expected IndexOutOfBoundsException (size/4 bytes)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8)+
+ ": "+ee.getMessage());
+ expectedExceptions++;
+ }
+ Assert.assertNotNull(
+ exceptionMsg("Expected IndexOutOfBoundsException (size/4 bytes)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ ee = null;
+
+ //
+ // Alignment test
+ //
+ psm.setPackAlignment(gl, 4);
+
+ // ok size !
+ try {
+ ByteBuffer bb = Buffers.newDirectByteBuffer(height*rowlenA4);
+ gl.glReadPixels(0, 0, width, height, format, type, bb);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ } catch(IndexOutOfBoundsException e) {
+ ee = e;
+ }
+ Assert.assertNull(
+ exceptionMsg("Unexpected IndexOutOfBoundsException (size ok, alignment 4)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ ee = null;
+
+ // too small if rowlenA1%4 > 0
+ try {
+ ByteBuffer bb = Buffers.newDirectByteBuffer(height*rowlenA1);
+ gl.glReadPixels(0, 0, width, height, format, type, bb);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ } catch(IndexOutOfBoundsException e) {
+ ee = e;
+ if(rowlenA1%4>0) {
+ System.err.println(
+ exceptionMsg("OK Expected IndexOutOfBoundsException (alignment 4)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8)+
+ ": "+ee.getMessage());
+ expectedExceptions++;
+ }
+ }
+ if(rowlenA1%4>0) {
+ Assert.assertNotNull(
+ exceptionMsg("Expected IndexOutOfBoundsException (alignment 4)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ } else {
+ Assert.assertNull(
+ exceptionMsg("Unexpected IndexOutOfBoundsException (alignment 4)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ }
+ ee = null;
+
+ psm.setPackAlignment(gl, 8);
+
+ // ok size !
+ try {
+ ByteBuffer bb = Buffers.newDirectByteBuffer(height*rowlenA8);
+ gl.glReadPixels(0, 0, width, height, format, type, bb);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ } catch(IndexOutOfBoundsException e) {
+ ee = e;
+ }
+ Assert.assertNull(
+ exceptionMsg("Unexpected IndexOutOfBoundsException (size ok, alignment 8)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ ee = null;
+
+ // too small if rowlenA1%8 > 0
+ try {
+ ByteBuffer bb = Buffers.newDirectByteBuffer(height*rowlenA1);
+ gl.glReadPixels(0, 0, width, height, format, type, bb);
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+ } catch(IndexOutOfBoundsException e) {
+ ee = e;
+ if(rowlenA1%8>0) {
+ System.err.println(
+ exceptionMsg("OK Expected IndexOutOfBoundsException (alignment 8)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8)+
+ ": "+ee.getMessage());
+ expectedExceptions++;
+ }
+ }
+ if(rowlenA1%8>0) {
+ Assert.assertNotNull(
+ exceptionMsg("Expected IndexOutOfBoundsException (alignment 8)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ } else {
+ Assert.assertNull(
+ exceptionMsg("Unexpected IndexOutOfBoundsException (alignment 8)",
+ format, type, components, width, height, rowlenA1, rowlenA4, rowlenA8), ee);
+ }
+ ee = null;
+
+ psm.restore(gl);
+
+ return expectedExceptions;
+ }
+
+ @Test
+ public void testReadPixels_640x480xREDxUB() throws InterruptedException {
+ final int width = 640;
+ final int height= 480;
+
+ // preset ..
+ final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height);
+ final GLDrawable drawable = winctx.context.getGLDrawable();
+ final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
+
+ // 2 x too small - 0 x alignment
+ Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, width, height));
+
+ drawable.swapBuffers();
+ Thread.sleep(50);
+
+ NEWTGLContext.destroyWindow(winctx);
+ }
+
+ @Test
+ public void testReadPixels_640x480xRGBxUB() throws InterruptedException {
+ final int width = 640;
+ final int height= 480;
+
+ // preset ..
+ final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(width, height);
+ final GLDrawable drawable = winctx.context.getGLDrawable();
+ final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
+
+ // 2 x too small - 0 x alignment
+ Assert.assertEquals(2, readPixelsCheck(gl, GL2GL3.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, width, height));
+
+ drawable.swapBuffers();
+ Thread.sleep(50);
+
+ NEWTGLContext.destroyWindow(winctx);
+ }
+
+ @Test
+ public void testReadPixels_102x100xREDxUB() throws InterruptedException {
+ int wwidth = 640;
+ int wheight= 480;
+ int rwidth = 102;
+ int rheight= 100;
+
+ // preset ..
+ final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight);
+ final GLDrawable drawable = winctx.context.getGLDrawable();
+ final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
+
+ // 2 x too small - 2 x alignment
+ Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RED, GL.GL_UNSIGNED_BYTE, 1, rwidth, rheight));
+
+ drawable.swapBuffers();
+ Thread.sleep(50);
+
+ NEWTGLContext.destroyWindow(winctx);
+ }
+
+ @Test
+ public void testReadPixels_102x100xRGBxUB() throws InterruptedException {
+ final int wwidth = 640;
+ final int wheight= 480;
+ final int rwidth = 102;
+ final int rheight= 100;
+
+ // preset ..
+ final NEWTGLContext.WindowContext winctx = createCurrentGLOffscreenWindow(wwidth, wheight);
+ final GLDrawable drawable = winctx.context.getGLDrawable();
+ final GL2GL3 gl = winctx.context.getGL().getGL2GL3();
+
+ // 2 x too small - 2 x alignment
+ Assert.assertEquals(4, readPixelsCheck(gl, GL2GL3.GL_RGB, GL.GL_UNSIGNED_BYTE, 3, rwidth, rheight));
+
+ drawable.swapBuffers();
+ Thread.sleep(50);
+
+ NEWTGLContext.destroyWindow(winctx);
+ }
+
+ public static void main(String args[]) throws IOException {
+ String tstname = TestGPUMemSec01NEWT.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java
index 8b050374a..d0f73898f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java
@@ -104,7 +104,7 @@ public class TestGearsAWT extends UITestCase {
@Test
public void test01() throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
+ GLCapabilities caps = new GLCapabilities(glp);
runTestGL(caps);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
index 6c826c221..f3af56fb3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
@@ -56,7 +56,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
@Test
public void test01() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(GLProfile.getGL2ES2(), 640, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 640, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL _gl = winctx.context.getGL();
Assert.assertTrue(_gl.isGL2GL3());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
index c29faf31d..484734b28 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java
@@ -60,7 +60,7 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
@Test
public void testShaderState01Validation() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(GLProfile.getGL2ES2(), 480, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -173,18 +173,18 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
NEWTGLContext.destroyWindow(winctx);
}
- @Test
+ @Test(timeout=120000)
public void testShaderState00PerformanceSingleKeepEnabled() throws InterruptedException {
testShaderState00PerformanceSingle(false);
}
- @Test
+ @Test(timeout=120000)
public void testShaderState00PerformanceSingleToggleEnable() throws InterruptedException {
testShaderState00PerformanceSingle(true);
}
void testShaderState00PerformanceSingle(boolean toggleEnable) throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(GLProfile.getGL2ES2(), 480, 480, false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -240,17 +240,20 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
st.uniform(gl, pmvMatrixUniform);
gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
- long t0 = System.currentTimeMillis();
- int frames;
+ gl.setSwapInterval(0);
// validation ..
GLSLMiscHelper.displayVCArrays(drawable, gl, st, toggleEnable, vertices0, colors0, toggleEnable, 1, 0);
// warmup ..
- for(frames=0; frames<GLSLMiscHelper.frames_warmup; frames++) {
+ for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames++) {
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, toggleEnable, vertices0, colors0, toggleEnable);
- }
+ }
+
// measure ..
+ long t0 = System.currentTimeMillis();
+ int frames;
+
for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames++) {
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, toggleEnable, vertices0, colors0, toggleEnable);
}
@@ -267,10 +270,10 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
NEWTGLContext.destroyWindow(winctx);
}
- @Test
+ @Test(timeout=120000)
public void testShaderState01PerformanceDouble() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(GLProfile.getGL2ES2(), 480, 480, false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -336,18 +339,22 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
st.uniform(gl, pmvMatrixUniform);
gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
+ gl.setSwapInterval(0);
+
// validation ..
GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
-
- long t0 = System.currentTimeMillis();
- int frames;
+
// warmup ..
- for(frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
+ for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
- }
+ }
+
// measure ..
+ long t0 = System.currentTimeMillis();
+ int frames;
+
for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames+=2) {
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
index 0d81db137..2ecc3b30d 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
@@ -68,7 +68,7 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
private void testShaderState01Validation(boolean linkSP1) throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(GLProfile.getGL2ES2(), 480, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -229,10 +229,10 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
NEWTGLContext.destroyWindow(winctx);
}
- @Test
+ @Test(timeout=120000)
public void testShaderState01PerformanceDouble() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(GLProfile.getGL2ES2(), 480, 480, false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -308,6 +308,8 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
st.uniform(gl, pmvMatrixUniform);
gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
+ gl.setSwapInterval(0);
+
// validation ..
st.attachShaderProgram(gl, sp0);
GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
@@ -316,18 +318,20 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);
- long t0 = System.currentTimeMillis();
- int frames;
// warmup ..
- for(frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
+ for(int frames=0; frames<GLSLMiscHelper.frames_warmup; frames+=2) {
// SP0
st.attachShaderProgram(gl, sp0);
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
// SP1
st.attachShaderProgram(gl, sp1);
GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
- }
+ }
+
// measure ..
+ long t0 = System.currentTimeMillis();
+ int frames;
+
for(frames=0; frames<GLSLMiscHelper.frames_perftest; frames+=4) {
// SP0
st.attachShaderProgram(gl, sp0);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
index 365596711..cc0ec4601 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java
@@ -58,7 +58,7 @@ public class TestRulerNEWT01 extends UITestCase {
@Test
public void test01() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createWindow(GLProfile.getGL2ES2(), 640, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 640, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java
index 95e7d6e53..b829c8deb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2File.java
@@ -37,7 +37,7 @@ import java.io.File;
public class ReadBuffer2File extends ReadBufferBase {
public ReadBuffer2File(GLDrawable externalRead) {
- super(externalRead);
+ super(externalRead, false);
}
@Override
@@ -52,10 +52,9 @@ public class ReadBuffer2File extends ReadBufferBase {
}
File file = File.createTempFile("shot" + shotNum + "-", ".ppm");
- TextureIO.write(readBufferUtil.getTextureData(), file);
+ readBufferUtil.write(file);
System.out.println("Wrote: " + file.getAbsolutePath() + ", ...");
shotNum++;
- readBufferUtil.rewindPixelBuffer();
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
index 23271dde2..8c315e97f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBuffer2Screen.java
@@ -47,7 +47,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
boolean enableBufferVBO = true; // FIXME
public ReadBuffer2Screen (GLDrawable externalRead) {
- super(externalRead);
+ super(externalRead, true);
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java
index 53675bc31..e3ca25ae6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferBase.java
@@ -30,16 +30,19 @@ package com.jogamp.opengl.test.junit.jogl.offscreen;
import javax.media.opengl.*;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+
public class ReadBufferBase implements GLEventListener {
public boolean glDebug = false ;
public boolean glTrace = false ;
protected GLDrawable externalRead;
- ReadBufferUtil readBufferUtil = new ReadBufferUtil();
+ GLReadBufferUtil readBufferUtil;
- public ReadBufferBase (GLDrawable externalRead) {
+ public ReadBufferBase (GLDrawable externalRead, boolean write2Texture) {
this.externalRead = externalRead ;
+ this.readBufferUtil = new GLReadBufferUtil(false, write2Texture);
}
public void init(GLAutoDrawable drawable) {
@@ -84,7 +87,7 @@ public class ReadBufferBase implements GLEventListener {
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
- readBufferUtil.fetchOffscreenTexture(drawable, gl);
+ readBufferUtil.readPixels(gl, drawable, false);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java
deleted file mode 100644
index 5a2c73cf4..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/ReadBufferUtil.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Copyright 2010 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.offscreen;
-
-import com.jogamp.opengl.util.GLBuffers;
-import java.nio.*;
-import javax.media.opengl.*;
-
-import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureData;
-
-public class ReadBufferUtil {
- protected int readPixelSizeLast = 0;
- protected Buffer readPixelBuffer = null;
- protected TextureData readTextureData = null;
- protected Texture readTexture = new Texture(GL.GL_TEXTURE_2D);
-
- public Buffer getPixelBuffer() { return readPixelBuffer; }
- public void rewindPixelBuffer() { readPixelBuffer.rewind(); }
-
- public TextureData getTextureData() { return readTextureData; }
- public Texture getTexture() { return readTexture; }
-
- public boolean isValid() {
- return null!=readTexture && null!=readTextureData && null!=readPixelBuffer ;
- }
-
- public void fetchOffscreenTexture(GLDrawable drawable, GL gl) {
- int readPixelSize = drawable.getWidth() * drawable.getHeight() * 3 ; // RGB
- boolean newData = false;
- if(readPixelSize>readPixelSizeLast) {
- readPixelBuffer = GLBuffers.newDirectGLBuffer(GL.GL_UNSIGNED_BYTE, readPixelSize);
- readPixelSizeLast = readPixelSize ;
- try {
- readTextureData = new TextureData(
- gl.getGLProfile(),
- // gl.isGL2GL3()?gl.GL_RGBA:gl.GL_RGB,
- gl.GL_RGB,
- drawable.getWidth(), drawable.getHeight(),
- 0,
- gl.GL_RGB,
- gl.GL_UNSIGNED_BYTE,
- false, false,
- false /* flip */,
- readPixelBuffer,
- null /* Flusher */);
- newData = true;
- } catch (Exception e) {
- readTextureData = null;
- readPixelBuffer = null;
- readPixelSizeLast = 0;
- throw new RuntimeException("can not fetch offscreen texture", e);
- }
- }
- if(null!=readPixelBuffer) {
- readPixelBuffer.clear();
- gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE, readPixelBuffer);
- readPixelBuffer.rewind();
- if(newData) {
- readTexture.updateImage(gl, readTextureData);
- } else {
- readTexture.updateSubImage(gl, readTextureData, 0,
- 0, 0, // src offset
- 0, 0, // dst offset
- drawable.getWidth(), drawable.getHeight());
- }
- readPixelBuffer.rewind();
- }
- }
-
- public void dispose(GL gl) {
- readTexture.destroy(gl);
- readTextureData = null;
- readPixelBuffer.clear();
- readPixelBuffer = null;
- readPixelSizeLast = 0;
- }
-
-}
-
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
index 77fd40181..8ca1f3ef8 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java
@@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.offscreen;
import javax.media.opengl.*;
+import com.jogamp.opengl.util.GLReadBufferUtil;
import com.jogamp.opengl.util.texture.TextureIO;
import java.io.File;
@@ -39,7 +40,7 @@ import javax.media.nativewindow.*;
public class Surface2File implements SurfaceUpdatedListener {
- ReadBufferUtil readBufferUtil = new ReadBufferUtil();
+ GLReadBufferUtil readBufferUtil = new GLReadBufferUtil(false, false);
int shotNum = 0;
public void dispose(GL gl) {
@@ -54,7 +55,7 @@ public class Surface2File implements SurfaceUpdatedListener {
GL gl = ctx.getGL();
// FIXME glFinish() is an expensive paranoia sync, should not be necessary due to spec
gl.glFinish();
- readBufferUtil.fetchOffscreenTexture(drawable, gl);
+ readBufferUtil.readPixels(gl, drawable, false);
gl.glFinish();
try {
surface2File("shot");
@@ -71,9 +72,8 @@ public class Surface2File implements SurfaceUpdatedListener {
}
File file = File.createTempFile(basename + shotNum + "-", ".ppm");
- TextureIO.write(readBufferUtil.getTextureData(), file);
+ readBufferUtil.write(file);
System.err.println("Wrote: " + file.getAbsolutePath() + ", ...");
shotNum++;
- readBufferUtil.rewindPixelBuffer();
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
index b8df88901..3992c0876 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
@@ -31,8 +31,6 @@ import com.jogamp.newt.Display;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.Screen;
import com.jogamp.newt.Window;
-import com.jogamp.opengl.util.GLArrayDataServer;
-import com.jogamp.opengl.util.glsl.ShaderState;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
@@ -56,7 +54,44 @@ public class NEWTGLContext {
}
}
- public static WindowContext createWindow(GLProfile glp, int width, int height, boolean debugGL) throws InterruptedException {
+ public static WindowContext createOffscreenWindow(GLProfile glp, int width, int height, boolean debugGL) throws InterruptedException {
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setOnscreen(false);
+
+ //
+ // Create native windowing resources .. X11/Win/OSX
+ //
+ Display display = NewtFactory.createDisplay(null); // local display
+ Assert.assertNotNull(display);
+
+ Screen screen = NewtFactory.createScreen(display, 0); // screen 0
+ Assert.assertNotNull(screen);
+
+ Window window = NewtFactory.createWindow(screen, caps);
+ Assert.assertNotNull(window);
+ window.setSize(width, height);
+ window.setVisible(true);
+ AWTRobotUtil.waitForVisible(window, true);
+ AWTRobotUtil.waitForRealized(window, true);
+
+ GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
+ GLDrawable drawable = factory.createGLDrawable(window);
+ Assert.assertNotNull(drawable);
+
+ drawable.setRealized(true);
+
+ GLContext context = drawable.createContext(null);
+ Assert.assertNotNull(context);
+
+ context.enableGLDebugMessage(debugGL);
+
+ int res = context.makeCurrent();
+ Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res);
+
+ return new WindowContext(window, context);
+ }
+
+ public static WindowContext createOnscreenWindow(GLProfile glp, int width, int height, boolean debugGL) throws InterruptedException {
GLCapabilities caps = new GLCapabilities(glp);
//
// Create native windowing resources .. X11/Win/OSX
diff --git a/src/test/com/jogamp/opengl/test/junit/util/SingletonInstance.java b/src/test/com/jogamp/opengl/test/junit/util/SingletonInstance.java
deleted file mode 100644
index f72a41e15..000000000
--- a/src/test/com/jogamp/opengl/test/junit/util/SingletonInstance.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * Copyright 2010 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.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileLock;
-import java.util.Date;
-
-public class SingletonInstance {
-
- static final boolean DEBUG = true;
- static final String temp_file_path;
-
- static {
- String s = null;
- try {
- File tmpFile = File.createTempFile("TEST", "tst");
- String absTmpFile = tmpFile.getCanonicalPath();
- tmpFile.delete();
- s = absTmpFile.substring(0, absTmpFile.lastIndexOf(File.separator));
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- temp_file_path = s;
- }
-
- public static String getCanonicalTempPath() {
- return temp_file_path;
- }
-
- public static String getCanonicalTempLockFilePath(String basename) {
- return getCanonicalTempPath() + File.separator + basename;
- }
-
- public SingletonInstance(String name, String lockFileBasename) {
- this.name = name;
- this.file = new File ( getCanonicalTempLockFilePath ( lockFileBasename ) );
- setupFileCleanup();
- }
-
- public SingletonInstance(String name, File lockFile) {
- this.name = name;
- this.file = lockFile ;
- setupFileCleanup();
- }
-
- public String getName() { return name; }
-
- void setupFileCleanup() {
- file.deleteOnExit();
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- unlock();
- }
- });
- }
-
- public synchronized void lock(long timeout_ms, long poll_ms) {
- long i=0;
- try {
- do {
- if(tryLock()) {
- return;
- }
- if(DEBUG && 0==i) {
- System.err.println("SLOCK "+System.currentTimeMillis()+" ??? "+name+" - Wait for lock " + file);
- }
- i++;
- Thread.sleep(poll_ms);
- } while ( i < timeout_ms / poll_ms ) ;
- } catch ( InterruptedException ie ) {
- throw new RuntimeException(ie);
- }
- throw new RuntimeException("SLOCK "+System.currentTimeMillis()+" EEE "+name+" - couldn't get lock within "+timeout_ms+"ms");
- }
-
- public synchronized boolean tryLock() {
- try {
- randomAccessFile = new RandomAccessFile(file, "rw");
- fileLock = randomAccessFile.getChannel().tryLock();
-
- if (fileLock != null) {
- locked = true;
- if(DEBUG) {
- System.err.println("SLOCK "+System.currentTimeMillis()+" +++ "+name+" - Locked " + file);
- }
- return true;
- }
- } catch (Exception e) {
- System.err.println("SLOCK "+System.currentTimeMillis()+" EEE "+name+" - Unable to create and/or lock file: " + file);
- e.printStackTrace();
- }
- return false;
- }
-
- public synchronized boolean unlock() {
- try {
- if(null != fileLock) {
- if(locked) {
- fileLock.release();
- if(DEBUG) {
- System.err.println("SLOCK "+System.currentTimeMillis()+" --- "+name+" - Unlocked " + file);
- }
- }
- fileLock = null;
- }
- if(null != randomAccessFile) {
- randomAccessFile.close();
- randomAccessFile = null;
- }
- if(null != file) {
- file.delete();
- file = null;
- }
- return true;
- } catch (Exception e) {
- System.err.println("SLOCK "+System.currentTimeMillis()+" EEE "+name+" - Unable to remove lock file: " + file);
- e.printStackTrace();
- } finally {
- fileLock = null;
- randomAccessFile = null;
- locked = false;
- }
- return false;
- }
-
- public synchronized boolean isLocked() {
- return locked;
- }
-
- String name;
- File file = null;
- RandomAccessFile randomAccessFile = null;
- FileLock fileLock = null;
- boolean locked = false;
-}
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 ff2e838f6..a25835596 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
@@ -28,6 +28,8 @@
package com.jogamp.opengl.test.junit.util;
+import com.jogamp.common.util.locks.SingletonInstance;
+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.After;
@@ -40,13 +42,20 @@ public abstract class UITestCase {
@Rule public TestName _unitTestName = new TestName();
public static final String SINGLE_INSTANCE_LOCK_FILE = "UITestCase.lock";
+ public static final int SINGLE_INSTANCE_LOCK_PORT = 59999;
+
+ public static final long SINGLE_INSTANCE_LOCK_TO = 3*60*1000; // wait up to 3 min
+ public static final long SINGLE_INSTANCE_LOCK_POLL = 1000; // poll every 1s
static volatile SingletonInstance singletonInstance;
private final synchronized void initSingletonInstance() {
if( null == singletonInstance ) {
- singletonInstance = new SingletonInstance(getClass().getName(), SINGLE_INSTANCE_LOCK_FILE);
- singletonInstance.lock(3*60*1000, 1000); // wait up to 3 min, poll every 1s
+ // singletonInstance = SingletonInstance.createFileLock(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_FILE);
+ singletonInstance = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT);
+ if(!singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)) {
+ throw new RuntimeException("Fatal: Could lock single instance: "+singletonInstance.getName());
+ }
}
}