[libjogl2-java] 28/58: Imported Upstream version 2.0-rc9
Tony Mancill
tmancill at moszumanska.debian.org
Thu Sep 4 03:59:14 UTC 2014
This is an automated email from the git hooks/post-receive script.
tmancill pushed a commit to branch master
in repository libjogl2-java.
commit a79f0a14efa589f6235826342629c34166f4782e
Author: tony mancill <tmancill at debian.org>
Date: Fri Aug 29 18:44:13 2014 -0700
Imported Upstream version 2.0-rc9
---
make/build-common.xml | 43 +-
make/build-jogl.xml | 19 +-
make/build-newt.xml | 48 +-
make/build-test.xml | 100 +-
make/build.xml | 8 +-
make/config/jogl/gl-common-extensions.cfg | 1 -
make/config/jogl/gl-if-CustomJavaCode-gl.java | 3 +
make/config/jogl/gl-if-gl-ignores.cfg | 44 +-
make/config/jogl/gl-if-gl2_es2.cfg | 2 +
make/joglversion-test | 12 +
make/joglversion-test-android | 12 +
make/resources/android/AndroidManifest-jogl.xml | 8 +-
make/resources/android/AndroidManifest-test.xml | 7 +-
.../android/res-jogl/drawable-xhdpi/icon.png | Bin 0 -> 5742 bytes
make/resources/android/res-jogl/values/strings.xml | 4 +-
.../android/res-test/drawable-xhdpi/icon.png | Bin 0 -> 5742 bytes
make/scripts/adb-install-all-armv7.sh | 8 +-
make/scripts/adb-launch-main.sh | 32 +-
make/scripts/adb-uninstall-all.sh | 4 +-
make/scripts/cmpOld2New.sh | 4 +-
make/scripts/tests.sh | 55 +-
make/versions.xml | 2 +-
.../com/jogamp/graph/curve/OutlineShape.java | 1258 ++++++++++----------
src/jogl/classes/com/jogamp/graph/font/Font.java | 7 +
.../classes/com/jogamp/graph/math/Quaternion.java | 764 ++++++------
.../classes/com/jogamp/graph/math/VectorUtil.java | 866 +++++++-------
src/jogl/classes/com/jogamp/opengl/FloatUtil.java | 75 +-
.../classes/com/jogamp/opengl/swt/GLCanvas.java | 1 -
.../classes/com/jogamp/opengl/util/GLBuffers.java | 2 +
.../com/jogamp/opengl/util/texture/Texture.java | 15 +-
.../jogamp/opengl/util/texture/TextureData.java | 2 +-
.../com/jogamp/opengl/util/texture/TextureIO.java | 30 +-
.../jogamp/opengl/util/texture/spi/PNGImage.java | 53 +-
.../classes/javax/media/opengl/GLAutoDrawable.java | 16 +-
src/jogl/classes/javax/media/opengl/GLContext.java | 10 -
.../classes/javax/media/opengl/GLRunnable.java | 25 +-
.../classes/javax/media/opengl/awt/GLCanvas.java | 12 +-
.../classes/javax/media/opengl/awt/GLJPanel.java | 3 -
.../jogamp/graph/curve/opengl/RegionFactory.java | 148 +--
.../graph/curve/opengl/RegionRendererImpl01.java | 186 +--
src/jogl/classes/jogamp/graph/font/FontInt.java | 8 +-
.../jogamp/graph/font/typecast/TypecastFont.java | 5 +
.../font/typecast/TypecastFontConstructor.java | 2 +-
.../jogamp/graph/font/typecast/TypecastGlyph.java | 2 +-
.../graph/font/typecast/TypecastRenderer.java | 442 +++----
src/jogl/classes/jogamp/graph/math/MathFloat.java | 90 +-
src/jogl/classes/jogamp/opengl/GLContextImpl.java | 119 +-
src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 1 -
src/jogl/classes/jogamp/opengl/ProjectFloat.java | 10 +-
.../macosx/cgl/MacOSXCGLDrawableFactory.java | 1 -
.../jogamp/opengl/util/av/NullGLMediaPlayer.java | 2 +-
.../windows/wgl/WindowsWGLDrawableFactory.java | 1 -
.../opengl/x11/glx/X11GLXDrawableFactory.java | 1 -
.../jogamp/nativewindow/NWJNILibLoader.java | 2 +-
.../jogamp/nativewindow/jawt/JAWTJNILibLoader.java | 2 +-
src/newt/classes/com/jogamp/newt/NewtFactory.java | 11 +-
.../classes/com/jogamp/newt/opengl/GLWindow.java | 1 -
src/newt/classes/jogamp/newt/DisplayImpl.java | 3 +
src/newt/classes/jogamp/newt/NEWTJNILibLoader.java | 2 +-
src/newt/classes/jogamp/newt/ScreenImpl.java | 3 +
src/newt/classes/jogamp/newt/WindowImpl.java | 3 +
.../newt/driver/android/NewtVersionActivity.java | 65 +-
.../android/NewtVersionActivityLauncher.java | 21 +
.../jogamp/newt/driver/broadcom/egl/Display.java | 11 +-
.../jogamp/newt/driver/broadcom/egl/Screen.java | 3 +-
.../jogamp/newt/driver/broadcom/egl/Window.java | 8 +-
.../classes/jogamp/newt/driver/kd/KDDisplay.java | 14 +-
.../classes/jogamp/newt/driver/kd/KDScreen.java | 6 +-
.../classes/jogamp/newt/driver/kd/KDWindow.java | 10 +-
.../jogamp/opengl/test/android/LauncherUtil.java | 5 +-
.../test/android/NEWTGearsES2ActivityLauncher.java | 7 +-
.../test/android/NEWTRedSquareES2Activity.java | 17 +-
.../opengl/test/bugs/Bug427GLJPanelTest1.java | 144 +--
.../test/junit/graph/TestRegionRendererNEWT01.java | 417 ++++---
.../test/junit/graph/TestTextRendererNEWT00.java | 236 ++++
.../test/junit/graph/TestTextRendererNEWT01.java | 463 +++----
.../test/junit/graph/TestTextRendererNEWT10.java | 168 +++
.../graph/demos/GPUTextRendererListenerBase01.java | 2 -
.../acore/TestFloatUtil01MatrixMatrixMultNOUI.java | 113 ++
.../jogl/acore/TestGLContextSurfaceLockNEWT.java | 220 ++++
.../test/junit/jogl/acore/TestGPUMemSec01NEWT.java | 4 +-
.../junit/jogl/acore/TestMapBufferRead01NEWT.java | 4 +-
.../junit/jogl/demos/TextureDraw01Accessor.java} | 80 +-
...ureSequence.java => TextureSequenceDemo01.java} | 8 +-
.../test/junit/jogl/demos/es1/OneTriangle.java | 156 +--
.../opengl/test/junit/jogl/demos/es2/GearsES2.java | 23 +-
.../test/junit/jogl/demos/es2/RedSquareES2.java | 17 -
.../jogl/demos/es2/TextureDraw01ES2Listener.java | 249 ++++
...TexCubeES2.java => TextureSequenceCubeES2.java} | 84 +-
.../test/junit/jogl/demos/es2/av/MovieCube.java | 6 +-
.../junit/jogl/demos/es2/shader/texture01_xxx.fp | 20 +
.../junit/jogl/demos/es2/shader/texture01_xxx.vp | 17 +
.../gl2/TextureDraw01GL2Listener.java} | 26 +-
.../test/junit/jogl/glsl/TestFBOMRTNEWT01.java | 4 +-
.../junit/jogl/glsl/TestGLSLShaderState01NEWT.java | 10 +-
.../junit/jogl/glsl/TestGLSLShaderState02NEWT.java | 7 +-
.../test/junit/jogl/glsl/TestGLSLSimple01NEWT.java | 1 -
.../test/junit/jogl/glsl/TestRulerNEWT01.java | 5 +-
.../TestTransformFeedbackVaryingsBug407NEWT.java | 4 +-
.../junit/jogl/glu/TestGluUnprojectFloatNOUI.java | 55 +-
.../test/junit/jogl/swt/TestSWTAWT01GLn.java | 390 +++---
.../jogl/swt/TestSWTEclipseGLCanvas01GLn.java | 388 +++---
.../jogl/swt/TestSWTJOGLGLCanvas01GLnAWT.java | 348 +++---
.../texture/TestGrayTextureFromFileAWTBug417.java | 150 ---
.../test/junit/jogl/util/TestPNGImage01NEWT.java | 2 +-
.../TestGLReadBufferUtilTextureIOWrite01NEWT.java | 2 +-
.../TestGLReadBufferUtilTextureIOWrite02NEWT.java | 2 +-
.../util/texture/TestPNGTextureFromFileAWT.java | 238 ++++
.../util/texture/TestPNGTextureFromFileNEWT.java | 173 +++
.../jogl/{ => util}/texture/TestTexture01AWT.java | 6 +-
.../util/texture/TestTextureSequence01AWT.java | 112 ++
.../util/texture/TestTextureSequence01NEWT.java | 97 ++
.../jogl/{ => util}/texture/grayscale_texture.png | Bin
.../opengl/test/junit/util/NEWTGLContext.java | 11 +-
.../jogamp/opengl/test/junit/util/UITestCase.java | 2 -
115 files changed, 5489 insertions(+), 3742 deletions(-)
diff --git a/make/build-common.xml b/make/build-common.xml
index 1ac6f70..93835e0 100644
--- a/make/build-common.xml
+++ b/make/build-common.xml
@@ -88,7 +88,7 @@
<property name="nativewindow.version" value="${nativewindow_base_version}-b${jogl.build.number}-${version.timestamp}" />
<property name="jogl.version" value="${jogl_base_version}-b${jogl.build.number}-${version.timestamp}" />
<property name="newt.version" value="${newt_base_version}-b${jogl.build.number}-${version.timestamp}" />
- <property name="jogl.version.plus" value="${jogl_base_version}-${jogl.build.branch}-b${jogl.build.number}-${jogl.build.commit}-${version.timestamp}" />
+ <property name="jogl.version.plus" value="${jogl_base_version}-${jogl.build.branch}-b${jogl.build.number}-${version.timestamp}" />
<property name="archive.name" value="jogl-${jogl.version}-${os.and.arch}" />
<property name="archive" value="${build}/${archive.name}" />
@@ -398,8 +398,10 @@
<!-- JavaSE combinations -->
<property name="gluegen-rt.jar" value="${build.gluegen}/gluegen-rt.jar" />
+ <property name="gluegen-rt-android.jar" value="${build.gluegen}/gluegen-rt-android.jar" />
<property name="jogl.test.jar" value="${jar}/jogl.test.jar"/>
- <property name="jogl.test.apk" value="${jar}/jogl.test.apk"/>
+ <property name="jogl.test-android.jar" value="${jar}/jogl.test-android.jar"/>
+ <property name="jogl.test-android.apk" value="${jar}/jogl.test-android.apk"/>
<!-- JavaSE combinations . AWT -->
<property name="jogl.all.jar" value="${jar}/jogl.all.jar" />
@@ -408,7 +410,7 @@
<property name="jogl.all-noawt.jar" value="${jar}/jogl.all-noawt.jar" />
<property name="jogl.all-mobile.jar" value="${jar}/jogl.all-mobile.jar" />
<property name="jogl.all-android.jar" value="${jar}/jogl.all-android.jar" />
- <property name="jogl.all-android.apk" value="${jar}/jogl.all-android.apk" />
+ <property name="jogl.all-android.apk" value="${jar}/jogl.all-android-${android.abi}.apk" />
<path id="swt_gluegen.classpath">
<pathelement location="${gluegen-rt.jar}" />
@@ -422,29 +424,47 @@
<path refid="nativewindow_all_atoms.classpath" />
</path>
- <path id="android_nativewindow_gluegen.classpath">
+ <path id="nativewindow_gluegen_android.classpath">
<pathelement location="${android.jar}" />
- <pathelement location="${gluegen-rt.jar}" />
+ <pathelement location="${gluegen-rt-android.jar}" />
<pathelement location="${swt.jar}" />
<path refid="nativewindow_all_atoms.classpath" />
</path>
<!-- NEWT Compilation .. -->
<path id="jogl_nativewindow_gluegen.classpath">
- <pathelement location="${android.jar}" />
<pathelement location="${gluegen-rt.jar}" />
<pathelement location="${swt.jar}" />
<path refid="nativewindow_all_atoms.classpath" />
<path refid="jogl_all_atoms.classpath" />
</path>
+ <path id="jogl_nativewindow_gluegen_android.classpath">
+ <pathelement location="${android.jar}" />
+ <pathelement location="${gluegen-rt-android.jar}" />
+ <pathelement location="${swt.jar}" />
+ <path refid="nativewindow_all_atoms.classpath" />
+ <path refid="jogl_all_atoms.classpath" />
+ </path>
+
<!-- Test Compilation .. -->
+ <path id="junit_jogl_newt.compile.classpath">
+ <pathelement location="${junit.jar}" />
+ <pathelement location="${ant.jar}" />
+ <pathelement location="${ant-junit.jar}" />
+ <pathelement location="${gluegen-rt.jar}" />
+ <pathelement location="${swt.jar}" />
+ <path refid="nativewindow_all_atoms.classpath" />
+ <path refid="jogl_all_atoms.classpath" />
+ <path refid="newt_all_atoms.classpath" />
+ </path>
+
<path id="junit_jogl_newt_android.compile.classpath">
<pathelement location="${android.jar}" />
<pathelement location="${junit.jar}" />
<pathelement location="${ant.jar}" />
<pathelement location="${ant-junit.jar}" />
- <pathelement location="${gluegen-rt.jar}" />
+ <pathelement location="${gluegen-rt-android.jar}" />
<pathelement location="${swt.jar}" />
<path refid="nativewindow_all_atoms.classpath" />
<path refid="jogl_all_atoms.classpath" />
@@ -453,7 +473,7 @@
</path>
<!-- Postbuild: javadoc .. -->
- <path id="jogl_all.classpath">
+ <path id="jogl_doc.classpath">
<pathelement location="${android.jar}" />
<pathelement location="${gluegen-rt.jar}" />
<pathelement location="${swt.jar}" />
@@ -485,7 +505,6 @@
<property name="junit_jogl_noawt.run.jars"
value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${jogl.all-noawt.jar}${path.separator}${jogl.test.jar}"/>
<property name="junit_jogl_noawt.run.remote.jars" value="${junit.jar}${path.separator}${env.TARGET_ANT_HOME}/lib/ant.jar${path.separator}${env.TARGET_ANT_HOME}/lib/ant-junit.jar${path.separator}${gluegen-rt.jar}${path.separator}${jogl.all-noawt.jar}${path.separator}${jogl.test.jar}"/>
- <property name="junit.run.remote.apks" value="${gluegen.root}/${rootrel.build}/jogamp.android-launcher.apk${path.separator}${ant-junit-all.apk}${path.separator}${gluegen.root}/${rootrel.build}/gluegen-rt.apk${path.separator}${jogl.all-android.apk}${path.separator}${jogl.test.apk}"/>
<!-- Test Run w/ SWT .. -->
<path id="junit_jogl_swt.run.classpath">
@@ -506,12 +525,14 @@
<pathelement location="${ant.jar}" />
<pathelement location="${ant-junit.jar}" />
<pathelement location="${android.jar}" />
- <pathelement location="${gluegen-rt.jar}" />
+ <pathelement location="${gluegen-rt-android.jar}" />
<pathelement location="${jogl.all-android.jar}" />
<pathelement location="${jogl.test.jar}" />
</path>
<property name="junit_jogl_android.run.jars"
- value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${jogl.all-android.jar}${path.separator}${jogl.test.jar}"/>
+ value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt-android.jar}${path.separator}${jogl.all-android.jar}${path.separator}${jogl.test.jar}"/>
+ <property name="junit.run.remote.apks"
+ value="${gluegen.root}/${rootrel.build}/jogamp.android-launcher.apk${path.separator}${ant-junit-all.apk}${path.separator}${gluegen.root}/${rootrel.build}/gluegen-rt-android-${android.abi}.apk${path.separator}${jogl.all-android.apk}${path.separator}${jogl.test.apk}"/>
<!-- Dummy extra CLASSPATH value, maybe overwritten -->
<property name="junit_extra_classpath" value=""/>
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index f80efdf..0c7328c 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -194,20 +194,13 @@
<isset property="setup.noSWT"/>
</condition>
- <condition property="java.excludes.android"
- value="${java.part.android}">
- <not>
- <isset property="isAndroid"/>
- </not>
- </condition>
-
<property name="java.excludes.javadoc.packagenames"
value="jogamp.opengl.gl2.fixme.*,com.jogamp.audio.windows.waveout.TestSpatialization"/>
<property name="java.excludes.fixme"
value="jogamp/opengl/gl2/fixme/** com/jogamp/audio/windows/waveout/TestSpatialization.java" />
- <property name="java.excludes.all" value="${java.excludes.fixme} ${java.excludes.awt} ${java.excludes.swt} ${java.excludes.android}" />
+ <property name="java.excludes.all" value="${java.excludes.fixme} ${java.excludes.awt} ${java.excludes.swt}" />
<echo message="java.excludes.all: ${java.excludes.all}" />
</target>
@@ -1043,10 +1036,10 @@
</javac>
</target>
- <target name="java.compile.secondpass.javase" unless="isAndroid">
+ <target name="java.compile.secondpass.javase">
<!-- Perform the second pass Java compile; everything except portion of fixed function emulation depending on generated code. -->
<javac destdir="${classes}"
- excludes="com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java,${java.excludes.all}"
+ excludes="com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java,${java.excludes.all},${java.part.android}"
fork="yes"
includeAntRuntime="false"
memoryMaximumSize="${javac.memorymax}"
@@ -1064,7 +1057,7 @@
<target name="java.compile.secondpass.android" if="isAndroid">
<!-- Perform the second pass Java compile; everything except portion of fixed function emulation depending on generated code. -->
<javac destdir="${classes}"
- excludes="com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java,${java.excludes.all}"
+ includes="${java.part.android}"
fork="yes"
includeAntRuntime="false"
memoryMaximumSize="${javac.memorymax}"
@@ -1073,7 +1066,7 @@
target="${target.targetlevel}"
bootclasspath="${target.rt.jar}"
debug="${javacdebug}" debuglevel="${javacdebuglevel}">
- <classpath refid="android_nativewindow_gluegen.classpath"/>
+ <classpath refid="nativewindow_gluegen_android.classpath"/>
<src path="${src.java}" />
<src path="${src.generated.java}" />
</javac>
@@ -1085,7 +1078,7 @@
<target name="java.compile.thirdpass.javase">
<!-- Perform the third pass Java compile; everything including fixed function emulation. -->
<javac destdir="${classes}"
- excludes="${java.excludes.all}"
+ excludes="${java.excludes.all},${java.part.android}"
fork="yes"
includeAntRuntime="false"
memoryMaximumSize="${javac.memorymax}"
diff --git a/make/build-newt.xml b/make/build-newt.xml
index 2bf04bb..695c86d 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -203,9 +203,8 @@
- Compile the original and generated source.
-->
<target name="java.compile.javase">
- <!-- Perform the second pass Java compile; everything. -->
<javac destdir="${classes}"
- excludes="${java.excludes.all}"
+ excludes="${java.excludes.all} ${java.part.driver.android}"
fork="yes"
includeAntRuntime="false"
memoryMaximumSize="${javac.memorymax}"
@@ -219,7 +218,21 @@
</javac>
</target>
- <target name="java.compile" depends="java.compile.javase" />
+ <target name="java.compile.android" if="isAndroid">
+ <javac destdir="${classes}"
+ excludes="${java.excludes.all}"
+ fork="yes"
+ includeAntRuntime="false"
+ memoryMaximumSize="${javac.memorymax}"
+ encoding="UTF-8"
+ source="${target.sourcelevel}"
+ target="${target.targetlevel}"
+ bootclasspath="${target.rt.jar}"
+ debug="${javacdebug}" debuglevel="${javacdebuglevel}">
+ <src path="${src.java}" />
+ <classpath refid="jogl_nativewindow_gluegen_android.classpath"/>
+ </javac>
+ </target>
<!-- ================================================================== -->
<!--
@@ -644,6 +657,9 @@
<javah destdir="${src.generated.c}/X11" classpath="${javah.classpath}" class="jogamp.newt.driver.x11.X11Window" />
<javah destdir="${src.generated.c}/X11" classpath="${javah.classpath}" class="jogamp.newt.driver.x11.X11Screen" />
<javah destdir="${src.generated.c}/X11" classpath="${javah.classpath}" class="jogamp.newt.driver.x11.X11Display" />
+ </target>
+
+ <target name="c.build.newt.prepare.android" if="isAndroid">
<javah destdir="${src.generated.c}/Android" classpath="${javah.classpath}:${android.jar}" class="jogamp.newt.driver.android.AndroidWindow" />
</target>
@@ -662,7 +678,7 @@
<target name="c.build.newt.natives" depends="c.build.newt.windowlib" unless="setup.nonatives">
</target>
- <target name="c.build.newt" depends="c.configure,c.build.newt.prepare,c.build.newt.natives">
+ <target name="c.build.newt" depends="c.configure,c.build.newt.prepare,c.build.newt.prepare.android,c.build.newt.natives">
<antcall target="c.manifest" inheritRefs="true" />
</target>
@@ -670,8 +686,6 @@
<!--
- Build the newt.jar files.
-->
- <target name="build-jars" depends="gluegen.cpptasks.detect.os,build-jars-javase" />
-
<target name="setup-manifestfile">
<property name="manifestfile" value="newtversion"/>
<copy file="${manifestfile}"
@@ -713,10 +727,6 @@
<fileset dir="${classes}"
includes="${java.part.driver.macosx}"/>
</jar>
- <jar manifest="${build.newt}/manifest.mf" destfile="${newt.driver.android.jar}" filesonly="true">
- <fileset dir="${classes}"
- includes="${java.part.driver.android}"/>
- </jar>
<jar manifest="${build.newt}/manifest.mf" destfile="${newt.driver.kd.jar}" filesonly="true">
<fileset dir="${classes}"
includes="${java.part.driver.kd}"/>
@@ -746,6 +756,16 @@
<include name="jogamp/newt/Debug*" />
</fileset>
</jar>
+ </target>
+
+ <target name="build-jars-android" depends="setup-manifestfile" if="isAndroid">
+ <jar manifest="${build.newt}/manifest.mf" destfile="${newt.driver.android.jar}" filesonly="true">
+ <fileset dir="${classes}"
+ includes="${java.part.driver.android}"/>
+ </jar>
+ </target>
+
+ <target name="build-jars-native" depends="gluegen.cpptasks.detect.os,setup-manifestfile">
<jar manifest="${build.newt}/manifest.mf" destfile="${build.newt}/newt-natives-${os.and.arch}.jar" filesonly="true">
<fileset dir="${obj.newt}">
<include name="*.${native.library.suffix}" />
@@ -772,7 +792,7 @@
maxmemory="${javac.memorymax}"
linkoffline="${javadoc.link} 142-packages"
bottom="${javadoc.bottom}" >
- <classpath refid="jogl_nativewindow_gluegen.classpath"/>
+ <classpath refid="jogl_doc.classpath"/>
</javadoc>
</target>
@@ -788,7 +808,7 @@
maxmemory="${javac.memorymax}"
linkoffline="${javadoc.link} 142-packages"
bottom="${javadoc.bottom}" >
- <classpath refid="jogl_nativewindow_gluegen.classpath"/>
+ <classpath refid="jogl_doc.classpath"/>
</javadoc>
</target>
@@ -804,7 +824,7 @@
maxmemory="${javac.memorymax}"
linkoffline="${javadoc.link} 142-packages"
bottom="${javadoc.bottom}" >
- <classpath refid="jogl_nativewindow_gluegen.classpath"/>
+ <classpath refid="jogl_doc.classpath"/>
</javadoc>
</target>
@@ -827,7 +847,7 @@
<!--
- Build everything.
-->
- <target name="all" description="Build NEWT JAR file(s) and native libraries." depends="init,java.compile,c.build.newt,build-jars,generate.version.txt" />
+ <target name="all" description="Build NEWT JAR file(s) and native libraries." depends="init,java.compile.javase,build-jars-javase,java.compile.android,build-jars-android,c.build.newt,build-jars-native,generate.version.txt" />
<target name="generate.version.txt" depends="init">
<!-- Create a version.txt file indicating which version we just built -->
diff --git a/make/build-test.xml b/make/build-test.xml
index 96b3f08..f543790 100644
--- a/make/build-test.xml
+++ b/make/build-test.xml
@@ -26,7 +26,8 @@
<property name="classes" value="${build.test}/classes" />
<property name="classes.path" location="${classes}"/> <!-- absolute path -->
- <property name="java.part.test" value="com/jogamp/** jogamp/**"/>
+ <property name="java.part.test.all" value="com/jogamp/** jogamp/**"/>
+ <property name="java.part.test.android" value="com/jogamp/opengl/test/android/**"/>
<property name="java.dir.test" value="com/jogamp/opengl/test"/>
<property name="java.dir.junit" value="${java.dir.test}/junit"/>
<property name="java.dir.bugs" value="${java.dir.test}/bugs"/>
@@ -58,24 +59,45 @@
<!--
- Build/run tests/junit.
-->
- <target name="android.test.package" if="isAndroid">
- <aapt.signed
- assetsdir="resources/assets-test"
- jarsrcdir="${src}/test"
- jarbuilddir="${jar}"
- jarbasename="jogl.test"
- nativebuilddir="${lib}"
- nativebasename="non-existing"
- android.abi="${android.abi}"
- androidmanifest.path="resources/android/AndroidManifest-test.xml"
- androidresources.path="resources/android/res-test"
- jarmanifest.path="${build.jogl}/manifest.mf"
- version.code="${jogl_int_version}"
- version.name="${jogl.version.plus}" />
+ <target name="test.compile.javase">
+ <!-- Perform the junit pass Java SE compile -->
+ <javac destdir="${classes}"
+ excludes="${java.part.test.android}"
+ fork="yes"
+ includeAntRuntime="false"
+ memoryMaximumSize="${javac.memorymax}"
+ encoding="UTF-8"
+ source="${target.sourcelevel}"
+ target="${target.targetlevel}"
+ bootclasspath="${target.rt.jar}"
+ debug="${javacdebug}" debuglevel="${javacdebuglevel}">
+ <classpath refid="junit_jogl_newt.compile.classpath"/>
+ <src path="${src.test}" />
+ </javac>
+ <copy file="joglversion-test"
+ tofile="${build.test}/manifest-test.mf"
+ overwrite="true">
+ <filterset>
+ <filter token="VERSION" value="${jogl.version}"/>
+ <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
+ <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
+ <filter token="BASEVERSION" value="${jogl_base_version}"/>
+ </filterset>
+ </copy>
+
+ <jar manifest="${build.test}/manifest-test.mf" destfile="${jogl.test.jar}" filesonly="true">
+ <!-- get all class files, but skip any resource files that external tools
+ might have copied into the class directory (otherwise, it's possible
+ to get the same resource file twice in the jar) -->
+ <fileset dir="${classes}"
+ includes="${java.part.test.all}"
+ excludes="${java.part.test.android}"/>
+ <fileset dir="resources/assets-test" includes="**" />
+ </jar>
</target>
- <target name="test.compile.java">
- <!-- Perform the junit pass Java compile -->
+ <target name="test.compile.android" if="isAndroid">
+ <!-- Perform the junit pass Java Android compile -->
<javac destdir="${classes}"
fork="yes"
includeAntRuntime="false"
@@ -88,19 +110,38 @@
<classpath refid="junit_jogl_newt_android.compile.classpath"/>
<src path="${src.test}" />
</javac>
- <!-- include any resource files that tests may require -->
- <copy todir="${classes}">
- <fileset dir="${src.test}">
- <exclude name="**/*.java"/>
- </fileset>
+ <copy file="joglversion-test-android"
+ tofile="${build.test}/manifest-test-android.mf"
+ overwrite="true">
+ <filterset>
+ <filter token="VERSION" value="${jogl.version}"/>
+ <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
+ <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
+ <filter token="BASEVERSION" value="${jogl_base_version}"/>
+ </filterset>
</copy>
- <jar destfile="${jogl.test.jar}" filesonly="true">
+
+ <jar manifest="${build.test}/manifest-test-android.mf" destfile="${jogl.test-android.jar}" filesonly="true">
<!-- get all class files, but skip any resource files that external tools
might have copied into the class directory (otherwise, it's possible
to get the same resource file twice in the jar) -->
- <fileset dir="${classes}" includes="${java.part.test}"/>
+ <fileset dir="${classes}"
+ includes="${java.part.test.all}"/>
<fileset dir="resources/assets-test" includes="**" />
</jar>
+
+ <aapt.signed
+ assetsdir="resources/assets-test"
+ jarsrcdir="${src}/test"
+ jarbuilddir="${jar}"
+ jarbasename="jogl.test-android"
+ nativebuilddir="${lib}"
+ nativebasename="non-existing"
+ androidmanifest.path="resources/android/AndroidManifest-test.xml"
+ androidresources.path="resources/android/res-test"
+ jarmanifest.path="${build.test}/manifest-test-android.mf"
+ version.code="${jogl_int_version}"
+ version.name="${jogl.version.plus}" />
</target>
<target name="test.compile.check" depends="declare.common">
@@ -123,8 +164,14 @@
</target>
<target name="test.compile" depends="test.compile.check" unless="test.compile.skip">
- <antcall target="test.compile.java" inheritRefs="true" inheritAll="true"/>
- <antcall target="android.test.package" inheritRefs="true" inheritAll="true"/>
+ <!-- include any resource files that tests may require -->
+ <copy todir="${classes}">
+ <fileset dir="${src.test}">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ <antcall target="test.compile.javase" inheritRefs="true" inheritAll="true"/>
+ <antcall target="test.compile.android" inheritRefs="true" inheritAll="true"/>
</target>
<target name="test.manual.run" depends="test.compile">
@@ -557,6 +604,7 @@
rsync -av --delete --delete-after --delete-excluded \${line.separator}
--exclude 'build-x86*/' --exclude 'build-linux-x*/' --exclude 'build-android*/' --exclude 'build-win*/' --exclude 'build-mac*/' \${line.separator}
--exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \${line.separator}
+ --exclude 'make/lib/external/' \${line.separator}
${env.HOST_UID}@${env.HOST_IP}::${env.HOST_RSYNC_ROOT}/${jogl.basename} ${env.TARGET_ROOT} ${line.separator}
cd ${env.TARGET_ROOT}/${jogl.basename}/${env.NODE_LABEL}/make ${line.separator}
" append="true" file="${build.test}/targetcommand.sh" />
diff --git a/make/build.xml b/make/build.xml
index 5f85f9a..9258df0 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -372,7 +372,7 @@
source="${target.sourcelevel}"
maxmemory="${javac.memorymax}"
bottom="${javadoc.bottom}" >
- <classpath refid="jogl_all.classpath"/>
+ <classpath refid="jogl_doc.classpath"/>
<link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
<link offline="false" href="${gluegen.link}" />
<arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
@@ -394,7 +394,7 @@
source="${target.sourcelevel}"
maxmemory="${javac.memorymax}"
bottom="${javadoc.bottom}" >
- <classpath refid="jogl_all.classpath"/>
+ <classpath refid="jogl_doc.classpath"/>
<link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
<link offline="false" href="${gluegen.link}" />
<arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
@@ -417,7 +417,7 @@
source="${target.sourcelevel}"
maxmemory="${javac.memorymax}"
bottom="${javadoc.bottom}" >
- <classpath refid="jogl_all.classpath"/>
+ <classpath refid="jogl_doc.classpath"/>
<link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
<link offline="false" href="${gluegen.link}" />
<arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
@@ -439,7 +439,7 @@
source="${target.sourcelevel}"
maxmemory="${javac.memorymax}"
bottom="${javadoc.bottom}" >
- <classpath refid="jogl_all.classpath"/>
+ <classpath refid="jogl_doc.classpath"/>
<link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
<link offline="false" href="${gluegen.link}" />
<arg line="-J-Dnativetaglet.mapping=${basedir}/native-taglet.properties"/>
diff --git a/make/config/jogl/gl-common-extensions.cfg b/make/config/jogl/gl-common-extensions.cfg
index 51edd9e..6631e03 100644
--- a/make/config/jogl/gl-common-extensions.cfg
+++ b/make/config/jogl/gl-common-extensions.cfg
@@ -70,7 +70,6 @@ RenameExtensionIntoCore GL_OES_stencil4
RenameExtensionIntoCore GL_OES_stencil8
RenameExtensionIntoCore GL_OES_stencil_wrap
RenameExtensionIntoCore GL_OES_texture_cube_map
-RenameExtensionIntoCore GL_OES_texture_half_float
RenameExtensionIntoCore GL_OES_texture_mirrored_repeat
RenameExtensionIntoCore GL_OES_vertex_type_10_10_10_2
RenameExtensionIntoCore GL_EXT_color_buffer_half_float
diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl.java b/make/config/jogl/gl-if-CustomJavaCode-gl.java
index 4741b2d..77378aa 100644
--- a/make/config/jogl/gl-if-CustomJavaCode-gl.java
+++ b/make/config/jogl/gl-if-CustomJavaCode-gl.java
@@ -53,6 +53,9 @@
public static final int GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12;
/** Common in ES1, GL2 and GL3 */
public static final int GL_XOR = 0x1506;
+ /** Part of <code>GL_ARB_half_float_vertex</code>; <code>GL_NV_half_float</code>; <code>GL_ARB_half_float_pixel</code>,
+ earmarked for ES 3.0 (hence kept in GL while fixing Bug 590) */
+ public static final int GL_HALF_FLOAT = 0x140B;
public void glClearDepth( double depth );
diff --git a/make/config/jogl/gl-if-gl-ignores.cfg b/make/config/jogl/gl-if-gl-ignores.cfg
index 220bd74..25fbd5a 100644
--- a/make/config/jogl/gl-if-gl-ignores.cfg
+++ b/make/config/jogl/gl-if-gl-ignores.cfg
@@ -32,13 +32,19 @@ IgnoreExtension GL_EXT_debug_marker
IgnoreExtension GL_EXT_debug_label
IgnoreExtension GL_EXT_multisampled_render_to_texture
IgnoreExtension GL_EXT_framebuffer_multisample
-
+IgnoreExtension GL_OES_texture_half_float
+IgnoreExtension GL_OES_vertex_half_float
# IgnoreExtension GL_EXT_texture_storage
IgnoreExtension GL_NV_draw_buffers
IgnoreExtension GL_NV_fbo_color_attachments
IgnoreExtension GL_OES_vertex_array_object
IgnoreExtension GL_OES_texture_3D
-# above ext are subsumed, so ignore the aliased ones
+
+# includes GL_STATE_RESTORE, which hasn't the QCOM suffix
+IgnoreExtension GL_QCOM_extended_get
+Ignore GL_STATE_RESTORE
+
+# above ext mightbe subsumed, ignore the aliased ones
Ignore GL_ACTIVE_PROGRAM
Ignore GL_ALPHA16F
Ignore GL_ALPHA32F
@@ -156,10 +162,6 @@ Ignore glPushGroupMarkerEXT
# isn't included in GL2
Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET
-# includes GL_STATE_RESTORE, which hasn't the QCOM suffix
-IgnoreExtension GL_QCOM_extended_get
-Ignore GL_STATE_RESTORE
-
Ignore GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
Ignore GL_ACTIVE_ATTRIBUTES
Ignore GL_ACTIVE_UNIFORM_MAX_LENGTH
@@ -348,36 +350,6 @@ Ignore GL_NORMAL_ARRAY_TYPE
Ignore GL_NORMALIZE
Ignore GL_NORMAL_MAP_OES
Ignore GL_NUM_SHADER_BINARY_FORMATS
-Ignore GL_OES_blend_equation_separate
-Ignore GL_OES_blend_func_separate
-Ignore GL_OES_blend_subtract
-Ignore GL_OES_byte_coordinates
-Ignore GL_OES_compressed_ETC1_RGB8_texture
-Ignore GL_OES_compressed_paletted_texture
-Ignore GL_OES_depth24
-Ignore GL_OES_depth32
-Ignore GL_OES_draw_texture
-Ignore GL_OES_element_index_uint
-Ignore GL_OES_extended_matrix_palette
-Ignore GL_OES_fbo_render_mipmap
-Ignore GL_OES_fixed_point
-Ignore GL_OES_framebuffer_object
-Ignore GL_OES_matrix_get
-Ignore GL_OES_matrix_palette
-Ignore GL_OES_point_size_array
-Ignore GL_OES_point_sprite
-Ignore GL_OES_query_matrix
-Ignore GL_OES_read_format
-Ignore GL_OES_single_precision
-Ignore GL_OES_stencil1
-Ignore GL_OES_stencil4
-Ignore GL_OES_stencil8
-Ignore GL_OES_stencil_wrap
-Ignore GL_OES_texture_cube_map
-Ignore GL_OES_texture_env_crossbar
-Ignore GL_OES_texture_half_float
-Ignore GL_OES_texture_mirrored_repeat
-Ignore GL_OES_vertex_half_float
Ignore GL_ONE_MINUS_CONSTANT_ALPHA
Ignore GL_ONE_MINUS_CONSTANT_COLOR
Ignore GL_OPERAND0_ALPHA
diff --git a/make/config/jogl/gl-if-gl2_es2.cfg b/make/config/jogl/gl-if-gl2_es2.cfg
index 6a8aef0..85e7992 100644
--- a/make/config/jogl/gl-if-gl2_es2.cfg
+++ b/make/config/jogl/gl-if-gl2_es2.cfg
@@ -35,6 +35,8 @@ IgnoreExtension GL_EXT_discard_framebuffer
IgnoreExtension GL_OES_compressed_paletted_texture
IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture
IgnoreExtension GL_OES_vertex_array_object
+IgnoreExtension GL_OES_texture_half_float
+IgnoreExtension GL_OES_vertex_half_float
IgnoreExtension GL_OES_EGL_image_external
IgnoreExtension GL_EXT_debug_marker
IgnoreExtension GL_EXT_debug_label
diff --git a/make/joglversion-test b/make/joglversion-test
new file mode 100644
index 0000000..cee93db
--- /dev/null
+++ b/make/joglversion-test
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Specification-Title: Test Java Bindings for OpenGL API Specification
+Specification-Version: @BASEVERSION@
+Specification-Vendor: JogAmp Community
+Implementation-Title: Test Java Bindings for OpenGL Runtime Environment
+Implementation-Version: @VERSION@
+Implementation-Branch: @SCM_BRANCH@
+Implementation-Commit: @SCM_COMMIT@
+Implementation-Vendor: JogAmp Community
+Implementation-URL: http://jogamp.org/
+Extension-Name: com.jogamp.opengl.test
+Implementation-Vendor-Id: com.jogamp
diff --git a/make/joglversion-test-android b/make/joglversion-test-android
new file mode 100644
index 0000000..88c35be
--- /dev/null
+++ b/make/joglversion-test-android
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Specification-Title: Test Java Bindings for OpenGL API Specification
+Specification-Version: @BASEVERSION@
+Specification-Vendor: JogAmp Community
+Implementation-Title: Test Java Bindings for OpenGL Runtime Environment on Android
+Implementation-Version: @VERSION@
+Implementation-Branch: @SCM_BRANCH@
+Implementation-Commit: @SCM_COMMIT@
+Implementation-Vendor: JogAmp Community
+Implementation-URL: http://jogamp.org/
+Extension-Name: com.jogamp.opengl.test
+Implementation-Vendor-Id: com.jogamp
diff --git a/make/resources/android/AndroidManifest-jogl.xml b/make/resources/android/AndroidManifest-jogl.xml
index c2017d3..1c08cc4 100644
--- a/make/resources/android/AndroidManifest-jogl.xml
+++ b/make/resources/android/AndroidManifest-jogl.xml
@@ -3,15 +3,19 @@
sharedUserId="com.jogamp.Community"
package="javax.media.opengl">
- <uses-sdk android:minSdkVersion="9" />
+ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
+ <!-- uses-feature android:name="android.hardware.camera" android:required="false" / --> <!-- not yet -->
+
<uses-library android:name="com.jogamp.common" android:required="true" />
+ <uses-sdk android:minSdkVersion="9" />
+
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:description="@string/app_descr"
android:persistent="false"
>
- <activity android:name="jogamp.newt.driver.android.NewtVersionActivity"
+ <activity android:name="jogamp.newt.driver.android.NewtVersionActivityLauncher"
android:finishOnTaskLaunch="true"
android:launchMode="singleTop"
android:configChanges="keyboardHidden|orientation"
diff --git a/make/resources/android/AndroidManifest-test.xml b/make/resources/android/AndroidManifest-test.xml
index 4e6a5a2..3c2046d 100644
--- a/make/resources/android/AndroidManifest-test.xml
+++ b/make/resources/android/AndroidManifest-test.xml
@@ -3,9 +3,14 @@
sharedUserId="com.jogamp.Community"
package="com.jogamp.opengl.test">
- <uses-sdk android:minSdkVersion="9" />
+ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
+ <!-- uses-feature android:name="android.hardware.camera" android:required="false" / --> <!-- not yet -->
+
<uses-library android:name="com.jogamp.common" android:required="true" />
<uses-library android:name="javax.media.opengl" android:required="true" />
+ <uses-library android:name="jogamp.android.launcher" android:required="true" />
+
+ <uses-sdk android:minSdkVersion="9" />
<application android:icon="@drawable/icon"
android:label="@string/app_name"
diff --git a/make/resources/android/res-jogl/drawable-xhdpi/icon.png b/make/resources/android/res-jogl/drawable-xhdpi/icon.png
new file mode 100644
index 0000000..7e9d5ba
Binary files /dev/null and b/make/resources/android/res-jogl/drawable-xhdpi/icon.png differ
diff --git a/make/resources/android/res-jogl/values/strings.xml b/make/resources/android/res-jogl/values/strings.xml
index 6c0a469..3064dad 100644
--- a/make/resources/android/res-jogl/values/strings.xml
+++ b/make/resources/android/res-jogl/values/strings.xml
@@ -3,6 +3,6 @@
<string name="hello">Jogl Library</string>
<string name="app_name">JogAmp\'s Jogl Library</string>
<string name="app_descr">Contains Dalvik and native code, supporting native bindings.</string>
- <string name="activity_v_name">Jogl</string>
- <string name="activity_v_descr">The Jogl Library.</string>
+ <string name="activity_v_name">Jogl\'s Version</string>
+ <string name="activity_v_descr">Shows the version of the JOGL Library and runtime GL infos.</string>
</resources>
diff --git a/make/resources/android/res-test/drawable-xhdpi/icon.png b/make/resources/android/res-test/drawable-xhdpi/icon.png
new file mode 100644
index 0000000..7e9d5ba
Binary files /dev/null and b/make/resources/android/res-test/drawable-xhdpi/icon.png differ
diff --git a/make/scripts/adb-install-all-armv7.sh b/make/scripts/adb-install-all-armv7.sh
index 503c6f2..fe97655 100755
--- a/make/scripts/adb-install-all-armv7.sh
+++ b/make/scripts/adb-install-all-armv7.sh
@@ -1,4 +1,4 @@
-adb $* install ../../gluegen/build-android-armv7/jogamp.android-launcher.apk
-adb $* install ../../gluegen/build-android-armv7/gluegen-rt.apk
-adb $* install ../build-android-armv7/jar/jogl.all-android.apk
-adb $* install ../build-android-armv7/jar/jogl.test.apk
+#adb $* install ../../gluegen/build-android-armv7/jogamp.android-launcher.apk
+#adb $* install ../../gluegen/build-android-armv7/gluegen-rt-android-armeabi-v7a.apk
+adb $* install ../build-android-armv7/jar/jogl.all-android-armeabi-v7a.apk
+adb $* install ../build-android-armv7/jar/jogl.test-android.apk
diff --git a/make/scripts/adb-launch-main.sh b/make/scripts/adb-launch-main.sh
index 7e32165..ff47a7a 100644
--- a/make/scripts/adb-launch-main.sh
+++ b/make/scripts/adb-launch-main.sh
@@ -2,11 +2,13 @@
export HOST_UID=jogamp
# jogamp02 - 10.1.0.122
-export HOST_IP=10.1.0.122
+#export HOST_IP=10.1.0.122
+export HOST_IP=10.1.0.52
export HOST_RSYNC_ROOT=PROJECTS/JOGL
export TARGET_UID=jogamp
-export TARGET_IP=panda02
+#export TARGET_IP=panda02
+export TARGET_IP=jautab01
export TARGET_ADB_PORT=5555
export TARGET_ROOT=/data/projects
@@ -17,7 +19,7 @@ if [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then
export PATH=$ANDROID_SDK_HOME/platform-tools:$PATH
fi
-TSTCLASS=jogamp.android.launcher.LauncherUtil
+#TSTCLASS=jogamp.android.launcher.LauncherUtil
#TSTCLASS=com.jogamp.opengl.test.android.LauncherUtil
#TSTCLASS=com.jogamp.android.launcher.NEWTLauncherMain
#TSTCLASS=com.jogamp.nativewindow.NativeWindowVersion
@@ -32,6 +34,7 @@ TSTCLASS=jogamp.android.launcher.LauncherUtil
#TSTCLASS=com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01
#TSTCLASS=com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.newt.TestGearsGL2ES1NEWT
+TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT
LOGFILE=`basename $0 .sh`.log
@@ -40,7 +43,8 @@ RSYNC_EXCLUDES="--delete-excluded \
--exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \
--exclude 'gensrc/' --exclude 'doc/' --exclude 'jnlp-files' --exclude 'archive/' \
--exclude 'android-sdk/' --exclude 'resources/' --exclude 'scripts/' \
- --exclude 'stub_includes/' --exclude 'nbproject/' --exclude '*.log' --exclude '*.zip' --exclude '*.7z'"
+ --exclude 'stub_includes/' --exclude 'nbproject/' --exclude '*.log' --exclude '*.zip' --exclude '*.7z' \
+ --exclude 'make/lib/external/'"
echo "#! /system/bin/sh" > $BUILD_DIR/jogl-targetcommand.sh
@@ -51,16 +55,20 @@ rsync -av --delete --delete-after $RSYNC_EXCLUDES \
$TARGET_ROOT ; \
cd $TARGET_ROOT/jogl/make ;
export LD_LIBRARY_PATH=/system/lib:$TARGET_ROOT/gluegen/make/$BUILD_DIR/obj:$TARGET_ROOT/jogl/make/$BUILD_DIR/lib ; \
-# export BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
-dalvikvm \
- -Xjnigreflimit:2000 \
- -cp ../../gluegen/make/$BUILD_DIR/jogamp.android-launcher.apk:../../gluegen/make/lib/ant-junit-all.apk:../../gluegen/make/$BUILD_DIR/gluegen-rt.apk:$BUILD_DIR/jar/jogl.all-android.apk:$BUILD_DIR/jar/jogl.test.apk:$BUILD_DIR/jar/jogl.android-launcher.apk \
- -Dgluegen.root=../../gluegen \
- -Drootrel.build=build-android-armv7 \
- com.android.internal.util.WithFramework \
- $TSTCLASS \
+# export BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar ;
+setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \
+am start -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/$TSTCLASS/?pkg=com.jogamp.opengl.test\&newt.debug=all\&jogl.debug=all\&nativewindow.debug=all \
+# \
+#dalvikvm \
+# -Xjnigreflimit:2000 \
+# -cp ../../gluegen/make/$BUILD_DIR/jogamp.android-launcher.apk:../../gluegen/make/lib/ant-junit-all.apk:../../gluegen/make/$BUILD_DIR/gluegen-rt-android-armeabi-v7a.apk:$BUILD_DIR/jar/jogl.all-android-armeabi-v7a.apk:$BUILD_DIR/jar/jogl.test.apk \
+# -Dgluegen.root=../../gluegen \
+# -Drootrel.build=build-android-armv7 \
+# com.android.internal.util.WithFramework \
+# $TSTCLASS \
" >> $BUILD_DIR/jogl-targetcommand.sh
+
chmod ugo+x $BUILD_DIR/jogl-targetcommand.sh
adb connect $TARGET_IP:$TARGET_ADB_PORT
adb -s $TARGET_IP:$TARGET_ADB_PORT push $BUILD_DIR/jogl-targetcommand.sh $TARGET_ROOT/jogl-targetcommand.sh
diff --git a/make/scripts/adb-uninstall-all.sh b/make/scripts/adb-uninstall-all.sh
index 1605a0e..a80c38f 100755
--- a/make/scripts/adb-uninstall-all.sh
+++ b/make/scripts/adb-uninstall-all.sh
@@ -1,4 +1,4 @@
-adb $* uninstall jogamp.android.launcher
-adb $* uninstall com.jogamp.common
+#adb $* uninstall jogamp.android.launcher
+#adb $* uninstall com.jogamp.common
adb $* uninstall javax.media.opengl
adb $* uninstall com.jogamp.opengl.test
diff --git a/make/scripts/cmpOld2New.sh b/make/scripts/cmpOld2New.sh
index 4394fe7..7d68cfc 100755
--- a/make/scripts/cmpOld2New.sh
+++ b/make/scripts/cmpOld2New.sh
@@ -2,8 +2,8 @@
dirscript=`dirname $0`
-dirold=../build-x86_64-old/jogl/gensrc/classes/javax/media/opengl/
-dirnew=../build-x86_64/jogl/gensrc/classes/javax/media/opengl/
+dirold=../build-old/jogl/gensrc/classes/javax/media/opengl/
+dirnew=../build/jogl/gensrc/classes/javax/media/opengl/
dircmp=cmp-old2new
rm -rf $dircmp
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 81cb060..c9db615 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -53,16 +53,16 @@ function jrun() {
swton=$1
shift
- #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader"
- #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading"
- #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading"
- #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch"
- #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all"
+ #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL"
#D_ARGS="-Djogl.debug.GLDebugMessageHandler"
#D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL"
#D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState"
#D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL"
#D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode"
+ #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader"
+ #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading"
+ #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading"
+ #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all"
#D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer"
#D_ARGS="-Djogl.debug.GLArrayData"
#D_ARGS="-Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable"
@@ -151,6 +151,9 @@ function jrun() {
if [ ! -z "$CUSTOM_CLASSPATH" ] ; then
export CLASSPATH=$CUSTOM_CLASSPATH:$CLASSPATH
fi
+ #Test NEWT Broadcom ..
+ #export CLASSPATH=$JOGL_BUILD_DIR/jar/atomic/newt.driver.broadcomegl.jar::$CLASSPATH
+ #X_ARGS="-Dnativewindow.ws.name=jogamp.newt.driver.broadcom.egl $X_ARGS"
echo CLASSPATH $CLASSPATH
if [ $MOSX_MT -eq 1 ] ; then
X_ARGS="-XstartOnFirstThread $X_ARGS"
@@ -205,12 +208,17 @@ function testawtswt() {
#testnoawt com.jogamp.newt.opengl.GLWindow $*
#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $*
@@ -242,12 +250,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $*
#testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT
-#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestGLReadBufferUtilTextureIOWrite01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestGLReadBufferUtilTextureIOWrite02NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 $*
#
# awt (testawt)
@@ -273,9 +275,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $*
-#testawt com.jogamp.opengl.test.junit.jogl.texture.TestTexture01AWT
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT
-#testawt com.jogamp.opengl.test.junit.jogl.texture.TestGrayTextureFromFileAWTBug417
#testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $*
@@ -325,6 +325,24 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
#testawt $*
+#
+# Texture / TextureUtils
+#
+#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT
+testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $*
+#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $*
+
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $*
+
+#
+# GLSL / FBO / ..
+#
#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT $*
@@ -332,6 +350,11 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 $*
+#
+# Graph
+#
+#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $*
+#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $*
#testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $*
@@ -342,9 +365,11 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $*
#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo02 $*
+#
+# Security
+#
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
#
# osx bugs
diff --git a/make/versions.xml b/make/versions.xml
index 6cb59b9..f5d17ba 100644
--- a/make/versions.xml
+++ b/make/versions.xml
@@ -12,7 +12,7 @@
betas before release candidates to give the Community time to
react.-->
<property name="jogl_base_version" value="2.0" />
- <property name="jogl_int_version" value="2" />
+ <property name="jogl_int_version" value="0914010" /> <!-- xxyyzzz, xx=API yy screen-from-to zzz app-version-->
<!-- Uncomment this property in order to produce a JOGL release
build without running the "RI" (Reference Implementation)
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index 025a998..e60fba0 100755
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -1,629 +1,629 @@
-/**
- * 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.graph.curve;
-
-import java.util.ArrayList;
-import java.util.Collections;
-
-import com.jogamp.graph.curve.tess.Triangulation;
-import com.jogamp.graph.curve.tess.Triangulator;
-import com.jogamp.graph.geom.AABBox;
-import com.jogamp.graph.geom.Outline;
-import com.jogamp.graph.geom.Triangle;
-import com.jogamp.graph.geom.Vertex;
-import com.jogamp.graph.math.VectorUtil;
-
-
-/** A Generic shape objects which is defined by a list of Outlines.
- * This Shape can be transformed to Triangulations.
- * The list of triangles generated are render-able by a Region object.
- * The triangulation produced by this Shape will define the
- * closed region defined by the outlines.
- *
- * One or more OutlineShape Object can be associated to a region
- * this is left as a high-level representation of the Objects. For
- * optimizations, flexibility requirements for future features.
- *
- * <br><br>
- * Example to creating an Outline Shape:
- * <pre>
- addVertex(...)
- addVertex(...)
- addVertex(...)
- addEmptyOutline()
- addVertex(...)
- addVertex(...)
- addVertex(...)
- * </pre>
- *
- * The above will create two outlines each with three vertices. By adding these two outlines to
- * the OutlineShape, we are stating that the combination of the two outlines represent the shape.
- * <br>
- *
- * To specify that the shape is curved at a region, the on-curve flag should be set to false
- * for the vertex that is in the middle of the curved region (if the curved region is defined by 3
- * vertices (quadratic curve).
- * <br>
- * In case the curved region is defined by 4 or more vertices the middle vertices should both have
- * the on-curve flag set to false.
- *
- * <br>Example: <br>
- * <pre>
- addVertex(0,0, true);
- addVertex(0,1, false);
- addVertex(1,1, false);
- addVertex(1,0, true);
- * </pre>
- *
- * The above snippet defines a cubic nurbs curve where (0,1 and 1,1)
- * do not belong to the final rendered shape.
- *
- * <i>Implementation Notes:</i><br>
- * <ul>
- * <li> The first vertex of any outline belonging to the shape should be on-curve</li>
- * <li> Intersections between off-curved parts of the outline is not handled</li>
- * </ul>
- *
- * @see Outline
- * @see Region
- */
-public class OutlineShape implements Comparable<OutlineShape> {
- /**
- * Outline's vertices have undefined state until transformed.
- */
- public enum VerticesState {
- UNDEFINED(0), QUADRATIC_NURBS(1);
-
- public final int state;
-
- VerticesState(int state){
- this.state = state;
- }
- }
-
- public static final int DIRTY_BOUNDS = 1 << 0;
-
- private final Vertex.Factory<? extends Vertex> vertexFactory;
- private VerticesState outlineState;
-
- /** The list of {@link Outline}s that are part of this
- * outline shape.
- */
- private ArrayList<Outline> outlines;
- private AABBox bbox;
-
- /** dirty bits DIRTY_BOUNDS */
- private int dirtyBits;
-
- /** Create a new Outline based Shape
- */
- public OutlineShape(Vertex.Factory<? extends Vertex> factory) {
- this.vertexFactory = factory;
- this.outlines = new ArrayList<Outline>(3);
- this.outlines.add(new Outline());
- this.outlineState = VerticesState.UNDEFINED;
- this.bbox = new AABBox();
- this.dirtyBits = 0;
- }
-
- /** Clears all data and reset all states as if this instance was newly created */
- public void clear() {
- outlines.clear();
- outlines.add(new Outline());
- outlineState = VerticesState.UNDEFINED;
- bbox.reset();
- dirtyBits = 0;
- }
-
- /** Returns the associated vertex factory of this outline shape
- * @return Vertex.Factory object
- */
- public final Vertex.Factory<? extends Vertex> vertexFactory() { return vertexFactory; }
-
- public int getOutlineNumber() {
- return outlines.size();
- }
-
- /** Add a new empty {@link Outline}
- * to the end of this shape's outline list.
- * <p>If the {@link #getLastOutline()} is empty already, no new one will be added.</p>
- *
- * After a call to this function all new vertices added
- * will belong to the new outline
- */
- public void addEmptyOutline() {
- if( !getLastOutline().isEmpty() ) {
- outlines.add(new Outline());
- }
- }
-
- /** Appends the {@link Outline} element to the end,
- * ensuring a clean tail.
- *
- * <p>A clean tail is ensured, no double empty Outlines are produced
- * and a pre-existing empty outline will be replaced with the given one. </p>
- *
- * @param outline Outline object to be added
- * @throws NullPointerException if the {@link Outline} element is null
- */
- public void addOutline(Outline outline) throws NullPointerException {
- addOutline(outlines.size(), outline);
- }
-
- /** Insert the {@link Outline} element at the given {@code position}.
- *
- * <p>If the {@code position} indicates the end of this list,
- * a clean tail is ensured, no double empty Outlines are produced
- * and a pre-existing empty outline will be replaced with the given one. </p>
- *
- * @param position of the added Outline
- * @param outline Outline object to be added
- * @throws NullPointerException if the {@link Outline} element is null
- * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber())
- */
- public void addOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
- if (null == outline) {
- throw new NullPointerException("outline is null");
- }
- if( outlines.size() == position ) {
- final Outline lastOutline = getLastOutline();
- if( outline.isEmpty() && lastOutline.isEmpty() ) {
- return;
- }
- if( lastOutline.isEmpty() ) {
- outlines.set(position-1, outline);
- if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
- bbox.resize(outline.getBounds());
- }
- return;
- }
- }
- outlines.add(position, outline);
- if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
- bbox.resize(outline.getBounds());
- }
- }
-
- /** Insert the {@link OutlineShape} elements of type {@link Outline}, .. at the end of this shape,
- * using {@link #addOutline(Outline)} for each element.
- * <p>Closes the current last outline via {@link #closeLastOutline()} before adding the new ones.</p>
- * @param outlineShape OutlineShape elements to be added.
- * @throws NullPointerException if the {@link OutlineShape} is null
- * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber())
- */
- public void addOutlineShape(OutlineShape outlineShape) throws NullPointerException {
- if (null == outlineShape) {
- throw new NullPointerException("OutlineShape is null");
- }
- closeLastOutline();
- for(int i=0; i<outlineShape.getOutlineNumber(); i++) {
- addOutline(outlineShape.getOutline(i));
- }
- }
-
- /** Replaces the {@link Outline} element at the given {@code position}.
- * <p>Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.</p>
- *
- * @param position of the replaced Outline
- * @param outline replacement Outline object
- * @throws NullPointerException if the {@link Outline} element is null
- * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
- */
- public void setOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
- if (null == outline) {
- throw new NullPointerException("outline is null");
- }
- outlines.set(position, outline);
- dirtyBits |= DIRTY_BOUNDS;
- }
-
- /** Removes the {@link Outline} element at the given {@code position}.
- * <p>Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.</p>
- *
- * @param position of the to be removed Outline
- * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
- */
- public final Outline removeOutline(int position) throws IndexOutOfBoundsException {
- dirtyBits |= DIRTY_BOUNDS;
- return outlines.remove(position);
- }
-
- /** Get the last added outline to the list
- * of outlines that define the shape
- * @return the last outline
- */
- public final Outline getLastOutline() {
- return outlines.get(outlines.size()-1);
- }
-
- /** @return the {@code Outline} at {@code position}
- * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
- */
- public Outline getOutline(int position) throws IndexOutOfBoundsException {
- return outlines.get(position);
- }
-
- /** Adds a vertex to the last open outline in the
- * shape.
- * @param v the vertex to be added to the OutlineShape
- */
- public final void addVertex(Vertex v) {
- final Outline lo = getLastOutline();
- lo.addVertex(v);
- if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
- bbox.resize(lo.getBounds());
- }
- }
-
- /** Adds a vertex to the last open outline in the shape.
- * at {@code position}
- * @param position indx at which the vertex will be added
- * @param v the vertex to be added to the OutlineShape
- */
- public final void addVertex(int position, Vertex v) {
- final Outline lo = getLastOutline();
- lo.addVertex(position, v);
- if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
- bbox.resize(lo.getBounds());
- }
- }
-
- /** Add a 2D {@link Vertex} to the last outline by defining the coordniate attribute
- * of the vertex. The 2D vertex will be represented as Z=0.
- *
- * @param x the x coordinate
- * @param y the y coordniate
- * @param onCurve flag if this vertex is on the final curve or defines a curved region
- * of the shape around this vertex.
- */
- public final void addVertex(float x, float y, boolean onCurve) {
- addVertex(vertexFactory.create(x, y, 0f, onCurve));
- }
-
- /** Add a 3D {@link Vertex} to the last outline by defining the coordniate attribute
- * of the vertex.
- * @param x the x coordinate
- * @param y the y coordinate
- * @param z the z coordinate
- * @param onCurve flag if this vertex is on the final curve or defines a curved region
- * of the shape around this vertex.
- */
- public final void addVertex(float x, float y, float z, boolean onCurve) {
- addVertex(vertexFactory.create(x, y, z, onCurve));
- }
-
- /** Add a vertex to the last outline by passing a float array and specifying the
- * offset and length in which. The attributes of the vertex are located.
- * The attributes should be continuous (stride = 0).
- * Attributes which value are not set (when length less than 3)
- * are set implicitly to zero.
- * @param coordsBuffer the coordinate array where the vertex attributes are to be picked from
- * @param offset the offset in the buffer to the x coordinate
- * @param length the number of attributes to pick from the buffer (maximum 3)
- * @param onCurve flag if this vertex is on the final curve or defines a curved region
- * of the shape around this vertex.
- */
- public final void addVertex(float[] coordsBuffer, int offset, int length, boolean onCurve) {
- addVertex(vertexFactory.create(coordsBuffer, offset, length, onCurve));
- }
-
- /** Closes the last outline in the shape.
- * <p>If last vertex is not equal to first vertex.
- * A new temp vertex is added at the end which
- * is equal to the first.</p>
- */
- public void closeLastOutline() {
- getLastOutline().setClosed(true);
- }
-
- /**
- * @return the outline's vertices state, {@link OutlineShape.VerticesState}
- */
- public final VerticesState getOutlineState() {
- return outlineState;
- }
-
- /** Ensure the outlines represent
- * the specified destinationType.
- * and removes all overlaps in boundary triangles
- * @param destinationType the target outline's vertices state. Currently only
- * {@link OutlineShape.VerticesState#QUADRATIC_NURBS} are supported.
- */
- public void transformOutlines(VerticesState destinationType) {
- if(outlineState != destinationType){
- if(destinationType == VerticesState.QUADRATIC_NURBS){
- transformOutlines2Quadratic();
- checkOverlaps();
- } else {
- throw new IllegalStateException("destinationType "+destinationType.name()+" not supported (currently "+outlineState.name()+")");
- }
- }
- }
-
- private void subdivideTriangle(final Outline outline, Vertex a, Vertex b, Vertex c, int index){
- float[] v1 = VectorUtil.mid(a.getCoord(), b.getCoord());
- float[] v3 = VectorUtil.mid(b.getCoord(), c.getCoord());
- float[] v2 = VectorUtil.mid(v1, v3);
-
- //drop off-curve vertex to image on the curve
- b.setCoord(v2, 0, 3);
- b.setOnCurve(true);
-
- outline.addVertex(index, vertexFactory.create(v1, 0, 3, false));
- outline.addVertex(index+2, vertexFactory.create(v3, 0, 3, false));
- }
-
- /** Check overlaps between curved triangles
- * first check if any vertex in triangle a is in triangle b
- * second check if edges of triangle a intersect segments of triangle b
- * if any of the two tests is true we divide current triangle
- * and add the other to the list of overlaps
- *
- * Loop until overlap array is empty. (check only in first pass)
- */
- private void checkOverlaps() {
- ArrayList<Vertex> overlaps = new ArrayList<Vertex>(3);
- int count = getOutlineNumber();
- boolean firstpass = true;
- do {
- for (int cc = 0; cc < count; cc++) {
- final Outline outline = getOutline(cc);
- int vertexCount = outline.getVertexCount();
- for(int i=0; i < outline.getVertexCount(); i++) {
- final Vertex currentVertex = outline.getVertex(i);
- if ( !currentVertex.isOnCurve()) {
- final Vertex nextV = outline.getVertex((i+1)%vertexCount);
- final Vertex prevV = outline.getVertex((i+vertexCount-1)%vertexCount);
- Vertex overlap =null;
-
- //check for overlap even if already set for subdivision
- //ensuring both trianglur overlaps get divided
- //for pref. only check in first pass
- //second pass to clear the overlaps arrray(reduces precision errors)
- if(firstpass) {
- overlap = checkTriOverlaps(prevV, currentVertex, nextV);
- }
- if(overlaps.contains(currentVertex) || overlap != null) {
- overlaps.remove(currentVertex);
-
- subdivideTriangle(outline, prevV, currentVertex, nextV, i);
- i+=3;
- vertexCount+=2;
-
- if(overlap != null && !overlap.isOnCurve()) {
- if(!overlaps.contains(overlap))
- overlaps.add(overlap);
- }
- }
- }
- }
- }
- firstpass = false;
- }while(!overlaps.isEmpty());
- }
-
- private Vertex checkTriOverlaps(Vertex a, Vertex b, Vertex c) {
- int count = getOutlineNumber();
- for (int cc = 0; cc < count; cc++) {
- final Outline outline = getOutline(cc);
- int vertexCount = outline.getVertexCount();
- for(int i=0; i < vertexCount; i++) {
- final Vertex current = outline.getVertex(i);
- if(current.isOnCurve() || current == a || current == b || current == c) {
- continue;
- }
- final Vertex nextV = outline.getVertex((i+1)%vertexCount);
- final Vertex prevV = outline.getVertex((i+vertexCount-1)%vertexCount);
-
- //skip neighboring triangles
- if(prevV == c || nextV == a) {
- continue;
- }
-
- if(VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), current.getCoord())
- || VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), nextV.getCoord())
- || VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), prevV.getCoord())) {
-
- return current;
- }
- if(VectorUtil.tri2SegIntersection(a, b, c, prevV, current)
- || VectorUtil.tri2SegIntersection(a, b, c, current, nextV)
- || VectorUtil.tri2SegIntersection(a, b, c, prevV, nextV)) {
- return current;
- }
- }
- }
- return null;
- }
-
- private void transformOutlines2Quadratic() {
- int count = getOutlineNumber();
- for (int cc = 0; cc < count; cc++) {
- final Outline outline = getOutline(cc);
- int vertexCount = outline.getVertexCount();
-
- for(int i=0; i < vertexCount; i++) {
- final Vertex currentVertex = outline.getVertex(i);
- final Vertex nextVertex = outline.getVertex((i+1)%vertexCount);
- if ( !currentVertex.isOnCurve() && !nextVertex.isOnCurve() ) {
- final float[] newCoords = VectorUtil.mid(currentVertex.getCoord(),
- nextVertex.getCoord());
- final Vertex v = vertexFactory.create(newCoords, 0, 3, true);
- i++;
- vertexCount++;
- outline.addVertex(i, v);
- }
- }
- if(vertexCount <= 0) {
- outlines.remove(outline);
- cc--;
- count--;
- continue;
- }
-
- if( vertexCount > 0 ) {
- if(VectorUtil.checkEquality(outline.getVertex(0).getCoord(),
- outline.getLastVertex().getCoord())) {
- outline.removeVertex(vertexCount-1);
- }
- }
- }
- outlineState = VerticesState.QUADRATIC_NURBS;
- }
-
- private void generateVertexIds() {
- int maxVertexId = 0;
- for(int i=0; i<outlines.size(); i++) {
- final ArrayList<Vertex> vertices = outlines.get(i).getVertices();
- for(int pos=0; pos<vertices.size(); pos++) {
- Vertex vert = vertices.get(pos);
- vert.setId(maxVertexId);
- maxVertexId++;
- }
- }
- }
-
- /** @return the list of concatenated vertices associated with all
- * {@code Outline}s of this object
- */
- public ArrayList<Vertex> getVertices() {
- ArrayList<Vertex> vertices = new ArrayList<Vertex>();
- for(int i=0; i<outlines.size(); i++) {
- vertices.addAll(outlines.get(i).getVertices());
- }
- return vertices;
- }
-
- /**
- * Triangulate the {@link OutlineShape} generating a list of triangles
- * @return an arraylist of triangles representing the filled region
- * which is produced by the combination of the outlines
- */
- public ArrayList<Triangle> triangulate() {
- if(outlines.size() == 0){
- return null;
- }
- sortOutlines();
- generateVertexIds();
-
- Triangulator triangulator2d = Triangulation.create();
- for(int index = 0; index<outlines.size(); index++) {
- triangulator2d.addCurve(outlines.get(index));
- }
-
- ArrayList<Triangle> triangles = triangulator2d.generate();
- triangulator2d.reset();
-
- return triangles;
- }
-
- /** Sort the outlines from large
- * to small depending on the AABox
- */
- private void sortOutlines() {
- Collections.sort(outlines);
- Collections.reverse(outlines);
- }
-
- /** Compare two outline shapes with Bounding Box area
- * as criteria.
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public final int compareTo(OutlineShape outline) {
- float size = getBounds().getSize();
- float newSize = outline.getBounds().getSize();
- if(size < newSize){
- return -1;
- }
- else if(size > newSize){
- return 1;
- }
- return 0;
- }
-
- private final void validateBoundingBox() {
- dirtyBits &= ~DIRTY_BOUNDS;
- bbox.reset();
- for (int i=0; i<outlines.size(); i++) {
- bbox.resize(outlines.get(i).getBounds());
- }
- }
-
- public final AABBox getBounds() {
- if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
- validateBoundingBox();
- }
- return bbox;
- }
-
- /**
- * @param obj the Object to compare this OutlineShape with
- * @return true if {@code obj} is an OutlineShape, not null,
- * same outlineState, equal bounds and equal outlines in the same order
- */
- public boolean equals(Object obj) {
- if( obj == this) {
- return true;
- }
- if( null == obj || !(obj instanceof OutlineShape) ) {
- return false;
- }
- final OutlineShape o = (OutlineShape) obj;
- if(getOutlineState() != o.getOutlineState()) {
- return false;
- }
- if(getOutlineNumber() != o.getOutlineNumber()) {
- return false;
- }
- if( !getBounds().equals( o.getBounds() ) ) {
- return false;
- }
- for (int i=getOutlineNumber()-1; i>=0; i--) {
- if( ! getOutline(i).equals( o.getOutline(i) ) ) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * @return deep clone of this OutlineShape w/o Region
- */
- public OutlineShape clone() {
- OutlineShape o;
- try {
- o = (OutlineShape) super.clone();
- } catch (CloneNotSupportedException e) { throw new InternalError(); }
- o.bbox = bbox.clone();
- o.outlines = new ArrayList<Outline>(outlines.size());
- for(int i=0; i<outlines.size(); i++) {
- o.outlines.add(outlines.get(i).clone());
- }
- return o;
- }
-}
+/**
+ * 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.graph.curve;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import com.jogamp.graph.curve.tess.Triangulation;
+import com.jogamp.graph.curve.tess.Triangulator;
+import com.jogamp.graph.geom.AABBox;
+import com.jogamp.graph.geom.Outline;
+import com.jogamp.graph.geom.Triangle;
+import com.jogamp.graph.geom.Vertex;
+import com.jogamp.graph.math.VectorUtil;
+
+
+/** A Generic shape objects which is defined by a list of Outlines.
+ * This Shape can be transformed to Triangulations.
+ * The list of triangles generated are render-able by a Region object.
+ * The triangulation produced by this Shape will define the
+ * closed region defined by the outlines.
+ *
+ * One or more OutlineShape Object can be associated to a region
+ * this is left as a high-level representation of the Objects. For
+ * optimizations, flexibility requirements for future features.
+ *
+ * <br><br>
+ * Example to creating an Outline Shape:
+ * <pre>
+ addVertex(...)
+ addVertex(...)
+ addVertex(...)
+ addEmptyOutline()
+ addVertex(...)
+ addVertex(...)
+ addVertex(...)
+ * </pre>
+ *
+ * The above will create two outlines each with three vertices. By adding these two outlines to
+ * the OutlineShape, we are stating that the combination of the two outlines represent the shape.
+ * <br>
+ *
+ * To specify that the shape is curved at a region, the on-curve flag should be set to false
+ * for the vertex that is in the middle of the curved region (if the curved region is defined by 3
+ * vertices (quadratic curve).
+ * <br>
+ * In case the curved region is defined by 4 or more vertices the middle vertices should both have
+ * the on-curve flag set to false.
+ *
+ * <br>Example: <br>
+ * <pre>
+ addVertex(0,0, true);
+ addVertex(0,1, false);
+ addVertex(1,1, false);
+ addVertex(1,0, true);
+ * </pre>
+ *
+ * The above snippet defines a cubic nurbs curve where (0,1 and 1,1)
+ * do not belong to the final rendered shape.
+ *
+ * <i>Implementation Notes:</i><br>
+ * <ul>
+ * <li> The first vertex of any outline belonging to the shape should be on-curve</li>
+ * <li> Intersections between off-curved parts of the outline is not handled</li>
+ * </ul>
+ *
+ * @see Outline
+ * @see Region
+ */
+public class OutlineShape implements Comparable<OutlineShape> {
+ /**
+ * Outline's vertices have undefined state until transformed.
+ */
+ public enum VerticesState {
+ UNDEFINED(0), QUADRATIC_NURBS(1);
+
+ public final int state;
+
+ VerticesState(int state){
+ this.state = state;
+ }
+ }
+
+ public static final int DIRTY_BOUNDS = 1 << 0;
+
+ private final Vertex.Factory<? extends Vertex> vertexFactory;
+ private VerticesState outlineState;
+
+ /** The list of {@link Outline}s that are part of this
+ * outline shape.
+ */
+ private ArrayList<Outline> outlines;
+ private AABBox bbox;
+
+ /** dirty bits DIRTY_BOUNDS */
+ private int dirtyBits;
+
+ /** Create a new Outline based Shape
+ */
+ public OutlineShape(Vertex.Factory<? extends Vertex> factory) {
+ this.vertexFactory = factory;
+ this.outlines = new ArrayList<Outline>(3);
+ this.outlines.add(new Outline());
+ this.outlineState = VerticesState.UNDEFINED;
+ this.bbox = new AABBox();
+ this.dirtyBits = 0;
+ }
+
+ /** Clears all data and reset all states as if this instance was newly created */
+ public void clear() {
+ outlines.clear();
+ outlines.add(new Outline());
+ outlineState = VerticesState.UNDEFINED;
+ bbox.reset();
+ dirtyBits = 0;
+ }
+
+ /** Returns the associated vertex factory of this outline shape
+ * @return Vertex.Factory object
+ */
+ public final Vertex.Factory<? extends Vertex> vertexFactory() { return vertexFactory; }
+
+ public int getOutlineNumber() {
+ return outlines.size();
+ }
+
+ /** Add a new empty {@link Outline}
+ * to the end of this shape's outline list.
+ * <p>If the {@link #getLastOutline()} is empty already, no new one will be added.</p>
+ *
+ * After a call to this function all new vertices added
+ * will belong to the new outline
+ */
+ public void addEmptyOutline() {
+ if( !getLastOutline().isEmpty() ) {
+ outlines.add(new Outline());
+ }
+ }
+
+ /** Appends the {@link Outline} element to the end,
+ * ensuring a clean tail.
+ *
+ * <p>A clean tail is ensured, no double empty Outlines are produced
+ * and a pre-existing empty outline will be replaced with the given one. </p>
+ *
+ * @param outline Outline object to be added
+ * @throws NullPointerException if the {@link Outline} element is null
+ */
+ public void addOutline(Outline outline) throws NullPointerException {
+ addOutline(outlines.size(), outline);
+ }
+
+ /** Insert the {@link Outline} element at the given {@code position}.
+ *
+ * <p>If the {@code position} indicates the end of this list,
+ * a clean tail is ensured, no double empty Outlines are produced
+ * and a pre-existing empty outline will be replaced with the given one. </p>
+ *
+ * @param position of the added Outline
+ * @param outline Outline object to be added
+ * @throws NullPointerException if the {@link Outline} element is null
+ * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber())
+ */
+ public void addOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
+ if (null == outline) {
+ throw new NullPointerException("outline is null");
+ }
+ if( outlines.size() == position ) {
+ final Outline lastOutline = getLastOutline();
+ if( outline.isEmpty() && lastOutline.isEmpty() ) {
+ return;
+ }
+ if( lastOutline.isEmpty() ) {
+ outlines.set(position-1, outline);
+ if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
+ bbox.resize(outline.getBounds());
+ }
+ return;
+ }
+ }
+ outlines.add(position, outline);
+ if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
+ bbox.resize(outline.getBounds());
+ }
+ }
+
+ /** Insert the {@link OutlineShape} elements of type {@link Outline}, .. at the end of this shape,
+ * using {@link #addOutline(Outline)} for each element.
+ * <p>Closes the current last outline via {@link #closeLastOutline()} before adding the new ones.</p>
+ * @param outlineShape OutlineShape elements to be added.
+ * @throws NullPointerException if the {@link OutlineShape} is null
+ * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber())
+ */
+ public void addOutlineShape(OutlineShape outlineShape) throws NullPointerException {
+ if (null == outlineShape) {
+ throw new NullPointerException("OutlineShape is null");
+ }
+ closeLastOutline();
+ for(int i=0; i<outlineShape.getOutlineNumber(); i++) {
+ addOutline(outlineShape.getOutline(i));
+ }
+ }
+
+ /** Replaces the {@link Outline} element at the given {@code position}.
+ * <p>Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.</p>
+ *
+ * @param position of the replaced Outline
+ * @param outline replacement Outline object
+ * @throws NullPointerException if the {@link Outline} element is null
+ * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
+ */
+ public void setOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException {
+ if (null == outline) {
+ throw new NullPointerException("outline is null");
+ }
+ outlines.set(position, outline);
+ dirtyBits |= DIRTY_BOUNDS;
+ }
+
+ /** Removes the {@link Outline} element at the given {@code position}.
+ * <p>Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.</p>
+ *
+ * @param position of the to be removed Outline
+ * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
+ */
+ public final Outline removeOutline(int position) throws IndexOutOfBoundsException {
+ dirtyBits |= DIRTY_BOUNDS;
+ return outlines.remove(position);
+ }
+
+ /** Get the last added outline to the list
+ * of outlines that define the shape
+ * @return the last outline
+ */
+ public final Outline getLastOutline() {
+ return outlines.get(outlines.size()-1);
+ }
+
+ /** @return the {@code Outline} at {@code position}
+ * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber())
+ */
+ public Outline getOutline(int position) throws IndexOutOfBoundsException {
+ return outlines.get(position);
+ }
+
+ /** Adds a vertex to the last open outline in the
+ * shape.
+ * @param v the vertex to be added to the OutlineShape
+ */
+ public final void addVertex(Vertex v) {
+ final Outline lo = getLastOutline();
+ lo.addVertex(v);
+ if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
+ bbox.resize(lo.getBounds());
+ }
+ }
+
+ /** Adds a vertex to the last open outline in the shape.
+ * at {@code position}
+ * @param position indx at which the vertex will be added
+ * @param v the vertex to be added to the OutlineShape
+ */
+ public final void addVertex(int position, Vertex v) {
+ final Outline lo = getLastOutline();
+ lo.addVertex(position, v);
+ if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
+ bbox.resize(lo.getBounds());
+ }
+ }
+
+ /** Add a 2D {@link Vertex} to the last outline by defining the coordniate attribute
+ * of the vertex. The 2D vertex will be represented as Z=0.
+ *
+ * @param x the x coordinate
+ * @param y the y coordniate
+ * @param onCurve flag if this vertex is on the final curve or defines a curved region
+ * of the shape around this vertex.
+ */
+ public final void addVertex(float x, float y, boolean onCurve) {
+ addVertex(vertexFactory.create(x, y, 0f, onCurve));
+ }
+
+ /** Add a 3D {@link Vertex} to the last outline by defining the coordniate attribute
+ * of the vertex.
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @param z the z coordinate
+ * @param onCurve flag if this vertex is on the final curve or defines a curved region
+ * of the shape around this vertex.
+ */
+ public final void addVertex(float x, float y, float z, boolean onCurve) {
+ addVertex(vertexFactory.create(x, y, z, onCurve));
+ }
+
+ /** Add a vertex to the last outline by passing a float array and specifying the
+ * offset and length in which. The attributes of the vertex are located.
+ * The attributes should be continuous (stride = 0).
+ * Attributes which value are not set (when length less than 3)
+ * are set implicitly to zero.
+ * @param coordsBuffer the coordinate array where the vertex attributes are to be picked from
+ * @param offset the offset in the buffer to the x coordinate
+ * @param length the number of attributes to pick from the buffer (maximum 3)
+ * @param onCurve flag if this vertex is on the final curve or defines a curved region
+ * of the shape around this vertex.
+ */
+ public final void addVertex(float[] coordsBuffer, int offset, int length, boolean onCurve) {
+ addVertex(vertexFactory.create(coordsBuffer, offset, length, onCurve));
+ }
+
+ /** Closes the last outline in the shape.
+ * <p>If last vertex is not equal to first vertex.
+ * A new temp vertex is added at the end which
+ * is equal to the first.</p>
+ */
+ public void closeLastOutline() {
+ getLastOutline().setClosed(true);
+ }
+
+ /**
+ * @return the outline's vertices state, {@link OutlineShape.VerticesState}
+ */
+ public final VerticesState getOutlineState() {
+ return outlineState;
+ }
+
+ /** Ensure the outlines represent
+ * the specified destinationType.
+ * and removes all overlaps in boundary triangles
+ * @param destinationType the target outline's vertices state. Currently only
+ * {@link OutlineShape.VerticesState#QUADRATIC_NURBS} are supported.
+ */
+ public void transformOutlines(VerticesState destinationType) {
+ if(outlineState != destinationType){
+ if(destinationType == VerticesState.QUADRATIC_NURBS){
+ transformOutlines2Quadratic();
+ checkOverlaps();
+ } else {
+ throw new IllegalStateException("destinationType "+destinationType.name()+" not supported (currently "+outlineState.name()+")");
+ }
+ }
+ }
+
+ private void subdivideTriangle(final Outline outline, Vertex a, Vertex b, Vertex c, int index){
+ float[] v1 = VectorUtil.mid(a.getCoord(), b.getCoord());
+ float[] v3 = VectorUtil.mid(b.getCoord(), c.getCoord());
+ float[] v2 = VectorUtil.mid(v1, v3);
+
+ //drop off-curve vertex to image on the curve
+ b.setCoord(v2, 0, 3);
+ b.setOnCurve(true);
+
+ outline.addVertex(index, vertexFactory.create(v1, 0, 3, false));
+ outline.addVertex(index+2, vertexFactory.create(v3, 0, 3, false));
+ }
+
+ /** Check overlaps between curved triangles
+ * first check if any vertex in triangle a is in triangle b
+ * second check if edges of triangle a intersect segments of triangle b
+ * if any of the two tests is true we divide current triangle
+ * and add the other to the list of overlaps
+ *
+ * Loop until overlap array is empty. (check only in first pass)
+ */
+ private void checkOverlaps() {
+ ArrayList<Vertex> overlaps = new ArrayList<Vertex>(3);
+ int count = getOutlineNumber();
+ boolean firstpass = true;
+ do {
+ for (int cc = 0; cc < count; cc++) {
+ final Outline outline = getOutline(cc);
+ int vertexCount = outline.getVertexCount();
+ for(int i=0; i < outline.getVertexCount(); i++) {
+ final Vertex currentVertex = outline.getVertex(i);
+ if ( !currentVertex.isOnCurve()) {
+ final Vertex nextV = outline.getVertex((i+1)%vertexCount);
+ final Vertex prevV = outline.getVertex((i+vertexCount-1)%vertexCount);
+ Vertex overlap =null;
+
+ //check for overlap even if already set for subdivision
+ //ensuring both trianglur overlaps get divided
+ //for pref. only check in first pass
+ //second pass to clear the overlaps arrray(reduces precision errors)
+ if(firstpass) {
+ overlap = checkTriOverlaps(prevV, currentVertex, nextV);
+ }
+ if(overlaps.contains(currentVertex) || overlap != null) {
+ overlaps.remove(currentVertex);
+
+ subdivideTriangle(outline, prevV, currentVertex, nextV, i);
+ i+=3;
+ vertexCount+=2;
+
+ if(overlap != null && !overlap.isOnCurve()) {
+ if(!overlaps.contains(overlap))
+ overlaps.add(overlap);
+ }
+ }
+ }
+ }
+ }
+ firstpass = false;
+ }while(!overlaps.isEmpty());
+ }
+
+ private Vertex checkTriOverlaps(Vertex a, Vertex b, Vertex c) {
+ int count = getOutlineNumber();
+ for (int cc = 0; cc < count; cc++) {
+ final Outline outline = getOutline(cc);
+ int vertexCount = outline.getVertexCount();
+ for(int i=0; i < vertexCount; i++) {
+ final Vertex current = outline.getVertex(i);
+ if(current.isOnCurve() || current == a || current == b || current == c) {
+ continue;
+ }
+ final Vertex nextV = outline.getVertex((i+1)%vertexCount);
+ final Vertex prevV = outline.getVertex((i+vertexCount-1)%vertexCount);
+
+ //skip neighboring triangles
+ if(prevV == c || nextV == a) {
+ continue;
+ }
+
+ if(VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), current.getCoord())
+ || VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), nextV.getCoord())
+ || VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), prevV.getCoord())) {
+
+ return current;
+ }
+ if(VectorUtil.tri2SegIntersection(a, b, c, prevV, current)
+ || VectorUtil.tri2SegIntersection(a, b, c, current, nextV)
+ || VectorUtil.tri2SegIntersection(a, b, c, prevV, nextV)) {
+ return current;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void transformOutlines2Quadratic() {
+ int count = getOutlineNumber();
+ for (int cc = 0; cc < count; cc++) {
+ final Outline outline = getOutline(cc);
+ int vertexCount = outline.getVertexCount();
+
+ for(int i=0; i < vertexCount; i++) {
+ final Vertex currentVertex = outline.getVertex(i);
+ final Vertex nextVertex = outline.getVertex((i+1)%vertexCount);
+ if ( !currentVertex.isOnCurve() && !nextVertex.isOnCurve() ) {
+ final float[] newCoords = VectorUtil.mid(currentVertex.getCoord(),
+ nextVertex.getCoord());
+ final Vertex v = vertexFactory.create(newCoords, 0, 3, true);
+ i++;
+ vertexCount++;
+ outline.addVertex(i, v);
+ }
+ }
+ if(vertexCount <= 0) {
+ outlines.remove(outline);
+ cc--;
+ count--;
+ continue;
+ }
+
+ if( vertexCount > 0 ) {
+ if(VectorUtil.checkEquality(outline.getVertex(0).getCoord(),
+ outline.getLastVertex().getCoord())) {
+ outline.removeVertex(vertexCount-1);
+ }
+ }
+ }
+ outlineState = VerticesState.QUADRATIC_NURBS;
+ }
+
+ private void generateVertexIds() {
+ int maxVertexId = 0;
+ for(int i=0; i<outlines.size(); i++) {
+ final ArrayList<Vertex> vertices = outlines.get(i).getVertices();
+ for(int pos=0; pos<vertices.size(); pos++) {
+ Vertex vert = vertices.get(pos);
+ vert.setId(maxVertexId);
+ maxVertexId++;
+ }
+ }
+ }
+
+ /** @return the list of concatenated vertices associated with all
+ * {@code Outline}s of this object
+ */
+ public ArrayList<Vertex> getVertices() {
+ ArrayList<Vertex> vertices = new ArrayList<Vertex>();
+ for(int i=0; i<outlines.size(); i++) {
+ vertices.addAll(outlines.get(i).getVertices());
+ }
+ return vertices;
+ }
+
+ /**
+ * Triangulate the {@link OutlineShape} generating a list of triangles
+ * @return an arraylist of triangles representing the filled region
+ * which is produced by the combination of the outlines
+ */
+ public ArrayList<Triangle> triangulate() {
+ if(outlines.size() == 0){
+ return null;
+ }
+ sortOutlines();
+ generateVertexIds();
+
+ Triangulator triangulator2d = Triangulation.create();
+ for(int index = 0; index<outlines.size(); index++) {
+ triangulator2d.addCurve(outlines.get(index));
+ }
+
+ ArrayList<Triangle> triangles = triangulator2d.generate();
+ triangulator2d.reset();
+
+ return triangles;
+ }
+
+ /** Sort the outlines from large
+ * to small depending on the AABox
+ */
+ private void sortOutlines() {
+ Collections.sort(outlines);
+ Collections.reverse(outlines);
+ }
+
+ /** Compare two outline shapes with Bounding Box area
+ * as criteria.
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public final int compareTo(OutlineShape outline) {
+ float size = getBounds().getSize();
+ float newSize = outline.getBounds().getSize();
+ if(size < newSize){
+ return -1;
+ }
+ else if(size > newSize){
+ return 1;
+ }
+ return 0;
+ }
+
+ private final void validateBoundingBox() {
+ dirtyBits &= ~DIRTY_BOUNDS;
+ bbox.reset();
+ for (int i=0; i<outlines.size(); i++) {
+ bbox.resize(outlines.get(i).getBounds());
+ }
+ }
+
+ public final AABBox getBounds() {
+ if( 0 == ( dirtyBits & DIRTY_BOUNDS ) ) {
+ validateBoundingBox();
+ }
+ return bbox;
+ }
+
+ /**
+ * @param obj the Object to compare this OutlineShape with
+ * @return true if {@code obj} is an OutlineShape, not null,
+ * same outlineState, equal bounds and equal outlines in the same order
+ */
+ public boolean equals(Object obj) {
+ if( obj == this) {
+ return true;
+ }
+ if( null == obj || !(obj instanceof OutlineShape) ) {
+ return false;
+ }
+ final OutlineShape o = (OutlineShape) obj;
+ if(getOutlineState() != o.getOutlineState()) {
+ return false;
+ }
+ if(getOutlineNumber() != o.getOutlineNumber()) {
+ return false;
+ }
+ if( !getBounds().equals( o.getBounds() ) ) {
+ return false;
+ }
+ for (int i=getOutlineNumber()-1; i>=0; i--) {
+ if( ! getOutline(i).equals( o.getOutline(i) ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @return deep clone of this OutlineShape w/o Region
+ */
+ public OutlineShape clone() {
+ OutlineShape o;
+ try {
+ o = (OutlineShape) super.clone();
+ } catch (CloneNotSupportedException e) { throw new InternalError(); }
+ o.bbox = bbox.clone();
+ o.outlines = new ArrayList<Outline>(outlines.size());
+ for(int i=0; i<outlines.size(); i++) {
+ o.outlines.add(outlines.get(i).clone());
+ }
+ return o;
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index 6503f27..e2b3fe5 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -74,6 +74,12 @@ public interface Font {
* Glyph for font
*/
public interface Glyph {
+ // reserved special glyph IDs
+ // http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08#ba57949e
+ public static final int ID_UNKNOWN = 0;
+ public static final int ID_CR = 2;
+ public static final int ID_SPACE = 3;
+
public Font getFont();
public char getSymbol();
public AABBox getBBox(float pixelSize);
@@ -91,6 +97,7 @@ public interface Font {
public StringBuilder getAllNames(StringBuilder string, String separator);
+ public float getAdvanceWidth(int i, float pixelSize);
public Metrics getMetrics();
public Glyph getGlyph(char symbol);
public int getNumGlyphs();
diff --git a/src/jogl/classes/com/jogamp/graph/math/Quaternion.java b/src/jogl/classes/com/jogamp/graph/math/Quaternion.java
index 38638dc..adaf073 100755
--- a/src/jogl/classes/com/jogamp/graph/math/Quaternion.java
+++ b/src/jogl/classes/com/jogamp/graph/math/Quaternion.java
@@ -1,382 +1,382 @@
-/**
- * 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.graph.math;
-
-import jogamp.graph.math.MathFloat;
-
-public class Quaternion {
- protected float x,y,z,w;
-
- public Quaternion(){
-
- }
-
- public Quaternion(float x, float y, float z, float w) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
-
- /** Constructor to create a rotation based quaternion from two vectors
- * @param vector1
- * @param vector2
- */
- public Quaternion(float[] vector1, float[] vector2)
- {
- float theta = (float)MathFloat.acos(dot(vector1, vector2));
- float[] cross = cross(vector1,vector2);
- cross = normalizeVec(cross);
-
- this.x = (float)MathFloat.sin(theta/2)*cross[0];
- this.y = (float)MathFloat.sin(theta/2)*cross[1];
- this.z = (float)MathFloat.sin(theta/2)*cross[2];
- this.w = (float)MathFloat.cos(theta/2);
- this.normalize();
- }
-
- /** Transform the rotational quaternion to axis based rotation angles
- * @return new float[4] with ,theta,Rx,Ry,Rz
- */
- public float[] toAxis()
- {
- float[] vec = new float[4];
- float scale = (float)MathFloat.sqrt(x * x + y * y + z * z);
- vec[0] =(float) MathFloat.acos(w) * 2.0f;
- vec[1] = x / scale;
- vec[2] = y / scale;
- vec[3] = z / scale;
- return vec;
- }
-
- /** Normalize a vector
- * @param vector input vector
- * @return normalized vector
- */
- private float[] normalizeVec(float[] vector)
- {
- float[] newVector = new float[3];
-
- float d = MathFloat.sqrt(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2]);
- if(d> 0.0f)
- {
- newVector[0] = vector[0]/d;
- newVector[1] = vector[1]/d;
- newVector[2] = vector[2]/d;
- }
- return newVector;
- }
- /** compute the dot product of two points
- * @param vec1 vector 1
- * @param vec2 vector 2
- * @return the dot product as float
- */
- private float dot(float[] vec1, float[] vec2)
- {
- return (vec1[0]*vec2[0] + vec1[1]*vec2[1] + vec1[2]*vec2[2]);
- }
- /** cross product vec1 x vec2
- * @param vec1 vector 1
- * @param vec2 vecttor 2
- * @return the resulting vector
- */
- private float[] cross(float[] vec1, float[] vec2)
- {
- float[] out = new float[3];
-
- out[0] = vec2[2]*vec1[1] - vec2[1]*vec1[2];
- out[1] = vec2[0]*vec1[2] - vec2[2]*vec1[0];
- out[2] = vec2[1]*vec1[0] - vec2[0]*vec1[1];
-
- return out;
- }
- public float getW() {
- return w;
- }
- public void setW(float w) {
- this.w = w;
- }
- public float getX() {
- return x;
- }
- public void setX(float x) {
- this.x = x;
- }
- public float getY() {
- return y;
- }
- public void setY(float y) {
- this.y = y;
- }
- public float getZ() {
- return z;
- }
- public void setZ(float z) {
- this.z = z;
- }
-
- /** Add a quaternion
- * @param q quaternion
- */
- public void add(Quaternion q)
- {
- x+=q.x;
- y+=q.y;
- z+=q.z;
- }
-
- /** Subtract a quaternion
- * @param q quaternion
- */
- public void subtract(Quaternion q)
- {
- x-=q.x;
- y-=q.y;
- z-=q.z;
- }
-
- /** Divide a quaternion by a constant
- * @param n a float to divide by
- */
- public void divide(float n)
- {
- x/=n;
- y/=n;
- z/=n;
- }
-
- /** Multiply this quaternion by
- * the param quaternion
- * @param q a quaternion to multiply with
- */
- public void mult(Quaternion q)
- {
- float w1 = w*q.w - (x*q.x + y*q.y + z*q.z);
-
- float x1 = w*q.z + q.w*z + y*q.z - z*q.y;
- float y1 = w*q.x + q.w*x + z*q.x - x*q.z;
- float z1 = w*q.y + q.w*y + x*q.y - y*q.x;
-
- w = w1;
- x = x1;
- y = y1;
- z = z1;
- }
-
- /** Multiply a quaternion by a constant
- * @param n a float constant
- */
- public void mult(float n)
- {
- x*=n;
- y*=n;
- z*=n;
- }
-
- /** Normalize a quaternion required if
- * to be used as a rotational quaternion
- */
- public void normalize()
- {
- float norme = (float)MathFloat.sqrt(w*w + x*x + y*y + z*z);
- if (norme == 0.0f)
- {
- w = 1.0f;
- x = y = z = 0.0f;
- }
- else
- {
- float recip = 1.0f/norme;
-
- w *= recip;
- x *= recip;
- y *= recip;
- z *= recip;
- }
- }
-
- /** Invert the quaternion If rotational,
- * will produce a the inverse rotation
- */
- public void inverse()
- {
- float norm = w*w + x*x + y*y + z*z;
-
- float recip = 1.0f/norm;
-
- w *= recip;
- x = -1*x*recip;
- y = -1*y*recip;
- z = -1*z*recip;
- }
-
- /** Transform this quaternion to a
- * 4x4 column matrix representing the rotation
- * @return new float[16] column matrix 4x4
- */
- public float[] toMatrix()
- {
- float[] matrix = new float[16];
- matrix[0] = 1.0f - 2*y*y - 2*z*z;
- matrix[1] = 2*x*y + 2*w*z;
- matrix[2] = 2*x*z - 2*w*y;
- matrix[3] = 0;
-
- matrix[4] = 2*x*y - 2*w*z;
- matrix[5] = 1.0f - 2*x*x - 2*z*z;
- matrix[6] = 2*y*z + 2*w*x;
- matrix[7] = 0;
-
- matrix[8] = 2*x*z + 2*w*y;
- matrix[9] = 2*y*z - 2*w*x;
- matrix[10] = 1.0f - 2*x*x - 2*y*y;
- matrix[11] = 0;
-
- matrix[12] = 0;
- matrix[13] = 0;
- matrix[14] = 0;
- matrix[15] = 1;
- return matrix;
- }
-
- /** Set this quaternion from a Sphereical interpolation
- * of two param quaternion, used mostly for rotational animation
- * @param a initial quaternion
- * @param b target quaternion
- * @param t float between 0 and 1 representing interp.
- */
- public void slerp(Quaternion a,Quaternion b, float t)
- {
- float omega, cosom, sinom, sclp, sclq;
- cosom = a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w;
- if ((1.0f+cosom) > MathFloat.E) {
- if ((1.0f-cosom) > MathFloat.E) {
- omega = (float)MathFloat.acos(cosom);
- sinom = (float)MathFloat.sin(omega);
- sclp = (float)MathFloat.sin((1.0f-t)*omega) / sinom;
- sclq = (float)MathFloat.sin(t*omega) / sinom;
- }
- else {
- sclp = 1.0f - t;
- sclq = t;
- }
- x = sclp*a.x + sclq*b.x;
- y = sclp*a.y + sclq*b.y;
- z = sclp*a.z + sclq*b.z;
- w = sclp*a.w + sclq*b.w;
- }
- else {
- x =-a.y;
- y = a.x;
- z =-a.w;
- w = a.z;
- sclp = MathFloat.sin((1.0f-t) * MathFloat.PI * 0.5f);
- sclq = MathFloat.sin(t * MathFloat.PI * 0.5f);
- x = sclp*a.x + sclq*b.x;
- y = sclp*a.y + sclq*b.y;
- z = sclp*a.z + sclq*b.z;
- }
- }
-
- /** Check if this quaternion is empty, ie (0,0,0,1)
- * @return true if empty, false otherwise
- */
- public boolean isEmpty()
- {
- if (w==1 && x==0 && y==0 && z==0)
- return true;
- return false;
- }
-
- /** Check if this quaternion represents an identity
- * matrix, for rotation.
- * @return true if it is an identity rep., false otherwise
- */
- public boolean isIdentity()
- {
- if (w==0 && x==0 && y==0 && z==0)
- return true;
- return false;
- }
-
- /** compute the quaternion from a 3x3 column matrix
- * @param m 3x3 column matrix
- */
- public void setFromMatrix(float[] m) {
- float T= m[0] + m[4] + m[8] + 1;
- if (T>0){
- float S = 0.5f / (float)MathFloat.sqrt(T);
- w = 0.25f / S;
- x = ( m[5] - m[7]) * S;
- y = ( m[6] - m[2]) * S;
- z = ( m[1] - m[3] ) * S;
- }
- else{
- if ((m[0] > m[4])&(m[0] > m[8])) {
- float S = MathFloat.sqrt( 1.0f + m[0] - m[4] - m[8] ) * 2f; // S=4*qx
- w = (m[7] - m[5]) / S;
- x = 0.25f * S;
- y = (m[3] + m[1]) / S;
- z = (m[6] + m[2]) / S;
- }
- else if (m[4] > m[8]) {
- float S = MathFloat.sqrt( 1.0f + m[4] - m[0] - m[8] ) * 2f; // S=4*qy
- w = (m[6] - m[2]) / S;
- x = (m[3] + m[1]) / S;
- y = 0.25f * S;
- z = (m[7] + m[5]) / S;
- }
- else {
- float S = MathFloat.sqrt( 1.0f + m[8] - m[0] - m[4] ) * 2f; // S=4*qz
- w = (m[3] - m[1]) / S;
- x = (m[6] + m[2]) / S;
- y = (m[7] + m[5]) / S;
- z = 0.25f * S;
- }
- }
- }
-
- /** Check if the the 3x3 matrix (param) is in fact
- * an affine rotational matrix
- * @param m 3x3 column matrix
- * @return true if representing a rotational matrix, false otherwise
- */
- public boolean isRotationMatrix(float[] m) {
- double epsilon = 0.01; // margin to allow for rounding errors
- if (MathFloat.abs(m[0]*m[3] + m[3]*m[4] + m[6]*m[7]) > epsilon) return false;
- if (MathFloat.abs(m[0]*m[2] + m[3]*m[5] + m[6]*m[8]) > epsilon) return false;
- if (MathFloat.abs(m[1]*m[2] + m[4]*m[5] + m[7]*m[8]) > epsilon) return false;
- if (MathFloat.abs(m[0]*m[0] + m[3]*m[3] + m[6]*m[6] - 1) > epsilon) return false;
- if (MathFloat.abs(m[1]*m[1] + m[4]*m[4] + m[7]*m[7] - 1) > epsilon) return false;
- if (MathFloat.abs(m[2]*m[2] + m[5]*m[5] + m[8]*m[8] - 1) > epsilon) return false;
- return (MathFloat.abs(determinant(m)-1) < epsilon);
- }
- private float determinant(float[] m) {
- return m[0]*m[4]*m[8] + m[3]*m[7]*m[2] + m[6]*m[1]*m[5] - m[0]*m[7]*m[5] - m[3]*m[1]*m[8] - m[6]*m[4]*m[2];
- }
-}
+/**
+ * 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.graph.math;
+
+import jogamp.graph.math.MathFloat;
+
+public class Quaternion {
+ protected float x,y,z,w;
+
+ public Quaternion(){
+
+ }
+
+ public Quaternion(float x, float y, float z, float w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+
+ /** Constructor to create a rotation based quaternion from two vectors
+ * @param vector1
+ * @param vector2
+ */
+ public Quaternion(float[] vector1, float[] vector2)
+ {
+ float theta = (float)MathFloat.acos(dot(vector1, vector2));
+ float[] cross = cross(vector1,vector2);
+ cross = normalizeVec(cross);
+
+ this.x = (float)MathFloat.sin(theta/2)*cross[0];
+ this.y = (float)MathFloat.sin(theta/2)*cross[1];
+ this.z = (float)MathFloat.sin(theta/2)*cross[2];
+ this.w = (float)MathFloat.cos(theta/2);
+ this.normalize();
+ }
+
+ /** Transform the rotational quaternion to axis based rotation angles
+ * @return new float[4] with ,theta,Rx,Ry,Rz
+ */
+ public float[] toAxis()
+ {
+ float[] vec = new float[4];
+ float scale = (float)MathFloat.sqrt(x * x + y * y + z * z);
+ vec[0] =(float) MathFloat.acos(w) * 2.0f;
+ vec[1] = x / scale;
+ vec[2] = y / scale;
+ vec[3] = z / scale;
+ return vec;
+ }
+
+ /** Normalize a vector
+ * @param vector input vector
+ * @return normalized vector
+ */
+ private float[] normalizeVec(float[] vector)
+ {
+ float[] newVector = new float[3];
+
+ float d = MathFloat.sqrt(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2]);
+ if(d> 0.0f)
+ {
+ newVector[0] = vector[0]/d;
+ newVector[1] = vector[1]/d;
+ newVector[2] = vector[2]/d;
+ }
+ return newVector;
+ }
+ /** compute the dot product of two points
+ * @param vec1 vector 1
+ * @param vec2 vector 2
+ * @return the dot product as float
+ */
+ private float dot(float[] vec1, float[] vec2)
+ {
+ return (vec1[0]*vec2[0] + vec1[1]*vec2[1] + vec1[2]*vec2[2]);
+ }
+ /** cross product vec1 x vec2
+ * @param vec1 vector 1
+ * @param vec2 vecttor 2
+ * @return the resulting vector
+ */
+ private float[] cross(float[] vec1, float[] vec2)
+ {
+ float[] out = new float[3];
+
+ out[0] = vec2[2]*vec1[1] - vec2[1]*vec1[2];
+ out[1] = vec2[0]*vec1[2] - vec2[2]*vec1[0];
+ out[2] = vec2[1]*vec1[0] - vec2[0]*vec1[1];
+
+ return out;
+ }
+ public float getW() {
+ return w;
+ }
+ public void setW(float w) {
+ this.w = w;
+ }
+ public float getX() {
+ return x;
+ }
+ public void setX(float x) {
+ this.x = x;
+ }
+ public float getY() {
+ return y;
+ }
+ public void setY(float y) {
+ this.y = y;
+ }
+ public float getZ() {
+ return z;
+ }
+ public void setZ(float z) {
+ this.z = z;
+ }
+
+ /** Add a quaternion
+ * @param q quaternion
+ */
+ public void add(Quaternion q)
+ {
+ x+=q.x;
+ y+=q.y;
+ z+=q.z;
+ }
+
+ /** Subtract a quaternion
+ * @param q quaternion
+ */
+ public void subtract(Quaternion q)
+ {
+ x-=q.x;
+ y-=q.y;
+ z-=q.z;
+ }
+
+ /** Divide a quaternion by a constant
+ * @param n a float to divide by
+ */
+ public void divide(float n)
+ {
+ x/=n;
+ y/=n;
+ z/=n;
+ }
+
+ /** Multiply this quaternion by
+ * the param quaternion
+ * @param q a quaternion to multiply with
+ */
+ public void mult(Quaternion q)
+ {
+ float w1 = w*q.w - (x*q.x + y*q.y + z*q.z);
+
+ float x1 = w*q.z + q.w*z + y*q.z - z*q.y;
+ float y1 = w*q.x + q.w*x + z*q.x - x*q.z;
+ float z1 = w*q.y + q.w*y + x*q.y - y*q.x;
+
+ w = w1;
+ x = x1;
+ y = y1;
+ z = z1;
+ }
+
+ /** Multiply a quaternion by a constant
+ * @param n a float constant
+ */
+ public void mult(float n)
+ {
+ x*=n;
+ y*=n;
+ z*=n;
+ }
+
+ /** Normalize a quaternion required if
+ * to be used as a rotational quaternion
+ */
+ public void normalize()
+ {
+ float norme = (float)MathFloat.sqrt(w*w + x*x + y*y + z*z);
+ if (norme == 0.0f)
+ {
+ w = 1.0f;
+ x = y = z = 0.0f;
+ }
+ else
+ {
+ float recip = 1.0f/norme;
+
+ w *= recip;
+ x *= recip;
+ y *= recip;
+ z *= recip;
+ }
+ }
+
+ /** Invert the quaternion If rotational,
+ * will produce a the inverse rotation
+ */
+ public void inverse()
+ {
+ float norm = w*w + x*x + y*y + z*z;
+
+ float recip = 1.0f/norm;
+
+ w *= recip;
+ x = -1*x*recip;
+ y = -1*y*recip;
+ z = -1*z*recip;
+ }
+
+ /** Transform this quaternion to a
+ * 4x4 column matrix representing the rotation
+ * @return new float[16] column matrix 4x4
+ */
+ public float[] toMatrix()
+ {
+ float[] matrix = new float[16];
+ matrix[0] = 1.0f - 2*y*y - 2*z*z;
+ matrix[1] = 2*x*y + 2*w*z;
+ matrix[2] = 2*x*z - 2*w*y;
+ matrix[3] = 0;
+
+ matrix[4] = 2*x*y - 2*w*z;
+ matrix[5] = 1.0f - 2*x*x - 2*z*z;
+ matrix[6] = 2*y*z + 2*w*x;
+ matrix[7] = 0;
+
+ matrix[8] = 2*x*z + 2*w*y;
+ matrix[9] = 2*y*z - 2*w*x;
+ matrix[10] = 1.0f - 2*x*x - 2*y*y;
+ matrix[11] = 0;
+
+ matrix[12] = 0;
+ matrix[13] = 0;
+ matrix[14] = 0;
+ matrix[15] = 1;
+ return matrix;
+ }
+
+ /** Set this quaternion from a Sphereical interpolation
+ * of two param quaternion, used mostly for rotational animation
+ * @param a initial quaternion
+ * @param b target quaternion
+ * @param t float between 0 and 1 representing interp.
+ */
+ public void slerp(Quaternion a,Quaternion b, float t)
+ {
+ float omega, cosom, sinom, sclp, sclq;
+ cosom = a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w;
+ if ((1.0f+cosom) > MathFloat.E) {
+ if ((1.0f-cosom) > MathFloat.E) {
+ omega = (float)MathFloat.acos(cosom);
+ sinom = (float)MathFloat.sin(omega);
+ sclp = (float)MathFloat.sin((1.0f-t)*omega) / sinom;
+ sclq = (float)MathFloat.sin(t*omega) / sinom;
+ }
+ else {
+ sclp = 1.0f - t;
+ sclq = t;
+ }
+ x = sclp*a.x + sclq*b.x;
+ y = sclp*a.y + sclq*b.y;
+ z = sclp*a.z + sclq*b.z;
+ w = sclp*a.w + sclq*b.w;
+ }
+ else {
+ x =-a.y;
+ y = a.x;
+ z =-a.w;
+ w = a.z;
+ sclp = MathFloat.sin((1.0f-t) * MathFloat.PI * 0.5f);
+ sclq = MathFloat.sin(t * MathFloat.PI * 0.5f);
+ x = sclp*a.x + sclq*b.x;
+ y = sclp*a.y + sclq*b.y;
+ z = sclp*a.z + sclq*b.z;
+ }
+ }
+
+ /** Check if this quaternion is empty, ie (0,0,0,1)
+ * @return true if empty, false otherwise
+ */
+ public boolean isEmpty()
+ {
+ if (w==1 && x==0 && y==0 && z==0)
+ return true;
+ return false;
+ }
+
+ /** Check if this quaternion represents an identity
+ * matrix, for rotation.
+ * @return true if it is an identity rep., false otherwise
+ */
+ public boolean isIdentity()
+ {
+ if (w==0 && x==0 && y==0 && z==0)
+ return true;
+ return false;
+ }
+
+ /** compute the quaternion from a 3x3 column matrix
+ * @param m 3x3 column matrix
+ */
+ public void setFromMatrix(float[] m) {
+ float T= m[0] + m[4] + m[8] + 1;
+ if (T>0){
+ float S = 0.5f / (float)MathFloat.sqrt(T);
+ w = 0.25f / S;
+ x = ( m[5] - m[7]) * S;
+ y = ( m[6] - m[2]) * S;
+ z = ( m[1] - m[3] ) * S;
+ }
+ else{
+ if ((m[0] > m[4])&(m[0] > m[8])) {
+ float S = MathFloat.sqrt( 1.0f + m[0] - m[4] - m[8] ) * 2f; // S=4*qx
+ w = (m[7] - m[5]) / S;
+ x = 0.25f * S;
+ y = (m[3] + m[1]) / S;
+ z = (m[6] + m[2]) / S;
+ }
+ else if (m[4] > m[8]) {
+ float S = MathFloat.sqrt( 1.0f + m[4] - m[0] - m[8] ) * 2f; // S=4*qy
+ w = (m[6] - m[2]) / S;
+ x = (m[3] + m[1]) / S;
+ y = 0.25f * S;
+ z = (m[7] + m[5]) / S;
+ }
+ else {
+ float S = MathFloat.sqrt( 1.0f + m[8] - m[0] - m[4] ) * 2f; // S=4*qz
+ w = (m[3] - m[1]) / S;
+ x = (m[6] + m[2]) / S;
+ y = (m[7] + m[5]) / S;
+ z = 0.25f * S;
+ }
+ }
+ }
+
+ /** Check if the the 3x3 matrix (param) is in fact
+ * an affine rotational matrix
+ * @param m 3x3 column matrix
+ * @return true if representing a rotational matrix, false otherwise
+ */
+ public boolean isRotationMatrix(float[] m) {
+ double epsilon = 0.01; // margin to allow for rounding errors
+ if (MathFloat.abs(m[0]*m[3] + m[3]*m[4] + m[6]*m[7]) > epsilon) return false;
+ if (MathFloat.abs(m[0]*m[2] + m[3]*m[5] + m[6]*m[8]) > epsilon) return false;
+ if (MathFloat.abs(m[1]*m[2] + m[4]*m[5] + m[7]*m[8]) > epsilon) return false;
+ if (MathFloat.abs(m[0]*m[0] + m[3]*m[3] + m[6]*m[6] - 1) > epsilon) return false;
+ if (MathFloat.abs(m[1]*m[1] + m[4]*m[4] + m[7]*m[7] - 1) > epsilon) return false;
+ if (MathFloat.abs(m[2]*m[2] + m[5]*m[5] + m[8]*m[8] - 1) > epsilon) return false;
+ return (MathFloat.abs(determinant(m)-1) < epsilon);
+ }
+ private float determinant(float[] m) {
+ return m[0]*m[4]*m[8] + m[3]*m[7]*m[2] + m[6]*m[1]*m[5] - m[0]*m[7]*m[5] - m[3]*m[1]*m[8] - m[6]*m[4]*m[2];
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java b/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java
index b1f2023..d51afcb 100755
--- a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java
@@ -1,433 +1,433 @@
-/**
- * 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.graph.math;
-
-import java.util.ArrayList;
-
-import jogamp.graph.math.MathFloat;
-
-import com.jogamp.graph.geom.Vertex;
-
-public class VectorUtil {
-
- public enum Winding {
- CW(-1), CCW(1);
-
- public final int dir;
-
- Winding(int dir) {
- this.dir = dir;
- }
- }
-
- public static final int COLLINEAR = 0;
-
- /** compute the dot product of two points
- * @param vec1 vector 1
- * @param vec2 vector 2
- * @return the dot product as float
- */
- public static float dot(float[] vec1, float[] vec2)
- {
- return (vec1[0]*vec2[0] + vec1[1]*vec2[1] + vec1[2]*vec2[2]);
- }
- /** Normalize a vector
- * @param vector input vector
- * @return normalized vector
- */
- public static float[] normalize(float[] vector)
- {
- float[] newVector = new float[3];
-
- float d = MathFloat.sqrt(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2]);
- if(d> 0.0f)
- {
- newVector[0] = vector[0]/d;
- newVector[1] = vector[1]/d;
- newVector[2] = vector[2]/d;
- }
- return newVector;
- }
-
- /** Scales a vector by param
- * @param vector input vector
- * @param scale constant to scale by
- * @return scaled vector
- */
- public static float[] scale(float[] vector, float scale)
- {
- float[] newVector = new float[3];
-
- newVector[0] = vector[0]*scale;
- newVector[1] = vector[1]*scale;
- newVector[2] = vector[2]*scale;
- return newVector;
- }
-
- /** Adds to vectors
- * @param v1 vector 1
- * @param v2 vector 2
- * @return v1 + v2
- */
- public static float[] vectorAdd(float[] v1, float[] v2)
- {
- float[] newVector = new float[3];
-
- newVector[0] = v1[0] + v2[0];
- newVector[1] = v1[1] + v2[1];
- newVector[2] = v1[2] + v2[2];
- return newVector;
- }
-
- /** cross product vec1 x vec2
- * @param vec1 vector 1
- * @param vec2 vecttor 2
- * @return the resulting vector
- */
- public static float[] cross(float[] vec1, float[] vec2)
- {
- float[] out = new float[3];
-
- out[0] = vec2[2]*vec1[1] - vec2[1]*vec1[2];
- out[1] = vec2[0]*vec1[2] - vec2[2]*vec1[0];
- out[2] = vec2[1]*vec1[0] - vec2[0]*vec1[1];
-
- return out;
- }
-
- /** Column Matrix Vector multiplication
- * @param colMatrix column matrix (4x4)
- * @param vec vector(x,y,z)
- * @return result new float[3]
- */
- public static float[] colMatrixVectorMult(float[] colMatrix, float[] vec)
- {
- float[] out = new float[3];
-
- out[0] = vec[0]*colMatrix[0] + vec[1]*colMatrix[4] + vec[2]*colMatrix[8] + colMatrix[12];
- out[1] = vec[0]*colMatrix[1] + vec[1]*colMatrix[5] + vec[2]*colMatrix[9] + colMatrix[13];
- out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14];
-
- return out;
- }
-
- /** Matrix Vector multiplication
- * @param rawMatrix column matrix (4x4)
- * @param vec vector(x,y,z)
- * @return result new float[3]
- */
- public static float[] rowMatrixVectorMult(float[] rawMatrix, float[] vec)
- {
- float[] out = new float[3];
-
- out[0] = vec[0]*rawMatrix[0] + vec[1]*rawMatrix[1] + vec[2]*rawMatrix[2] + rawMatrix[3];
- out[1] = vec[0]*rawMatrix[4] + vec[1]*rawMatrix[5] + vec[2]*rawMatrix[6] + rawMatrix[7];
- out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11];
-
- return out;
- }
-
- /** Calculate the midpoint of two values
- * @param p1 first value
- * @param p2 second vale
- * @return midpoint
- */
- public static float mid(float p1, float p2)
- {
- return (p1+p2)/2.0f;
- }
- /** Calculate the midpoint of two points
- * @param p1 first point
- * @param p2 second point
- * @return midpoint
- */
- public static float[] mid(float[] p1, float[] p2)
- {
- float[] midPoint = new float[3];
- midPoint[0] = (p1[0] + p2[0])*0.5f;
- midPoint[1] = (p1[1] + p2[1])*0.5f;
- midPoint[2] = (p1[2] + p2[2])*0.5f;
-
- return midPoint;
- }
- /** Compute the norm of a vector
- * @param vec vector
- * @return vorm
- */
- public static float norm(float[] vec)
- {
- return MathFloat.sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
- }
- /** Compute distance between 2 points
- * @param p0 a ref point on the line
- * @param vec vector representing the direction of the line
- * @param point the point to compute the relative distance of
- * @return distance float
- */
- public static float computeLength(float[] p0, float[] point)
- {
- float[] w = new float[]{point[0]-p0[0],point[1]-p0[1],point[2]-p0[2]};
-
- float distance = MathFloat.sqrt(w[0]*w[0] + w[1]*w[1] + w[2]*w[2]);
-
- return distance;
- }
-
- /**Check equality of 2 vec3 vectors
- * @param v1 vertex 1
- * @param v2 vertex 2
- * @return
- */
- public static boolean checkEquality(float[] v1, float[] v2)
- {
- if(Float.compare(v1[0], v2[0]) == 0 &&
- Float.compare(v1[1], v2[1]) == 0 &&
- Float.compare(v1[2], v2[2]) == 0 )
- return true;
- return false;
- }
-
- /**Check equality of 2 vec2 vectors
- * @param v1 vertex 1
- * @param v2 vertex 2
- * @return
- */
- public static boolean checkEqualityVec2(float[] v1, float[] v2)
- {
- if(Float.compare(v1[0], v2[0]) == 0 &&
- Float.compare(v1[1], v2[1]) == 0)
- return true;
- return false;
- }
-
- /** Compute the determinant of 3 vectors
- * @param a vector 1
- * @param b vector 2
- * @param c vector 3
- * @return the determinant value
- */
- public static float computeDeterminant(float[] a, float[] b, float[] c)
- {
- float area = a[0]*b[1]*c[2] + a[1]*b[2]*c[0] + a[2]*b[0]*c[1] - a[0]*b[2]*c[1] - a[1]*b[0]*c[2] - a[2]*b[1]*c[0];
- return area;
- }
-
- /** Check if three vertices are colliniear
- * @param v1 vertex 1
- * @param v2 vertex 2
- * @param v3 vertex 3
- * @return true if collinear, false otherwise
- */
- public static boolean checkCollinear(float[] v1, float[] v2, float[] v3)
- {
- return (computeDeterminant(v1, v2, v3) == VectorUtil.COLLINEAR);
- }
-
- /** Compute Vector
- * @param v1 vertex 1
- * @param v2 vertex2 2
- * @return Vector V1V2
- */
- public static float[] computeVector(float[] v1, float[] v2)
- {
- float[] vector = new float[3];
- vector[0] = v2[0] - v1[0];
- vector[1] = v2[1] - v1[1];
- vector[2] = v2[2] - v1[2];
- return vector;
- }
-
- /** Check if vertices in triangle circumcircle
- * @param a triangle vertex 1
- * @param b triangle vertex 2
- * @param c triangle vertex 3
- * @param d vertex in question
- * @return true if the vertex d is inside the circle defined by the
- * vertices a, b, c. from paper by Guibas and Stolfi (1985).
- */
- public static boolean inCircle(Vertex a, Vertex b, Vertex c, Vertex d){
- return (a.getX() * a.getX() + a.getY() * a.getY()) * triArea(b, c, d) -
- (b.getX() * b.getX() + b.getY() * b.getY()) * triArea(a, c, d) +
- (c.getX() * c.getX() + c.getY() * c.getY()) * triArea(a, b, d) -
- (d.getX() * d.getX() + d.getY() * d.getY()) * triArea(a, b, c) > 0;
- }
-
- /** Computes oriented area of a triangle
- * @param a first vertex
- * @param b second vertex
- * @param c third vertex
- * @return compute twice the area of the oriented triangle (a,b,c), the area
- * is positive if the triangle is oriented counterclockwise.
- */
- public static float triArea(Vertex a, Vertex b, Vertex c){
- return (b.getX() - a.getX()) * (c.getY() - a.getY()) - (b.getY() - a.getY())*(c.getX() - a.getX());
- }
-
- /** Check if a vertex is in triangle using
- * barycentric coordinates computation.
- * @param a first triangle vertex
- * @param b second triangle vertex
- * @param c third triangle vertex
- * @param p the vertex in question
- * @return true if p is in triangle (a, b, c), false otherwise.
- */
- public static boolean vertexInTriangle(float[] a, float[] b, float[] c, float[] p){
- // Compute vectors
- float[] ac = computeVector(a, c); //v0
- float[] ab = computeVector(a, b); //v1
- float[] ap = computeVector(a, p); //v2
-
- // Compute dot products
- float dot00 = dot(ac, ac);
- float dot01 = dot(ac, ab);
- float dot02 = dot(ac, ap);
- float dot11 = dot(ab, ab);
- float dot12 = dot(ab, ap);
-
- // Compute barycentric coordinates
- float invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
- float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
- float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
-
- // Check if point is in triangle
- return (u >= 0) && (v >= 0) && (u + v < 1);
- }
-
- /** Check if points are in ccw order
- * @param a first vertex
- * @param b second vertex
- * @param c third vertex
- * @return true if the points a,b,c are in a ccw order
- */
- public static boolean ccw(Vertex a, Vertex b, Vertex c){
- return triArea(a,b,c) > 0;
- }
-
- /** Compute the winding of given points
- * @param a first vertex
- * @param b second vertex
- * @param c third vertex
- * @return Winding
- */
- public static Winding getWinding(Vertex a, Vertex b, Vertex c) {
- return triArea(a,b,c) > 0 ? Winding.CCW : Winding.CW ;
- }
-
- /** Computes the area of a list of vertices to check if ccw
- * @param vertices
- * @return positive area if ccw else negative area value
- */
- public static float area(ArrayList<Vertex> vertices) {
- int n = vertices.size();
- float area = 0.0f;
- for (int p = n - 1, q = 0; q < n; p = q++)
- {
- float[] pCoord = vertices.get(p).getCoord();
- float[] qCoord = vertices.get(q).getCoord();
- area += pCoord[0] * qCoord[1] - qCoord[0] * pCoord[1];
- }
- return area;
- }
-
- /** Compute the general winding of the vertices
- * @param vertices array of Vertices
- * @return CCW or CW {@link Winding}
- */
- public static Winding getWinding(ArrayList<Vertex> vertices) {
- return area(vertices) >= 0 ? Winding.CCW : Winding.CW ;
- }
-
-
- /** Compute intersection between two segments
- * @param a vertex 1 of first segment
- * @param b vertex 2 of first segment
- * @param c vertex 1 of second segment
- * @param d vertex 2 of second segment
- * @return the intersection coordinates if the segments intersect, otherwise
- * returns null
- */
- public static float[] seg2SegIntersection(Vertex a, Vertex b, Vertex c, Vertex d) {
- float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX());
-
- if (determinant == 0)
- return null;
-
- float alpha = (a.getX()*b.getY()-a.getY()*b.getX());
- float beta = (c.getX()*d.getY()-c.getY()*d.getY());
- float xi = ((c.getX()-d.getX())*alpha-(a.getX()-b.getX())*beta)/determinant;
- float yi = ((c.getY()-d.getY())*alpha-(a.getY()-b.getY())*beta)/determinant;
-
- float gamma = (xi - a.getX())/(b.getX() - a.getX());
- float gamma1 = (xi - c.getX())/(d.getX() - c.getX());
- if(gamma <= 0 || gamma >= 1) return null;
- if(gamma1 <= 0 || gamma1 >= 1) return null;
-
- return new float[]{xi,yi,0};
- }
-
- /** Compute intersection between two lines
- * @param a vertex 1 of first line
- * @param b vertex 2 of first line
- * @param c vertex 1 of second line
- * @param d vertex 2 of second line
- * @return the intersection coordinates if the lines intersect, otherwise
- * returns null
- */
- public static float[] line2lineIntersection(Vertex a, Vertex b, Vertex c, Vertex d) {
- float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX());
-
- if (determinant == 0)
- return null;
-
- float alpha = (a.getX()*b.getY()-a.getY()*b.getX());
- float beta = (c.getX()*d.getY()-c.getY()*d.getY());
- float xi = ((c.getX()-d.getX())*alpha-(a.getX()-b.getX())*beta)/determinant;
- float yi = ((c.getY()-d.getY())*alpha-(a.getY()-b.getY())*beta)/determinant;
-
- return new float[]{xi,yi,0};
- }
-
- /** Check if a segment intersects with a triangle
- * @param a vertex 1 of the triangle
- * @param b vertex 2 of the triangle
- * @param c vertex 3 of the triangle
- * @param d vertex 1 of first segment
- * @param e vertex 2 of first segment
- * @return true if the segment intersects at least one segment of the triangle, false otherwise
- */
- public static boolean tri2SegIntersection(Vertex a, Vertex b, Vertex c, Vertex d, Vertex e){
- if(seg2SegIntersection(a, b, d, e) != null)
- return true;
- if(seg2SegIntersection(b, c, d, e) != null)
- return true;
- if(seg2SegIntersection(a, c, d, e) != null)
- return true;
-
- return false;
- }
-}
+/**
+ * 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.graph.math;
+
+import java.util.ArrayList;
+
+import jogamp.graph.math.MathFloat;
+
+import com.jogamp.graph.geom.Vertex;
+
+public class VectorUtil {
+
+ public enum Winding {
+ CW(-1), CCW(1);
+
+ public final int dir;
+
+ Winding(int dir) {
+ this.dir = dir;
+ }
+ }
+
+ public static final int COLLINEAR = 0;
+
+ /** compute the dot product of two points
+ * @param vec1 vector 1
+ * @param vec2 vector 2
+ * @return the dot product as float
+ */
+ public static float dot(float[] vec1, float[] vec2)
+ {
+ return (vec1[0]*vec2[0] + vec1[1]*vec2[1] + vec1[2]*vec2[2]);
+ }
+ /** Normalize a vector
+ * @param vector input vector
+ * @return normalized vector
+ */
+ public static float[] normalize(float[] vector)
+ {
+ float[] newVector = new float[3];
+
+ float d = MathFloat.sqrt(vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2]);
+ if(d> 0.0f)
+ {
+ newVector[0] = vector[0]/d;
+ newVector[1] = vector[1]/d;
+ newVector[2] = vector[2]/d;
+ }
+ return newVector;
+ }
+
+ /** Scales a vector by param
+ * @param vector input vector
+ * @param scale constant to scale by
+ * @return scaled vector
+ */
+ public static float[] scale(float[] vector, float scale)
+ {
+ float[] newVector = new float[3];
+
+ newVector[0] = vector[0]*scale;
+ newVector[1] = vector[1]*scale;
+ newVector[2] = vector[2]*scale;
+ return newVector;
+ }
+
+ /** Adds to vectors
+ * @param v1 vector 1
+ * @param v2 vector 2
+ * @return v1 + v2
+ */
+ public static float[] vectorAdd(float[] v1, float[] v2)
+ {
+ float[] newVector = new float[3];
+
+ newVector[0] = v1[0] + v2[0];
+ newVector[1] = v1[1] + v2[1];
+ newVector[2] = v1[2] + v2[2];
+ return newVector;
+ }
+
+ /** cross product vec1 x vec2
+ * @param vec1 vector 1
+ * @param vec2 vecttor 2
+ * @return the resulting vector
+ */
+ public static float[] cross(float[] vec1, float[] vec2)
+ {
+ float[] out = new float[3];
+
+ out[0] = vec2[2]*vec1[1] - vec2[1]*vec1[2];
+ out[1] = vec2[0]*vec1[2] - vec2[2]*vec1[0];
+ out[2] = vec2[1]*vec1[0] - vec2[0]*vec1[1];
+
+ return out;
+ }
+
+ /** Column Matrix Vector multiplication
+ * @param colMatrix column matrix (4x4)
+ * @param vec vector(x,y,z)
+ * @return result new float[3]
+ */
+ public static float[] colMatrixVectorMult(float[] colMatrix, float[] vec)
+ {
+ float[] out = new float[3];
+
+ out[0] = vec[0]*colMatrix[0] + vec[1]*colMatrix[4] + vec[2]*colMatrix[8] + colMatrix[12];
+ out[1] = vec[0]*colMatrix[1] + vec[1]*colMatrix[5] + vec[2]*colMatrix[9] + colMatrix[13];
+ out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14];
+
+ return out;
+ }
+
+ /** Matrix Vector multiplication
+ * @param rawMatrix column matrix (4x4)
+ * @param vec vector(x,y,z)
+ * @return result new float[3]
+ */
+ public static float[] rowMatrixVectorMult(float[] rawMatrix, float[] vec)
+ {
+ float[] out = new float[3];
+
+ out[0] = vec[0]*rawMatrix[0] + vec[1]*rawMatrix[1] + vec[2]*rawMatrix[2] + rawMatrix[3];
+ out[1] = vec[0]*rawMatrix[4] + vec[1]*rawMatrix[5] + vec[2]*rawMatrix[6] + rawMatrix[7];
+ out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11];
+
+ return out;
+ }
+
+ /** Calculate the midpoint of two values
+ * @param p1 first value
+ * @param p2 second vale
+ * @return midpoint
+ */
+ public static float mid(float p1, float p2)
+ {
+ return (p1+p2)/2.0f;
+ }
+ /** Calculate the midpoint of two points
+ * @param p1 first point
+ * @param p2 second point
+ * @return midpoint
+ */
+ public static float[] mid(float[] p1, float[] p2)
+ {
+ float[] midPoint = new float[3];
+ midPoint[0] = (p1[0] + p2[0])*0.5f;
+ midPoint[1] = (p1[1] + p2[1])*0.5f;
+ midPoint[2] = (p1[2] + p2[2])*0.5f;
+
+ return midPoint;
+ }
+ /** Compute the norm of a vector
+ * @param vec vector
+ * @return vorm
+ */
+ public static float norm(float[] vec)
+ {
+ return MathFloat.sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
+ }
+ /** Compute distance between 2 points
+ * @param p0 a ref point on the line
+ * @param vec vector representing the direction of the line
+ * @param point the point to compute the relative distance of
+ * @return distance float
+ */
+ public static float computeLength(float[] p0, float[] point)
+ {
+ float[] w = new float[]{point[0]-p0[0],point[1]-p0[1],point[2]-p0[2]};
+
+ float distance = MathFloat.sqrt(w[0]*w[0] + w[1]*w[1] + w[2]*w[2]);
+
+ return distance;
+ }
+
+ /**Check equality of 2 vec3 vectors
+ * @param v1 vertex 1
+ * @param v2 vertex 2
+ * @return
+ */
+ public static boolean checkEquality(float[] v1, float[] v2)
+ {
+ if(Float.compare(v1[0], v2[0]) == 0 &&
+ Float.compare(v1[1], v2[1]) == 0 &&
+ Float.compare(v1[2], v2[2]) == 0 )
+ return true;
+ return false;
+ }
+
+ /**Check equality of 2 vec2 vectors
+ * @param v1 vertex 1
+ * @param v2 vertex 2
+ * @return
+ */
+ public static boolean checkEqualityVec2(float[] v1, float[] v2)
+ {
+ if(Float.compare(v1[0], v2[0]) == 0 &&
+ Float.compare(v1[1], v2[1]) == 0)
+ return true;
+ return false;
+ }
+
+ /** Compute the determinant of 3 vectors
+ * @param a vector 1
+ * @param b vector 2
+ * @param c vector 3
+ * @return the determinant value
+ */
+ public static float computeDeterminant(float[] a, float[] b, float[] c)
+ {
+ float area = a[0]*b[1]*c[2] + a[1]*b[2]*c[0] + a[2]*b[0]*c[1] - a[0]*b[2]*c[1] - a[1]*b[0]*c[2] - a[2]*b[1]*c[0];
+ return area;
+ }
+
+ /** Check if three vertices are colliniear
+ * @param v1 vertex 1
+ * @param v2 vertex 2
+ * @param v3 vertex 3
+ * @return true if collinear, false otherwise
+ */
+ public static boolean checkCollinear(float[] v1, float[] v2, float[] v3)
+ {
+ return (computeDeterminant(v1, v2, v3) == VectorUtil.COLLINEAR);
+ }
+
+ /** Compute Vector
+ * @param v1 vertex 1
+ * @param v2 vertex2 2
+ * @return Vector V1V2
+ */
+ public static float[] computeVector(float[] v1, float[] v2)
+ {
+ float[] vector = new float[3];
+ vector[0] = v2[0] - v1[0];
+ vector[1] = v2[1] - v1[1];
+ vector[2] = v2[2] - v1[2];
+ return vector;
+ }
+
+ /** Check if vertices in triangle circumcircle
+ * @param a triangle vertex 1
+ * @param b triangle vertex 2
+ * @param c triangle vertex 3
+ * @param d vertex in question
+ * @return true if the vertex d is inside the circle defined by the
+ * vertices a, b, c. from paper by Guibas and Stolfi (1985).
+ */
+ public static boolean inCircle(Vertex a, Vertex b, Vertex c, Vertex d){
+ return (a.getX() * a.getX() + a.getY() * a.getY()) * triArea(b, c, d) -
+ (b.getX() * b.getX() + b.getY() * b.getY()) * triArea(a, c, d) +
+ (c.getX() * c.getX() + c.getY() * c.getY()) * triArea(a, b, d) -
+ (d.getX() * d.getX() + d.getY() * d.getY()) * triArea(a, b, c) > 0;
+ }
+
+ /** Computes oriented area of a triangle
+ * @param a first vertex
+ * @param b second vertex
+ * @param c third vertex
+ * @return compute twice the area of the oriented triangle (a,b,c), the area
+ * is positive if the triangle is oriented counterclockwise.
+ */
+ public static float triArea(Vertex a, Vertex b, Vertex c){
+ return (b.getX() - a.getX()) * (c.getY() - a.getY()) - (b.getY() - a.getY())*(c.getX() - a.getX());
+ }
+
+ /** Check if a vertex is in triangle using
+ * barycentric coordinates computation.
+ * @param a first triangle vertex
+ * @param b second triangle vertex
+ * @param c third triangle vertex
+ * @param p the vertex in question
+ * @return true if p is in triangle (a, b, c), false otherwise.
+ */
+ public static boolean vertexInTriangle(float[] a, float[] b, float[] c, float[] p){
+ // Compute vectors
+ float[] ac = computeVector(a, c); //v0
+ float[] ab = computeVector(a, b); //v1
+ float[] ap = computeVector(a, p); //v2
+
+ // Compute dot products
+ float dot00 = dot(ac, ac);
+ float dot01 = dot(ac, ab);
+ float dot02 = dot(ac, ap);
+ float dot11 = dot(ab, ab);
+ float dot12 = dot(ab, ap);
+
+ // Compute barycentric coordinates
+ float invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
+ float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
+ float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
+
+ // Check if point is in triangle
+ return (u >= 0) && (v >= 0) && (u + v < 1);
+ }
+
+ /** Check if points are in ccw order
+ * @param a first vertex
+ * @param b second vertex
+ * @param c third vertex
+ * @return true if the points a,b,c are in a ccw order
+ */
+ public static boolean ccw(Vertex a, Vertex b, Vertex c){
+ return triArea(a,b,c) > 0;
+ }
+
+ /** Compute the winding of given points
+ * @param a first vertex
+ * @param b second vertex
+ * @param c third vertex
+ * @return Winding
+ */
+ public static Winding getWinding(Vertex a, Vertex b, Vertex c) {
+ return triArea(a,b,c) > 0 ? Winding.CCW : Winding.CW ;
+ }
+
+ /** Computes the area of a list of vertices to check if ccw
+ * @param vertices
+ * @return positive area if ccw else negative area value
+ */
+ public static float area(ArrayList<Vertex> vertices) {
+ int n = vertices.size();
+ float area = 0.0f;
+ for (int p = n - 1, q = 0; q < n; p = q++)
+ {
+ float[] pCoord = vertices.get(p).getCoord();
+ float[] qCoord = vertices.get(q).getCoord();
+ area += pCoord[0] * qCoord[1] - qCoord[0] * pCoord[1];
+ }
+ return area;
+ }
+
+ /** Compute the general winding of the vertices
+ * @param vertices array of Vertices
+ * @return CCW or CW {@link Winding}
+ */
+ public static Winding getWinding(ArrayList<Vertex> vertices) {
+ return area(vertices) >= 0 ? Winding.CCW : Winding.CW ;
+ }
+
+
+ /** Compute intersection between two segments
+ * @param a vertex 1 of first segment
+ * @param b vertex 2 of first segment
+ * @param c vertex 1 of second segment
+ * @param d vertex 2 of second segment
+ * @return the intersection coordinates if the segments intersect, otherwise
+ * returns null
+ */
+ public static float[] seg2SegIntersection(Vertex a, Vertex b, Vertex c, Vertex d) {
+ float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX());
+
+ if (determinant == 0)
+ return null;
+
+ float alpha = (a.getX()*b.getY()-a.getY()*b.getX());
+ float beta = (c.getX()*d.getY()-c.getY()*d.getY());
+ float xi = ((c.getX()-d.getX())*alpha-(a.getX()-b.getX())*beta)/determinant;
+ float yi = ((c.getY()-d.getY())*alpha-(a.getY()-b.getY())*beta)/determinant;
+
+ float gamma = (xi - a.getX())/(b.getX() - a.getX());
+ float gamma1 = (xi - c.getX())/(d.getX() - c.getX());
+ if(gamma <= 0 || gamma >= 1) return null;
+ if(gamma1 <= 0 || gamma1 >= 1) return null;
+
+ return new float[]{xi,yi,0};
+ }
+
+ /** Compute intersection between two lines
+ * @param a vertex 1 of first line
+ * @param b vertex 2 of first line
+ * @param c vertex 1 of second line
+ * @param d vertex 2 of second line
+ * @return the intersection coordinates if the lines intersect, otherwise
+ * returns null
+ */
+ public static float[] line2lineIntersection(Vertex a, Vertex b, Vertex c, Vertex d) {
+ float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX());
+
+ if (determinant == 0)
+ return null;
+
+ float alpha = (a.getX()*b.getY()-a.getY()*b.getX());
+ float beta = (c.getX()*d.getY()-c.getY()*d.getY());
+ float xi = ((c.getX()-d.getX())*alpha-(a.getX()-b.getX())*beta)/determinant;
+ float yi = ((c.getY()-d.getY())*alpha-(a.getY()-b.getY())*beta)/determinant;
+
+ return new float[]{xi,yi,0};
+ }
+
+ /** Check if a segment intersects with a triangle
+ * @param a vertex 1 of the triangle
+ * @param b vertex 2 of the triangle
+ * @param c vertex 3 of the triangle
+ * @param d vertex 1 of first segment
+ * @param e vertex 2 of first segment
+ * @return true if the segment intersects at least one segment of the triangle, false otherwise
+ */
+ public static boolean tri2SegIntersection(Vertex a, Vertex b, Vertex c, Vertex d, Vertex e){
+ if(seg2SegIntersection(a, b, d, e) != null)
+ return true;
+ if(seg2SegIntersection(b, c, d, e) != null)
+ return true;
+ if(seg2SegIntersection(a, c, d, e) != null)
+ return true;
+
+ return false;
+ }
+}
diff --git a/src/jogl/classes/com/jogamp/opengl/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/FloatUtil.java
index 54fac46..93543ea 100644
--- a/src/jogl/classes/com/jogamp/opengl/FloatUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/FloatUtil.java
@@ -32,6 +32,10 @@ import java.nio.FloatBuffer;
/**
* Basic Float math utility functions.
* <p>
+ * Implementation assumes linear matrix layout in column-major order
+ * matching OpenGL's implementation.
+ * </p>
+ * <p>
* Derived from ProjectFloat.java - Created 11-jan-2004
* </p>
*
@@ -91,29 +95,31 @@ public class FloatUtil {
}
/**
- * @param a
- * @param b
- * @param d result a*b
+ * @param a 4x4 matrix in column-major order
+ * @param b 4x4 matrix in column-major order
+ * @param d result a*b in column-major order
*/
public static final void multMatrixf(final float[] a, int a_off, final float[] b, int b_off, float[] d, int d_off) {
for (int i = 0; i < 4; i++) {
- final float ai0=a[a_off+i+0*4], ai1=a[a_off+i+1*4], ai2=a[a_off+i+2*4], ai3=a[a_off+i+3*4];
+ // one row in column-major order
+ final float ai0=a[a_off+i+0*4], ai1=a[a_off+i+1*4], ai2=a[a_off+i+2*4], ai3=a[a_off+i+3*4]; // row-i of a
d[d_off+i+0*4] = ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] ;
d[d_off+i+1*4] = ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] ;
d[d_off+i+2*4] = ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] ;
d[d_off+i+3*4] = ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ;
}
}
-
+
/**
- * @param a
- * @param b
- * @param d result a*b
+ * @param a 4x4 matrix in column-major order
+ * @param b 4x4 matrix in column-major order
+ * @param d result a*b in column-major order
*/
public static final void multMatrixf(final float[] a, int a_off, final float[] b, int b_off, FloatBuffer d) {
final int dP = d.position();
for (int i = 0; i < 4; i++) {
- final float ai0=a[a_off+i+0*4], ai1=a[a_off+i+1*4], ai2=a[a_off+i+2*4], ai3=a[a_off+i+3*4];
+ // one row in column-major order
+ final float ai0=a[a_off+i+0*4], ai1=a[a_off+i+1*4], ai2=a[a_off+i+2*4], ai3=a[a_off+i+3*4]; // row-i of a
d.put(dP+i+0*4 , ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] );
d.put(dP+i+1*4 , ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] );
d.put(dP+i+2*4 , ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] );
@@ -122,15 +128,16 @@ public class FloatUtil {
}
/**
- * @param a
- * @param b
- * @param d result a*b
+ * @param a 4x4 matrix in column-major order
+ * @param b 4x4 matrix in column-major order
+ * @param d result a*b in column-major order
*/
public static final void multMatrixf(final FloatBuffer a, final float[] b, int b_off, FloatBuffer d) {
final int aP = a.position();
final int dP = d.position();
for (int i = 0; i < 4; i++) {
- final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4);
+ // one row in column-major order
+ final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4); // row-i of a
d.put(dP+i+0*4 , ai0 * b[b_off+0+0*4] + ai1 * b[b_off+1+0*4] + ai2 * b[b_off+2+0*4] + ai3 * b[b_off+3+0*4] );
d.put(dP+i+1*4 , ai0 * b[b_off+0+1*4] + ai1 * b[b_off+1+1*4] + ai2 * b[b_off+2+1*4] + ai3 * b[b_off+3+1*4] );
d.put(dP+i+2*4 , ai0 * b[b_off+0+2*4] + ai1 * b[b_off+1+2*4] + ai2 * b[b_off+2+2*4] + ai3 * b[b_off+3+2*4] );
@@ -139,16 +146,17 @@ public class FloatUtil {
}
/**
- * @param a
- * @param b
- * @param d result a*b
+ * @param a 4x4 matrix in column-major order
+ * @param b 4x4 matrix in column-major order
+ * @param d result a*b in column-major order
*/
public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b, FloatBuffer d) {
final int aP = a.position();
final int bP = b.position();
final int dP = d.position();
for (int i = 0; i < 4; i++) {
- final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4);
+ // one row in column-major order
+ final float ai0=a.get(aP+i+0*4), ai1=a.get(aP+i+1*4), ai2=a.get(aP+i+2*4), ai3=a.get(aP+i+3*4); // row-i of a
d.put(dP+i+0*4 , ai0 * b.get(bP+0+0*4) + ai1 * b.get(bP+1+0*4) + ai2 * b.get(bP+2+0*4) + ai3 * b.get(bP+3+0*4) );
d.put(dP+i+1*4 , ai0 * b.get(bP+0+1*4) + ai1 * b.get(bP+1+1*4) + ai2 * b.get(bP+2+1*4) + ai3 * b.get(bP+3+1*4) );
d.put(dP+i+2*4 , ai0 * b.get(bP+0+2*4) + ai1 * b.get(bP+1+2*4) + ai2 * b.get(bP+2+2*4) + ai3 * b.get(bP+3+2*4) );
@@ -201,10 +209,10 @@ public class FloatUtil {
/**
- * Calculate cross-product
+ * Calculate cross-product of 2 vector
*
- * @param v1
- * @param v2
+ * @param v1 3-component vector
+ * @param v2 3-component vector
* @param result v1 X v2
*/
public static final void cross(float[] v1, float[] v2, float[] result) {
@@ -214,10 +222,10 @@ public class FloatUtil {
}
/**
- * Calculate cross-product
+ * Calculate cross-product of 2 vector
*
- * @param v1
- * @param v2
+ * @param v1 3-component vector
+ * @param v2 3-component vector
* @param result v1 X v2
*/
public static final void cross(FloatBuffer v1, FloatBuffer v2, FloatBuffer result) {
@@ -231,15 +239,14 @@ public class FloatUtil {
}
/**
- * Method __gluMultMatrixVecf
- *
- * @param m_in
+ * @param m_in 4x4 matrix in column-major order
* @param m_in_off
- * @param v_in
+ * @param v_in 4-component column-vector
* @param v_out m_in * v_in
*/
public static final void multMatrixVecf(float[] m_in, int m_in_off, float[] v_in, int v_in_off, float[] v_out) {
for (int i = 0; i < 4; i++) {
+ // (one matrix row in column-major order) X (column vector)
v_out[i] =
v_in[0+v_in_off] * m_in[0*4+i+m_in_off] +
v_in[1+v_in_off] * m_in[1*4+i+m_in_off] +
@@ -249,15 +256,14 @@ public class FloatUtil {
}
/**
- * Method __gluMultMatrixVecf
- *
- * @param m_in
+ * @param m_in 4x4 matrix in column-major order
* @param m_in_off
- * @param v_in
+ * @param v_in 4-component column-vector
* @param v_out m_in * v_in
*/
public static final void multMatrixVecf(float[] m_in, float[] v_in, float[] v_out) {
for (int i = 0; i < 4; i++) {
+ // (one matrix row in column-major order) X (column vector)
v_out[i] =
v_in[0] * m_in[0*4+i] +
v_in[1] * m_in[1*4+i] +
@@ -267,10 +273,8 @@ public class FloatUtil {
}
/**
- * Method __gluMultMatrixVecf
- *
- * @param m_in
- * @param v_in
+ * @param m_in 4x4 matrix in column-major order
+ * @param v_in 4-component column-vector
* @param v_out m_in * v_in
*/
public static final void multMatrixVecf(FloatBuffer m_in, FloatBuffer v_in, FloatBuffer v_out) {
@@ -278,6 +282,7 @@ public class FloatUtil {
int outPos = v_out.position();
int matrixPos = m_in.position();
for (int i = 0; i < 4; i++) {
+ // (one matrix row in column-major order) X (column vector)
v_out.put(i + outPos,
v_in.get(0+inPos) * m_in.get(0*4+i+matrixPos) +
v_in.get(1+inPos) * m_in.get(1*4+i+matrixPos) +
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index f2cddca..73ad97f 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -239,7 +239,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
drawable.setRealized(true);
context = drawable.createContext(shareWith);
- context.setSynchronized(true);
/* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */
/* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
index 32391c6..8401b9c 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java
@@ -43,6 +43,7 @@ import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLES2;
import javax.media.opengl.GLException;
import java.nio.*;
@@ -456,6 +457,7 @@ public class GLBuffers extends Buffers {
case GL.GL_SHORT:
case GL.GL_UNSIGNED_SHORT:
case GL.GL_HALF_FLOAT:
+ case GLES2.GL_HALF_FLOAT_OES:
esize = 2;
break;
case GL2ES2.GL_INT:
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 a94b1f8..49d4add 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
@@ -907,12 +907,17 @@ public class Texture {
}
} else {
if (mustFlipVertically) {
- coords = new TextureCoords(0, (float) imgHeight / (float) texHeight,
- (float) imgWidth / (float) texWidth, 0);
+ coords = new TextureCoords(0, // l
+ (float) imgHeight / (float) texHeight, // b
+ (float) imgWidth / (float) texWidth, // r
+ 0 // t
+ );
} else {
- coords = new TextureCoords(0, 0,
- (float) imgWidth / (float) texWidth,
- (float) imgHeight / (float) texHeight);
+ coords = new TextureCoords(0, // l
+ 0, // b
+ (float) imgWidth / (float) texWidth, // r
+ (float) imgHeight / (float) texHeight // t
+ );
}
}
}
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 928f91c..96ee233 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java
@@ -355,7 +355,7 @@ public class TextureData {
}
public String toString() {
- return "TextureData["+width+"x"+height+", internFormat 0x"+Integer.toHexString(internalFormat)+", pixelFormat 0x"+Integer.toHexString(pixelFormat)+", pixelType 0x"+Integer.toHexString(pixelType)+", border "+border+", estSize "+estimatedMemorySize+", alignment "+alignment+", rowlen "+rowLength;
+ return "TextureData["+width+"x"+height+", y-flip "+mustFlipVertically+", internFormat 0x"+Integer.toHexString(internalFormat)+", pixelFormat 0x"+Integer.toHexString(pixelFormat)+", pixelType 0x"+Integer.toHexString(pixelType)+", border "+border+", estSize "+estimatedMemorySize+", alignment "+alignment+", rowlen "+rowLength;
}
//----------------------------------------------------------------------
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 d722100..ca97cdc 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java
@@ -1106,7 +1106,7 @@ public class TextureIO {
}
if (internalFormat == 0) {
if(glp.isGL2GL3()) {
- internalFormat = GL.GL_RGBA8;
+ internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA8:GL.GL_RGB8;
} else {
internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB;
}
@@ -1143,7 +1143,7 @@ public class TextureIO {
}
if (internalFormat == 0) {
if(glp.isGL2GL3()) {
- internalFormat = GL.GL_RGBA8;
+ internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA8:GL.GL_RGB8;
} else {
internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB;
}
@@ -1153,7 +1153,7 @@ public class TextureIO {
image.getHeight(),
0,
pixelFormat,
- GL.GL_UNSIGNED_BYTE,
+ image.getGLType(),
mipmap,
false,
false,
@@ -1183,13 +1183,13 @@ public class TextureIO {
int d3dFormat = 0;
// FIXME: some of these are probably not completely correct and would require swizzling
switch (pixelFormat) {
- case GL.GL_RGB: d3dFormat = DDSImage.D3DFMT_R8G8B8; break;
- case GL.GL_RGBA: d3dFormat = DDSImage.D3DFMT_A8R8G8B8; break;
- case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT: d3dFormat = DDSImage.D3DFMT_DXT1; break;
- case GL.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: throw new IOException("RGBA DXT1 not yet supported");
- case GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: d3dFormat = DDSImage.D3DFMT_DXT3; break;
- case GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: d3dFormat = DDSImage.D3DFMT_DXT5; break;
- default: throw new IOException("Unsupported pixel format 0x" + Integer.toHexString(pixelFormat) + " by DDS writer");
+ case GL.GL_RGB: d3dFormat = DDSImage.D3DFMT_R8G8B8; break;
+ case GL.GL_RGBA: d3dFormat = DDSImage.D3DFMT_A8R8G8B8; break;
+ case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT: d3dFormat = DDSImage.D3DFMT_DXT1; break;
+ case GL.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: throw new IOException("RGBA DXT1 not yet supported");
+ case GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: d3dFormat = DDSImage.D3DFMT_DXT3; break;
+ case GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: d3dFormat = DDSImage.D3DFMT_DXT5; break;
+ default: throw new IOException("Unsupported pixel format 0x" + Integer.toHexString(pixelFormat) + " by DDS writer");
}
ByteBuffer[] mipmaps = null;
@@ -1319,6 +1319,10 @@ public class TextureIO {
boolean reversedChannels;
int bytesPerPixel;
switch(pixelFormat) {
+ case GL.GL_LUMINANCE:
+ reversedChannels=false;
+ bytesPerPixel=1;
+ break;
case GL.GL_RGB:
reversedChannels=false;
bytesPerPixel=3;
@@ -1340,10 +1344,8 @@ public class TextureIO {
bytesPerPixel=-1;
break;
}
- if ( 1 < bytesPerPixel &&
- (pixelType == GL.GL_BYTE ||
- pixelType == GL.GL_UNSIGNED_BYTE)) {
-
+ if ( ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel) &&
+ ( pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) {
ByteBuffer buf = (ByteBuffer) data.getBuffer();
if (null == buf) {
buf = (ByteBuffer) data.getMipmapData()[0];
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java
index a89418f..d8d6f7d 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java
@@ -23,7 +23,7 @@ import com.jogamp.common.util.IOUtil;
public class PNGImage {
/** Creates a PNGImage from data supplied by the end user. Shares
data with the passed ByteBuffer. Assumes the data is already in
- the correct byte order for writing to disk, i.e., RGB or RGBA bottom-to-top (OpenGL coord). */
+ the correct byte order for writing to disk, i.e., LUMINANCE, RGB or RGBA bottom-to-top (OpenGL coord). */
public static PNGImage createFromData(int width, int height, double dpiX, double dpiY,
int bytesPerPixel, boolean reversedChannels, ByteBuffer data) {
return new PNGImage(width, height, dpiX, dpiY, bytesPerPixel, reversedChannels, data);
@@ -44,7 +44,7 @@ public class PNGImage {
d.put(dOff--, (byte)line.scanline[lineOff ]); // R
return dOff;
}
- /** Reverse read and store, implicitly flip image from GL coords. */
+ /** Reverse read and store, implicitly flip image from GL coords. Handle reversed channels (BGR[A])*/
private static int setPixelRGBA8(ImageLine line, int lineOff, ByteBuffer d, int dOff, boolean hasAlpha, boolean reversedChannels) {
if(reversedChannels) {
line.scanline[lineOff ] = d.get(dOff--); // R, A
@@ -83,12 +83,15 @@ public class PNGImage {
private PNGImage(InputStream in) {
final PngReader pngr = new PngReader(new BufferedInputStream(in), null);
final int channels = pngr.imgInfo.channels;
- if (3 > channels || channels > 4 ) {
- throw new RuntimeException("PNGImage can only handle RGB/RGBA images for now. Channels "+channels);
+ if ( ! ( 1 == channels || 3 == channels || 4 == channels ) ) {
+ throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 channels] images for now. Channels "+channels);
}
bytesPerPixel=pngr.imgInfo.bytesPixel;
- if (3 > bytesPerPixel || bytesPerPixel > 4 ) {
- throw new RuntimeException("PNGImage can only handle RGB/RGBA images for now. BytesPerPixel "+bytesPerPixel);
+ if ( ! ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel ) ) {
+ throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 bpp] images for now. BytesPerPixel "+bytesPerPixel);
+ }
+ if(channels != bytesPerPixel) {
+ throw new RuntimeException("PNGImage currently only handles Channels [1/3/4] == BytePerPixel [1/3/4], channels: "+channels+", bytesPerPixel "+bytesPerPixel);
}
pixelWidth=pngr.imgInfo.cols;
pixelHeight=pngr.imgInfo.rows;
@@ -97,18 +100,29 @@ public class PNGImage {
final double[] dpi2 = pngr.getMetadata().getDpi();
dpi[0]=dpi2[0];
dpi[1]=dpi2[1];
- }
- glFormat= ( 4 == bytesPerPixel ) ? GL.GL_RGBA : GL.GL_RGB;
+ }
+ switch(channels) {
+ case 1: glFormat = GL.GL_LUMINANCE; break;
+ case 3: glFormat = GL.GL_RGB; break;
+ case 4: glFormat = GL.GL_RGBA; break;
+ default: throw new InternalError("XXX: channels: "+channels+", bytesPerPixel "+bytesPerPixel);
+ }
data = Buffers.newDirectByteBuffer(bytesPerPixel * pixelWidth * pixelHeight);
reversedChannels = false; // RGB[A]
- final boolean hasAlpha = 4 == bytesPerPixel;
+ final boolean hasAlpha = 4 == channels;
int dataOff = bytesPerPixel * pixelWidth * pixelHeight - 1; // start at end-of-buffer, reverse store
for (int row = 0; row < pixelHeight; row++) {
final ImageLine l1 = pngr.readRow(row);
int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse read
- for (int j = pixelWidth - 1; j >= 0; j--) {
- dataOff = getPixelRGBA8(data, dataOff, l1, lineOff, hasAlpha);
- lineOff -= bytesPerPixel;
+ if(1 == channels) {
+ for (int j = pixelWidth - 1; j >= 0; j--) {
+ data.put(dataOff--, (byte)l1.scanline[lineOff--]); // Luminance, 1 bytesPerPixel
+ }
+ } else {
+ for (int j = pixelWidth - 1; j >= 0; j--) {
+ dataOff = getPixelRGBA8(data, dataOff, l1, lineOff, hasAlpha);
+ lineOff -= bytesPerPixel;
+ }
}
}
pngr.end();
@@ -132,6 +146,9 @@ public class PNGImage {
/** Returns the OpenGL format for this texture; e.g. GL.GL_BGR or GL.GL_BGRA. */
public int getGLFormat() { return glFormat; }
+
+ /** Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE. */
+ public int getGLType() { return GL.GL_UNSIGNED_BYTE; }
/** Returns the bytes per pixel */
public int getBytesPerPixel() { return bytesPerPixel; }
@@ -156,9 +173,15 @@ public class PNGImage {
int dataOff = bytesPerPixel * pixelWidth * pixelHeight - 1; // start at end-of-buffer, reverse read
for (int row = 0; row < pixelHeight; row++) {
int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse store
- for (int j = pixelWidth - 1; j >= 0; j--) {
- dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha, reversedChannels);
- lineOff -= bytesPerPixel;
+ if(1 == bytesPerPixel) {
+ for (int j = pixelWidth - 1; j >= 0; j--) {
+ l1.scanline[lineOff--] = data.get(dataOff--); // // Luminance, 1 bytesPerPixel
+ }
+ } else {
+ for (int j = pixelWidth - 1; j >= 0; j--) {
+ dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha, reversedChannels);
+ lineOff -= bytesPerPixel;
+ }
}
png.writeRow(l1, row);
}
diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
index f0101a9..c676535 100644
--- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java
@@ -181,22 +181,26 @@ public interface GLAutoDrawable extends GLDrawable {
/**
* <p>
- * Enqueues a one-shot {@link javax.media.opengl.GLRunnable GLRunnable},
- * which will be executed with the next {@link #display()} call.</p>
+ * Enqueues a one-shot {@link GLRunnable},
+ * which will be executed within the next {@link #display()} call
+ * after all registered {@link GLEventListener}s
+ * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)}
+ * methods has been called.
+ * </p>
* <p>
- * If no {@link javax.media.opengl.GLAnimatorControl GLAnimatorControl} is animating (default),<br>
+ * If no {@link GLAnimatorControl} is animating (default),<br>
* or if the current thread is the animator thread,<br>
* a {@link #display()} call is issued after enqueue the <code>GLRunnable</code>.<br>
* No extra synchronization is performed in case <code>wait</code> is true, since it is executed in the current thread.</p>
* <p>
- * If an {@link javax.media.opengl.GLAnimatorControl GLAnimatorControl} is animating,<br>
+ * If an {@link GLAnimatorControl} is animating,<br>
* no {@link #display()} call is issued, since the animator thread performs it.<br>
* If <code>wait</code> is true, the implementation waits until the <code>GLRunnable</code> is executed.<br>
* </p><br>
*
- * @see #setAnimator(javax.media.opengl.GLAnimatorControl)
+ * @see #setAnimator(GLAnimatorControl)
* @see #display()
- * @see javax.media.opengl.GLRunnable
+ * @see GLRunnable
*/
public void invoke(boolean wait, GLRunnable glRunnable);
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 815da27..e23fa74 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -319,16 +319,6 @@ public abstract class GLContext {
public abstract void destroy();
/**
- * Returns true if 'makeCurrent' will exhibit synchronized behavior.
- */
- public abstract boolean isSynchronized();
-
- /**
- * Determines whether 'makeCurrent' will exhibit synchronized behavior.
- */
- public abstract void setSynchronized(boolean isSynchronized);
-
- /**
* Returns the GL pipeline object for this GLContext.
*
* @return the aggregated GL instance, or null if this context was not yet made current.
diff --git a/src/jogl/classes/javax/media/opengl/GLRunnable.java b/src/jogl/classes/javax/media/opengl/GLRunnable.java
index 141d07c..1ae1c9b 100644
--- a/src/jogl/classes/javax/media/opengl/GLRunnable.java
+++ b/src/jogl/classes/javax/media/opengl/GLRunnable.java
@@ -30,23 +30,28 @@ package javax.media.opengl;
/**
* <p>
- * Declares one-shot OpenGL commands usable for injection into a {@link GLAutoDrawable},<br>
+ * Declares a one-shot OpenGL command usable for injection
* via {@link GLAutoDrawable#invoke(boolean, javax.media.opengl.GLRunnable)}.<br>
- * {@link GLAutoDrawable} executes these commands within it's {@link GLAutoDrawable#display()}
- * method while the OpenGL context is current.<br>
+ * {@link GLAutoDrawable} executes the GLRunnables within it's {@link GLAutoDrawable#display() display()}
+ * method after all registered {@link GLEventListener}s
+ * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)}
+ * methods has been called.
+ * </p>
+ * <p>
+ * The OpenGL context is current while executing the GLRunnable.
+ * </p>
* <p>
* This might be useful to inject OpenGL commands from an I/O event listener.
+ * </p>
*/
public interface GLRunnable {
/**
- * Initiate one-shot OpenGL commands with a valid current context,
- * processed by {@link GLAutoDrawable#display()}, enqueued by
- * {@link GLAutoDrawable#invoke(boolean, GLRunnable)}.
- *
* @param drawable the associated drawable and current context for this call
- * @return true if the GL [back] framebuffer remain intact by this runnable, otherwise false.
- * If returning false and hence the impl signals an invalidated back buffer,
- * another {@link GLEventListener#display(GLAutoDrawable)} call will be issued.
+ * @return true if the GL [back] framebuffer remains intact by this runnable, otherwise false.
+ * If returning false {@link GLAutoDrawable} will call
+ * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)}
+ * of all registered {@link GLEventListener}s once more.
+ * @see GLRunnable
*/
boolean run(GLAutoDrawable drawable);
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index a8d3c03..0a75865 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -66,7 +66,6 @@ import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode;
import javax.media.opengl.GL;
import javax.media.opengl.GLAnimatorControl;
@@ -92,6 +91,7 @@ import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol;
import com.jogamp.nativewindow.awt.JAWTWindow;
import com.jogamp.opengl.JoglVersion;
+import jogamp.common.awt.AWTEDTExecutor;
import jogamp.opengl.Debug;
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableHelper;
@@ -541,7 +541,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
try {
drawable = GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow);
context = (GLContextImpl) drawable.createContext(shareWith);
- context.setSynchronized(true);
context.setContextCreationFlags(additionalCtxCreationFlags);
} finally {
jawtWindow.unlockSurface();
@@ -551,10 +550,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
private boolean validateGLDrawable() {
boolean realized = false;
if (!Beans.isDesignTime()) {
- if ( null != drawable ) {
+ if ( null != drawable ) { // OK: drawable is volatile
realized = drawable.isRealized();
if ( !realized && 0 < drawable.getWidth() * drawable.getHeight() ) {
- drawable.setRealized(true);
+ // make sure drawable realization happens on AWT EDT, due to AWTTree lock
+ AWTEDTExecutor.singleton.invoke(true, setRealizedOnEventDispatchThreadAction);
realized = true;
sendReshape=true; // ensure a reshape is being send ..
if(DEBUG) {
@@ -566,6 +566,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
}
return realized;
}
+ private Runnable setRealizedOnEventDispatchThreadAction = new Runnable() {
+ public void run() {
+ drawable.setRealized(true);
+ } };
/** <p>Overridden to track when this component is removed from a
container. Subclasses which override this method must call
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index db3f189..167b993 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -974,7 +974,6 @@ public void reshape(int x, int y, int width, int height) {
Math.max(1, panelHeight));
offscreenDrawable.setRealized(true);
offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith);
- offscreenContext.setSynchronized(true);
offscreenContext.setContextCreationFlags(additionalCtxCreationFlags);
isInitialized = true;
@@ -1600,7 +1599,6 @@ public void reshape(int x, int y, int width, int height) {
if (factory.canCreateExternalGLDrawable(device)) {
joglDrawable = factory.createExternalGLDrawable();
joglContext = joglDrawable.createContext(j2dContext);
- joglContext.setSynchronized(true);
if (DEBUG) {
System.err.println("-- Created External Drawable: "+joglDrawable);
System.err.println("-- Created Context: "+joglContext);
@@ -1608,7 +1606,6 @@ public void reshape(int x, int y, int width, int height) {
} else if (factory.canCreateContextOnJava2DSurface(device)) {
// Mac OS X code path
joglContext = factory.createContextOnJava2DSurface(g, j2dContext);
- joglContext.setSynchronized(true);
if (DEBUG) {
System.err.println("-- Created Context: "+joglContext);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java
index e73b0cb..1f59b58 100755
--- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java
@@ -1,74 +1,74 @@
-/**
- * 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 jogamp.graph.curve.opengl;
-
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.GLRegion;
-
-/** RegionFactory to create a Context specific Region implementation.
- *
- * @see GLRegion
- */
-public class RegionFactory {
-
- /**
- * Create a Region using the passed render mode
- *
- * <p> In case {@link Region#VBAA_RENDERING_BIT} is being requested the default texture unit
- * {@link Region#TWO_PASS_DEFAULT_TEXTURE_UNIT} is being used.</p>
- *
- * @param rs the RenderState to be used
- * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT}
- */
- public static GLRegion create(int renderModes) {
- if( 0 != ( Region.VBAA_RENDERING_BIT & renderModes ) ){
- return new VBORegion2PES2(renderModes, Region.TWO_PASS_DEFAULT_TEXTURE_UNIT);
- }
- else{
- return new VBORegionSPES2(renderModes);
- }
- }
-
- /** Create a Single Pass Region using the passed render mode
- * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT},
- * {@link Region#VBAA_RENDERING_BIT}
- * @return
- */
- public static GLRegion createSinglePass(int renderModes) {
- return new VBORegionSPES2(renderModes);
- }
-
- /** Create a Two Pass (VBAA) Region using the passed render mode
- * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT},
- * {@link Region#VBAA_RENDERING_BIT}
- * @return
- */
- public static GLRegion createTwoPass(int renderModes, int textureUnit) {
- return new VBORegion2PES2(renderModes, textureUnit);
- }
-}
+/**
+ * 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 jogamp.graph.curve.opengl;
+
+import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.GLRegion;
+
+/** RegionFactory to create a Context specific Region implementation.
+ *
+ * @see GLRegion
+ */
+public class RegionFactory {
+
+ /**
+ * Create a Region using the passed render mode
+ *
+ * <p> In case {@link Region#VBAA_RENDERING_BIT} is being requested the default texture unit
+ * {@link Region#TWO_PASS_DEFAULT_TEXTURE_UNIT} is being used.</p>
+ *
+ * @param rs the RenderState to be used
+ * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT}
+ */
+ public static GLRegion create(int renderModes) {
+ if( 0 != ( Region.VBAA_RENDERING_BIT & renderModes ) ){
+ return new VBORegion2PES2(renderModes, Region.TWO_PASS_DEFAULT_TEXTURE_UNIT);
+ }
+ else{
+ return new VBORegionSPES2(renderModes);
+ }
+ }
+
+ /** Create a Single Pass Region using the passed render mode
+ * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT},
+ * {@link Region#VBAA_RENDERING_BIT}
+ * @return
+ */
+ public static GLRegion createSinglePass(int renderModes) {
+ return new VBORegionSPES2(renderModes);
+ }
+
+ /** Create a Two Pass (VBAA) Region using the passed render mode
+ * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT},
+ * {@link Region#VBAA_RENDERING_BIT}
+ * @return
+ */
+ public static GLRegion createTwoPass(int renderModes, int textureUnit) {
+ return new VBORegion2PES2(renderModes, textureUnit);
+ }
+}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
index 117faaf..c34d1cb 100755
--- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java
@@ -1,93 +1,93 @@
-/**
- * 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 jogamp.graph.curve.opengl;
-
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLException;
-
-import jogamp.graph.curve.opengl.shader.AttributeNames;
-
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.GLRegion;
-import com.jogamp.graph.curve.opengl.RegionRenderer;
-import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.opengl.util.glsl.ShaderCode;
-import com.jogamp.opengl.util.glsl.ShaderProgram;
-import com.jogamp.opengl.util.glsl.ShaderState;
-
-public class RegionRendererImpl01 extends RegionRenderer {
- public RegionRendererImpl01(RenderState rs, int renderModes) {
- super(rs, renderModes);
-
- }
-
- @Override
- protected String getFragmentShaderName(GL2ES2 gl) {
- final String type = Region.isNonUniformWeight(renderModes) ? "02" : "01" ;
- final String pass = Region.isVBAA(renderModes) ? "b" : "a" ;
- return "curverenderer" + type + pass + getShaderGLVersionSuffix(gl);
- }
-
- protected boolean initShaderProgram(GL2ES2 gl) {
- final ShaderState st = rs.getShaderState();
-
- ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader",
- "shader/bin", getVertexShaderName(gl), false);
- ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader",
- "shader/bin", getFragmentShaderName(gl), false);
-
- ShaderProgram sp = new ShaderProgram();
- sp.add(rsVp);
- sp.add(rsFp);
-
- sp.init(gl);
- st.attachShaderProgram(gl, sp, false);
- st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME);
- st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME);
-
- if(!sp.link(gl, System.err)) {
- throw new GLException("RegionRenderer: Couldn't link program: "+sp);
- }
- st.useProgram(gl, true);
-
- if(DEBUG) {
- System.err.println("RegionRendererImpl01 initialized: " + Thread.currentThread()+" "+st);
- }
- return true;
- }
-
- @Override
- protected void destroyImpl(GL2ES2 gl) {
- super.destroyImpl(gl);
- }
-
- @Override
- protected void drawImpl(GL2ES2 gl, Region region, float[] position, int[] texSize) {
- ((GLRegion)region).draw(gl, rs, vp_width, vp_height, texSize);
- }
-}
+/**
+ * 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 jogamp.graph.curve.opengl;
+
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLException;
+
+import jogamp.graph.curve.opengl.shader.AttributeNames;
+
+import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.GLRegion;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+public class RegionRendererImpl01 extends RegionRenderer {
+ public RegionRendererImpl01(RenderState rs, int renderModes) {
+ super(rs, renderModes);
+
+ }
+
+ @Override
+ protected String getFragmentShaderName(GL2ES2 gl) {
+ final String type = Region.isNonUniformWeight(renderModes) ? "02" : "01" ;
+ final String pass = Region.isVBAA(renderModes) ? "b" : "a" ;
+ return "curverenderer" + type + pass + getShaderGLVersionSuffix(gl);
+ }
+
+ protected boolean initShaderProgram(GL2ES2 gl) {
+ final ShaderState st = rs.getShaderState();
+
+ ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader",
+ "shader/bin", getVertexShaderName(gl), false);
+ ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader",
+ "shader/bin", getFragmentShaderName(gl), false);
+
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(rsVp);
+ sp.add(rsFp);
+
+ sp.init(gl);
+ st.attachShaderProgram(gl, sp, false);
+ st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME);
+ st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME);
+
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("RegionRenderer: Couldn't link program: "+sp);
+ }
+ st.useProgram(gl, true);
+
+ if(DEBUG) {
+ System.err.println("RegionRendererImpl01 initialized: " + Thread.currentThread()+" "+st);
+ }
+ return true;
+ }
+
+ @Override
+ protected void destroyImpl(GL2ES2 gl) {
+ super.destroyImpl(gl);
+ }
+
+ @Override
+ protected void drawImpl(GL2ES2 gl, Region region, float[] position, int[] texSize) {
+ ((GLRegion)region).draw(gl, rs, vp_width, vp_height, texSize);
+ }
+}
diff --git a/src/jogl/classes/jogamp/graph/font/FontInt.java b/src/jogl/classes/jogamp/graph/font/FontInt.java
index 37660bb..20e1ec0 100644
--- a/src/jogl/classes/jogamp/graph/font/FontInt.java
+++ b/src/jogl/classes/jogamp/graph/font/FontInt.java
@@ -38,13 +38,7 @@ import com.jogamp.graph.geom.Vertex.Factory;
public interface FontInt extends Font {
- public interface Glyph extends Font.Glyph {
- // reserved special glyph IDs
- // http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08#ba57949e
- public static final int ID_UNKNOWN = 0;
- public static final int ID_CR = 2;
- public static final int ID_SPACE = 3;
-
+ public interface GlyphInt extends Font.Glyph {
public Path2D getPath(); // unscaled path
public Path2D getPath(float pixelSize);
}
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 8806f53..8e465de 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -44,6 +44,7 @@ import com.jogamp.common.util.IntObjectHashMap;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.font.Font.Glyph;
import com.jogamp.graph.geom.AABBox;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
@@ -162,6 +163,10 @@ class TypecastFont implements FontInt {
return sb;
}
+ public float getAdvanceWidth(int i, float pixelSize) {
+ return font.getHmtxTable().getAdvanceWidth(i) * metrics.getScale(pixelSize);
+ }
+
public Metrics getMetrics() {
if (metrics == null) {
metrics = new TypecastHMetrics(this);
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
index e8b62bd..0f762e7 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java
@@ -71,7 +71,7 @@ public class TypecastFontConstructor implements FontConstructor {
int len=0;
Font f = null;
try {
- tf = IOUtil.createTempFile( "joglfont", ".ttf", null);
+ tf = IOUtil.createTempFile( "jogl.font", ".ttf", false, null);
len = IOUtil.copyURLConn2File(fconn, tf);
if(len==0) {
tf.delete();
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
index f20b7d1..a1f1a32 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
@@ -36,7 +36,7 @@ import jogamp.graph.geom.plane.Path2D;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.geom.AABBox;
-public class TypecastGlyph implements FontInt.Glyph {
+public class TypecastGlyph implements FontInt.GlyphInt {
public class Advance
{
final Font font;
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
index b3ee9c9..f155345 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
@@ -1,220 +1,222 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.graph.font.typecast;
-
-import java.util.ArrayList;
-
-import jogamp.graph.font.typecast.ot.OTGlyph;
-import jogamp.graph.font.typecast.ot.Point;
-import jogamp.graph.geom.plane.AffineTransform;
-import jogamp.graph.geom.plane.Path2D;
-import jogamp.graph.geom.plane.PathIterator;
-
-import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.font.Font;
-import com.jogamp.graph.geom.Vertex;
-import com.jogamp.graph.geom.Vertex.Factory;
-
-/**
- * Factory to build a {@link com.jogamp.graph.geom.Path2D Path2D} from
- * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}s.
- */
-public class TypecastRenderer {
-
- private static void getPaths(TypecastFont font,
- CharSequence string, float pixelSize, AffineTransform transform, Path2D[] p)
- {
- if (string == null) {
- return;
- }
- Font.Metrics metrics = font.getMetrics();
- float advanceTotal = 0;
- float lineGap = metrics.getLineGap(pixelSize) ;
- float ascent = metrics.getAscent(pixelSize) ;
- float descent = metrics.getDescent(pixelSize) ;
- if (transform == null) {
- transform = new AffineTransform();
- }
- AffineTransform t = new AffineTransform();
-
- float advanceY = lineGap - descent + ascent;
- float y = 0;
- for (int i=0; i<string.length(); i++)
- {
- p[i] = new Path2D();
- p[i].reset();
- t.setTransform(transform);
- char character = string.charAt(i);
- if (character == '\n') {
- y += advanceY;
- advanceTotal = 0;
- continue;
- } else if (character == ' ') {
- advanceTotal += font.font.getHmtxTable().getAdvanceWidth(TypecastGlyph.ID_SPACE) * metrics.getScale(pixelSize);
- continue;
- }
- TypecastGlyph glyph = (TypecastGlyph) font.getGlyph(character);
- Path2D gp = glyph.getPath();
- float scale = metrics.getScale(pixelSize);
- t.translate(advanceTotal, y);
- t.scale(scale, scale);
- p[i].append(gp.iterator(t), false);
- advanceTotal += glyph.getAdvance(pixelSize, true);
- }
- }
-
- public static ArrayList<OutlineShape> getOutlineShapes(TypecastFont font, CharSequence string, float pixelSize, AffineTransform transform, Factory<? extends Vertex> vertexFactory) {
- Path2D[] paths = new Path2D[string.length()];
- getPaths(font, string, pixelSize, transform, paths);
-
- ArrayList<OutlineShape> shapes = new ArrayList<OutlineShape>();
- final int numGlyps = paths.length;
- for (int index=0;index<numGlyps;index++) {
- if(paths[index] == null){
- continue;
- }
- OutlineShape shape = new OutlineShape(vertexFactory);
- shapes.add(shape);
- PathIterator iterator = paths[index].iterator(transform);
- if(null != iterator){
- while(!iterator.isDone()){
- float[] coords = new float[6];
- int segmentType = iterator.currentSegment(coords);
- addPathVertexToOutline(shape, vertexFactory, coords, segmentType);
- iterator.next();
- }
- }
- }
- return shapes;
- }
- private static void addPathVertexToOutline(OutlineShape shape, Factory<? extends Vertex> vertexFactory, float[] coords, int segmentType){
- switch(segmentType) {
- case PathIterator.SEG_MOVETO:
- shape.closeLastOutline();
- shape.addEmptyOutline();
- shape.addVertex(0, vertexFactory.create(coords, 0, 2, true));
- break;
- case PathIterator.SEG_LINETO:
- shape.addVertex(0, vertexFactory.create(coords, 0, 2, true));
- break;
- case PathIterator.SEG_QUADTO:
- shape.addVertex(0, vertexFactory.create(coords, 0, 2, false));
- shape.addVertex(0, vertexFactory.create(coords, 2, 2, true));
- break;
- case PathIterator.SEG_CUBICTO:
- shape.addVertex(0, vertexFactory.create(coords, 0, 2, false));
- shape.addVertex(0, vertexFactory.create(coords, 2, 2, false));
- shape.addVertex(0, vertexFactory.create(coords, 4, 2, true));
- break;
- case PathIterator.SEG_CLOSE:
- shape.closeLastOutline();
- break;
- default:
- throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType);
- }
- }
-
- /**
- * Build a {@link com.jogamp.graph.geom.Path2D Path2D} from a
- * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}. This glyph path can then
- * be transformed and rendered.
- */
- public static Path2D buildPath(OTGlyph glyph) {
-
- if (glyph == null) {
- return null;
- }
-
- Path2D glyphPath = new Path2D();
-
- // Iterate through all of the points in the glyph. Each time we find a
- // contour end point, add the point range to the path.
- int firstIndex = 0;
- int count = 0;
- for (int i = 0; i < glyph.getPointCount(); i++) {
- count++;
- if (glyph.getPoint(i).endOfContour) {
- addContourToPath(glyphPath, glyph, firstIndex, count);
- firstIndex = i + 1;
- count = 0;
- }
- }
- return glyphPath;
- }
-
- private static void addContourToPath(Path2D gp, OTGlyph glyph, int startIndex, int count) {
- int offset = 0;
- while (offset < count) {
- Point point = glyph.getPoint(startIndex + offset%count);
- Point point_plus1 = glyph.getPoint(startIndex + (offset+1)%count);
- Point point_plus2 = glyph.getPoint(startIndex + (offset+2)%count);
- if(offset == 0)
- {
- gp.moveTo(point.x, point.y);
- }
-
- if (point.onCurve) {
- if (point_plus1.onCurve) {
- // s = new Line2D.Float(point.x, point.y, point_plus1.x, point_plus1.y);
- gp.lineTo( point_plus1.x, point_plus1.y );
- offset++;
- } else {
- if (point_plus2.onCurve) {
- // s = new QuadCurve2D.Float( point.x, point.y, point_plus1.x, point_plus1.y, point_plus2.x, point_plus2.y);
- gp.quadTo(point_plus1.x, point_plus1.y, point_plus2.x, point_plus2.y);
- offset+=2;
- } else {
- // s = new QuadCurve2D.Float(point.x,point.y,point_plus1.x,point_plus1.y,
- // midValue(point_plus1.x, point_plus2.x), midValue(point_plus1.y, point_plus2.y));
- gp.quadTo(point_plus1.x, point_plus1.y, midValue(point_plus1.x, point_plus2.x), midValue(point_plus1.y, point_plus2.y));
- offset+=2;
- }
- }
- } else {
- if (point_plus1.onCurve) {
- // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), midValue(point_minus1.y, point.y),
- // point.x, point.y, point_plus1.x, point_plus1.y);
- //gp.curve3(point_plus1.x, point_plus1.y, point.x, point.y);
- gp.quadTo(point.x, point.y, point_plus1.x, point_plus1.y);
- offset++;
-
- } else {
- // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), midValue(point_minus1.y, point.y), point.x, point.y,
- // midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y));
- //gp.curve3(midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y), point.x, point.y);
- gp.quadTo(point.x, point.y, midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y));
- offset++;
- }
- }
- }
- }
-
- private static int midValue(int a, int b) {
- return a + (b - a)/2;
- }
-}
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package jogamp.graph.font.typecast;
+
+import java.util.ArrayList;
+
+import jogamp.graph.font.FontInt.GlyphInt;
+import jogamp.graph.font.typecast.ot.OTGlyph;
+import jogamp.graph.font.typecast.ot.Point;
+import jogamp.graph.geom.plane.AffineTransform;
+import jogamp.graph.geom.plane.Path2D;
+import jogamp.graph.geom.plane.PathIterator;
+
+import com.jogamp.graph.curve.OutlineShape;
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.Font.Glyph;
+import com.jogamp.graph.geom.Vertex;
+import com.jogamp.graph.geom.Vertex.Factory;
+
+/**
+ * Factory to build a {@link com.jogamp.graph.geom.Path2D Path2D} from
+ * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}s.
+ */
+public class TypecastRenderer {
+
+ private static void getPaths(TypecastFont font,
+ CharSequence string, float pixelSize, AffineTransform transform, Path2D[] p)
+ {
+ if (string == null) {
+ return;
+ }
+ Font.Metrics metrics = font.getMetrics();
+ float advanceTotal = 0;
+ float lineGap = metrics.getLineGap(pixelSize) ;
+ float ascent = metrics.getAscent(pixelSize) ;
+ float descent = metrics.getDescent(pixelSize) ;
+ if (transform == null) {
+ transform = new AffineTransform();
+ }
+ AffineTransform t = new AffineTransform();
+
+ float advanceY = lineGap - descent + ascent;
+ float y = 0;
+ for (int i=0; i<string.length(); i++)
+ {
+ p[i] = new Path2D();
+ p[i].reset();
+ t.setTransform(transform);
+ char character = string.charAt(i);
+ if (character == '\n') {
+ y += advanceY;
+ advanceTotal = 0;
+ continue;
+ } else if (character == ' ') {
+ advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, pixelSize);
+ continue;
+ }
+ Glyph glyph = font.getGlyph(character);
+ Path2D gp = ((GlyphInt)glyph).getPath();
+ float scale = metrics.getScale(pixelSize);
+ t.translate(advanceTotal, y);
+ t.scale(scale, scale);
+ p[i].append(gp.iterator(t), false);
+ advanceTotal += glyph.getAdvance(pixelSize, true);
+ }
+ }
+
+ public static ArrayList<OutlineShape> getOutlineShapes(TypecastFont font, CharSequence string, float pixelSize, AffineTransform transform, Factory<? extends Vertex> vertexFactory) {
+ Path2D[] paths = new Path2D[string.length()];
+ getPaths(font, string, pixelSize, transform, paths);
+
+ ArrayList<OutlineShape> shapes = new ArrayList<OutlineShape>();
+ final int numGlyps = paths.length;
+ for (int index=0;index<numGlyps;index++) {
+ if(paths[index] == null){
+ continue;
+ }
+ OutlineShape shape = new OutlineShape(vertexFactory);
+ shapes.add(shape);
+ PathIterator iterator = paths[index].iterator(transform);
+ if(null != iterator){
+ while(!iterator.isDone()){
+ float[] coords = new float[6];
+ int segmentType = iterator.currentSegment(coords);
+ addPathVertexToOutline(shape, vertexFactory, coords, segmentType);
+ iterator.next();
+ }
+ }
+ }
+ return shapes;
+ }
+ private static void addPathVertexToOutline(OutlineShape shape, Factory<? extends Vertex> vertexFactory, float[] coords, int segmentType){
+ switch(segmentType) {
+ case PathIterator.SEG_MOVETO:
+ shape.closeLastOutline();
+ shape.addEmptyOutline();
+ shape.addVertex(0, vertexFactory.create(coords, 0, 2, true));
+ break;
+ case PathIterator.SEG_LINETO:
+ shape.addVertex(0, vertexFactory.create(coords, 0, 2, true));
+ break;
+ case PathIterator.SEG_QUADTO:
+ shape.addVertex(0, vertexFactory.create(coords, 0, 2, false));
+ shape.addVertex(0, vertexFactory.create(coords, 2, 2, true));
+ break;
+ case PathIterator.SEG_CUBICTO:
+ shape.addVertex(0, vertexFactory.create(coords, 0, 2, false));
+ shape.addVertex(0, vertexFactory.create(coords, 2, 2, false));
+ shape.addVertex(0, vertexFactory.create(coords, 4, 2, true));
+ break;
+ case PathIterator.SEG_CLOSE:
+ shape.closeLastOutline();
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType);
+ }
+ }
+
+ /**
+ * Build a {@link com.jogamp.graph.geom.Path2D Path2D} from a
+ * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}. This glyph path can then
+ * be transformed and rendered.
+ */
+ public static Path2D buildPath(OTGlyph glyph) {
+
+ if (glyph == null) {
+ return null;
+ }
+
+ Path2D glyphPath = new Path2D();
+
+ // Iterate through all of the points in the glyph. Each time we find a
+ // contour end point, add the point range to the path.
+ int firstIndex = 0;
+ int count = 0;
+ for (int i = 0; i < glyph.getPointCount(); i++) {
+ count++;
+ if (glyph.getPoint(i).endOfContour) {
+ addContourToPath(glyphPath, glyph, firstIndex, count);
+ firstIndex = i + 1;
+ count = 0;
+ }
+ }
+ return glyphPath;
+ }
+
+ private static void addContourToPath(Path2D gp, OTGlyph glyph, int startIndex, int count) {
+ int offset = 0;
+ while (offset < count) {
+ Point point = glyph.getPoint(startIndex + offset%count);
+ Point point_plus1 = glyph.getPoint(startIndex + (offset+1)%count);
+ Point point_plus2 = glyph.getPoint(startIndex + (offset+2)%count);
+ if(offset == 0)
+ {
+ gp.moveTo(point.x, point.y);
+ }
+
+ if (point.onCurve) {
+ if (point_plus1.onCurve) {
+ // s = new Line2D.Float(point.x, point.y, point_plus1.x, point_plus1.y);
+ gp.lineTo( point_plus1.x, point_plus1.y );
+ offset++;
+ } else {
+ if (point_plus2.onCurve) {
+ // s = new QuadCurve2D.Float( point.x, point.y, point_plus1.x, point_plus1.y, point_plus2.x, point_plus2.y);
+ gp.quadTo(point_plus1.x, point_plus1.y, point_plus2.x, point_plus2.y);
+ offset+=2;
+ } else {
+ // s = new QuadCurve2D.Float(point.x,point.y,point_plus1.x,point_plus1.y,
+ // midValue(point_plus1.x, point_plus2.x), midValue(point_plus1.y, point_plus2.y));
+ gp.quadTo(point_plus1.x, point_plus1.y, midValue(point_plus1.x, point_plus2.x), midValue(point_plus1.y, point_plus2.y));
+ offset+=2;
+ }
+ }
+ } else {
+ if (point_plus1.onCurve) {
+ // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), midValue(point_minus1.y, point.y),
+ // point.x, point.y, point_plus1.x, point_plus1.y);
+ //gp.curve3(point_plus1.x, point_plus1.y, point.x, point.y);
+ gp.quadTo(point.x, point.y, point_plus1.x, point_plus1.y);
+ offset++;
+
+ } else {
+ // s = new QuadCurve2D.Float(midValue(point_minus1.x, point.x), midValue(point_minus1.y, point.y), point.x, point.y,
+ // midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y));
+ //gp.curve3(midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y), point.x, point.y);
+ gp.quadTo(point.x, point.y, midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y));
+ offset++;
+ }
+ }
+ }
+ }
+
+ private static int midValue(int a, int b) {
+ return a + (b - a)/2;
+ }
+}
diff --git a/src/jogl/classes/jogamp/graph/math/MathFloat.java b/src/jogl/classes/jogamp/graph/math/MathFloat.java
index 0b8d69e..82e7823 100644
--- a/src/jogl/classes/jogamp/graph/math/MathFloat.java
+++ b/src/jogl/classes/jogamp/graph/math/MathFloat.java
@@ -1,45 +1,45 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.graph.math;
-
-public class MathFloat {
-
- public static final float E = 2.7182818284590452354f;
-
- public static final float PI = 3.14159265358979323846f;
-
- public static float abs(float a) { return (float) java.lang.Math.abs(a); }
- public static float pow(float a, float b) { return (float) java.lang.Math.pow(a, b); }
-
- public static float sin(float a) { return (float) java.lang.Math.sin(a); }
- public static float cos(float a) { return (float) java.lang.Math.cos(a); }
- public static float acos(float a) { return (float) java.lang.Math.acos(a); }
-
- public static float sqrt(float a) { return (float) java.lang.Math.sqrt(a); }
-
-}
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package jogamp.graph.math;
+
+public class MathFloat {
+
+ public static final float E = 2.7182818284590452354f;
+
+ public static final float PI = 3.14159265358979323846f;
+
+ public static float abs(float a) { return (float) java.lang.Math.abs(a); }
+ public static float pow(float a, float b) { return (float) java.lang.Math.pow(a, b); }
+
+ public static float sin(float a) { return (float) java.lang.Math.sin(a); }
+ public static float cos(float a) { return (float) java.lang.Math.cos(a); }
+ public static float acos(float a) { return (float) java.lang.Math.acos(a); }
+
+ public static float sqrt(float a) { return (float) java.lang.Math.sqrt(a); }
+
+}
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index f348564..51201b3 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -214,31 +214,6 @@ public abstract class GLContextImpl extends GLContext {
*/
protected void drawableUpdatedNotify() throws GLException { }
- volatile boolean lockFailFast = true;
-
- public boolean isSynchronized() {
- return !lockFailFast; // volatile: ok
- }
-
- public void setSynchronized(boolean isSynchronized) {
- lockFailFast = !isSynchronized; // volatile: ok
- }
-
- private final void lockConsiderFailFast() {
- if( lockFailFast ) { // volatile: ok
- try {
- if( !lock.tryLock(0) ) { // immediate return w/ false, if lock is already held by other thread
- throw new GLException("Error: Attempt to make context current on thread " + Thread.currentThread().getName() +
- " which is already current on thread " + lock.getOwner().getName());
- }
- } catch (InterruptedException ie) {
- throw new GLException(ie);
- }
- } else {
- lock.lock();
- }
- }
-
public abstract Object getPlatformGLExtensions();
// Note: the surface is locked within [makeCurrent .. swap .. release]
@@ -274,13 +249,6 @@ public abstract class GLContextImpl extends GLContext {
protected abstract void releaseImpl() throws GLException;
public final void destroy() {
- // Must hold the lock around the destroy operation to make sure we
- // don't destroy the context out from under another thread rendering to it
- lockConsiderFailFast(); // holdCount++ -> 1 or 2
- try {
- if(lock.getHoldCount() > 2) {
- throw new GLException("XXX: "+lock);
- }
if (DEBUG || TRACE_SWITCH) {
System.err.println(getThreadName() + ": GLContextImpl.destroy.0: " + toHexString(contextHandle) +
", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
@@ -291,39 +259,47 @@ public abstract class GLContextImpl extends GLContext {
// this would be odd ..
throw new GLException("Surface not ready to lock: "+drawable);
}
- // release current context
- if(null != glDebugHandler) {
- if(lock.getHoldCount() == 1) {
- // needs current context to disable debug handler
- makeCurrent();
- }
- glDebugHandler.enable(false);
- }
- if(lock.getHoldCount() > 1) {
- // pending release() after makeCurrent()
- release(true);
- }
try {
- destroyImpl();
- contextHandle = 0;
- glDebugHandler = null;
- // this maybe impl. in a platform specific way to release remaining shared ctx.
- if(GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this)) {
- GLContextShareSet.unregisterSharing(this);
+ // Must hold the lock around the destroy operation to make sure we
+ // don't destroy the context while another thread renders to it.
+ // FIXME: This is actually impossible now, since we acquired the surface lock already,
+ // which is a prerequisite to acquire the context lock.
+ lock.lock(); // holdCount++ -> 1 or 2
+ if ( lock.getHoldCount() > 2 ) {
+ throw new GLException(getThreadName() + ": Lock was hold more than once - makeCurrent/release imbalance: "+lock);
+ }
+ try {
+ // release current context
+ if(null != glDebugHandler) {
+ if(lock.getHoldCount() == 1) {
+ // needs current context to disable debug handler
+ makeCurrent();
+ }
+ glDebugHandler.enable(false);
+ }
+ if(lock.getHoldCount() > 1) {
+ // pending release() after makeCurrent()
+ release(true);
+ }
+ destroyImpl();
+ contextHandle = 0;
+ glDebugHandler = null;
+ // this maybe impl. in a platform specific way to release remaining shared ctx.
+ if(GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this)) {
+ GLContextShareSet.unregisterSharing(this);
+ }
+ } finally {
+ lock.unlock();
+ if (TRACE_SWITCH) {
+ System.err.println(getThreadName() + ": GLContextImpl.destroy.X: " + toHexString(contextHandle) +
+ ", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
+ }
}
} finally {
drawable.unlockSurface();
}
}
- } finally {
- lock.unlock();
- if (TRACE_SWITCH) {
- System.err.println(getThreadName() + ": GLContextImpl.destroy.X: " + toHexString(contextHandle) +
- ", isShared "+GLContextShareSet.isShared(this)+" - "+lock);
- }
- }
-
- resetStates();
+ resetStates();
}
protected abstract void destroyImpl() throws GLException;
@@ -390,18 +366,20 @@ public abstract class GLContextImpl extends GLContext {
*/
public int makeCurrent() throws GLException {
boolean unlockContextAndDrawable = false;
- lockConsiderFailFast();
int res = CONTEXT_NOT_CURRENT;
+
+ // Note: the surface is locked within [makeCurrent .. swap .. release]
+ int lockRes = drawable.lockSurface();
+ if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
+ return CONTEXT_NOT_CURRENT;
+ }
try {
- // Note: the surface is locked within [makeCurrent .. swap .. release]
- int lockRes = drawable.lockSurface();
- if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) {
- return CONTEXT_NOT_CURRENT;
+ if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) {
+ drawable.updateHandle();
}
- try {
- if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) {
- drawable.updateHandle();
- }
+
+ lock.lock();
+ try {
// One context can only be current by one thread,
// and one thread can only have one context current!
final GLContext current = getCurrent();
@@ -437,7 +415,7 @@ public abstract class GLContextImpl extends GLContext {
throw e;
} finally {
if (unlockContextAndDrawable) {
- drawable.unlockSurface();
+ lock.unlock();
}
}
} catch (RuntimeException e) {
@@ -445,9 +423,10 @@ public abstract class GLContextImpl extends GLContext {
throw e;
} finally {
if (unlockContextAndDrawable) {
- lock.unlock();
+ drawable.unlockSurface();
}
}
+
if (res == CONTEXT_NOT_CURRENT) {
if(TRACE_SWITCH) {
System.err.println(getThreadName() +": GLContext.ContextSwitch: - switch - CONTEXT_NOT_CURRENT - "+lock);
diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
index 10d5a3f..0f4f7f8 100644
--- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java
@@ -85,7 +85,6 @@ public class GLPbufferImpl implements GLPbuffer {
}
this.pbufferDrawable = pbufferDrawable;
context = (GLContextImpl) pbufferDrawable.createContext(parentContext);
- context.setSynchronized(true);
}
public GLContext createContext(GLContext shareWith) {
diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java
index bce3f3c..ce8405f 100644
--- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java
+++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java
@@ -615,7 +615,7 @@ public class ProjectFloat {
float[] in = this.in;
float[] out = this.out;
- FloatUtil.multMatrixf(modelMatrix, modelMatrix_offset, projMatrix, projMatrix_offset, matrix, 0);
+ FloatUtil.multMatrixf(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, matrix, 0);
if (!gluInvertMatrixf(matrix, 0, matrix, 0)) {
return false;
@@ -659,7 +659,7 @@ public class ProjectFloat {
FloatBuffer in = this.inBuf;
FloatBuffer out = this.outBuf;
- FloatUtil.multMatrixf(modelMatrix, projMatrix, matrixBuf);
+ FloatUtil.multMatrixf(projMatrix, modelMatrix, matrixBuf);
if (!gluInvertMatrixf(matrixBuf, matrixBuf)) {
return false;
@@ -715,7 +715,7 @@ public class ProjectFloat {
FloatBuffer in = this.inBuf;
FloatBuffer out = this.outBuf;
- FloatUtil.multMatrixf(modelMatrix, projMatrix, matrixBuf);
+ FloatUtil.multMatrixf(projMatrix, modelMatrix, matrixBuf);
if (!gluInvertMatrixf(matrixBuf, matrixBuf)) {
return false;
@@ -786,7 +786,7 @@ public class ProjectFloat {
float[] in = this.in;
float[] out = this.out;
- FloatUtil.multMatrixf(modelMatrix, modelMatrix_offset, projMatrix, projMatrix_offset, matrix, 0);
+ FloatUtil.multMatrixf(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, matrix, 0);
if (!gluInvertMatrixf(matrix, 0, matrix, 0))
return false;
@@ -847,7 +847,7 @@ public class ProjectFloat {
FloatBuffer in = this.inBuf;
FloatBuffer out = this.outBuf;
- FloatUtil.multMatrixf(modelMatrix, projMatrix, matrixBuf);
+ FloatUtil.multMatrixf(projMatrix, modelMatrix, matrixBuf);
if (!gluInvertMatrixf(matrixBuf, matrixBuf))
return false;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index b696e1b..71c0d55 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -221,7 +221,6 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
drawable.setRealized(true);
final GLContext context = drawable.createContext(null);
if (null != context) {
- context.setSynchronized(true);
try {
context.makeCurrent(); // could cause exception
madeCurrent = context.isCurrent();
diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
index 3d740d6..cd48c39 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
@@ -110,7 +110,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl {
@Override
protected void initGLStreamImpl(GL gl, int[] texNames) throws IOException {
try {
- URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader());
+ URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
if(null != urlConn) {
texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG);
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index f4069d4..494bb30 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -307,7 +307,6 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
if (null == sharedContext) {
throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable);
}
- sharedContext.setSynchronized(true);
boolean hasARBPixelFormat;
boolean hasARBMultisample;
boolean hasARBPBuffer;
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 223c504..092d343 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -245,7 +245,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
if (null == sharedContext) {
throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable);
}
- sharedContext.setSynchronized(true);
boolean madeCurrent = false;
sharedContext.makeCurrent();
try {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
index be41ad7..99bc71c 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java
@@ -46,7 +46,7 @@ public class NWJNILibLoader extends JNILibLoaderBase {
if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) {
addNativeJarLibs(NWJNILibLoader.class, "jogl-all", new String[] { "nativewindow" } );
}
- return new Boolean(loadLibrary(libName, false));
+ return new Boolean(loadLibrary(libName, false, NWJNILibLoader.class.getClassLoader()));
}
}).booleanValue();
}
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java
index 354bb83..2377c2b 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java
@@ -62,7 +62,7 @@ public class JAWTJNILibLoader extends NWJNILibLoader {
// default library path
if ( ! NativeWindowFactory.TYPE_MACOSX.equals( NativeWindowFactory.getNativeWindowType(false) ) ) {
try {
- loadLibrary("jawt", null, true);
+ loadLibrary("jawt", null, true, JAWTJNILibLoader.class.getClassLoader());
} catch (Throwable t) {
// It might be ok .. if it's already loaded
if(DEBUG) {
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index f551fcc..61dbfb3 100644
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -58,11 +58,16 @@ public class NewtFactory {
public static Class<?> getCustomClass(String packageName, String classBaseName) {
Class<?> clazz = null;
- if(packageName!=null || classBaseName!=null) {
- String clazzName = packageName + "." + classBaseName ;
+ if(packageName!=null && classBaseName!=null) {
+ final String clazzName = packageName + "." + classBaseName ;
try {
clazz = Class.forName(clazzName);
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("Warning: Failed to find class <"+clazzName+">: "+t.getMessage());
+ t.printStackTrace();
+ }
+ }
}
return clazz;
}
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 34e0df6..f891937 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -421,7 +421,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
}
drawable.setRealized(true);
context = drawable.createContext(sharedContext);
- context.setSynchronized(true);
context.setContextCreationFlags(additionalCtxCreationFlags);
}
if(Window.DEBUG_IMPLEMENTATION) {
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java
index f2f3513..a0bbcc2 100644
--- a/src/newt/classes/jogamp/newt/DisplayImpl.java
+++ b/src/newt/classes/jogamp/newt/DisplayImpl.java
@@ -70,6 +70,9 @@ public abstract class DisplayImpl extends Display {
throw new RuntimeException("Unknown display type \"" + type + "\"");
}
}
+ if(null==displayClass) {
+ throw new ClassNotFoundException("Failed to find NEWT Display Class <"+type+".Display>");
+ }
return displayClass;
}
diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java
index 78707e7..2db9d8d 100644
--- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java
+++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java
@@ -56,7 +56,7 @@ public class NEWTJNILibLoader extends JNILibLoaderBase {
if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) {
addNativeJarLibs(NEWTJNILibLoader.class, "jogl-all", new String[] { "nativewindow", "newt" } );
}
- loadLibrary(libName, false);
+ loadLibrary(libName, false, NEWTJNILibLoader.class.getClassLoader());
return null;
}
});
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index 72f1b5a..cf614b6 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -111,6 +111,9 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
throw new RuntimeException("Unknown window type \"" + type + "\"");
}
}
+ if(null==screenClass) {
+ throw new ClassNotFoundException("Failed to find NEWT Screen Class <"+type+".Screen>");
+ }
return (Class<? extends Screen>)screenClass;
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 143e7c1..074f635 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -170,6 +170,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
throw new NativeWindowException("Unknown window type \"" + type + "\"");
}
}
+ if(null==windowClass) {
+ throw new ClassNotFoundException("Failed to find NEWT Window Class <"+type+".Window>");
+ }
return windowClass;
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
index d379017..36b8333 100644
--- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java
@@ -27,33 +27,78 @@
*/
package jogamp.newt.driver.android;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.VersionUtil;
+import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.JoglVersion;
import android.os.Bundle;
import android.util.Log;
+import android.view.Gravity;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.ScrollView;
import android.widget.TextView;
public class NewtVersionActivity extends NewtBaseActivity {
- TextView tv = null;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- System.setProperty("nativewindow.debug", "all");
- System.setProperty("jogl.debug", "all");
- System.setProperty("newt.debug", "all");
- System.setProperty("jogamp.debug.JNILibLoader", "true");
- System.setProperty("jogamp.debug.NativeLibrary", "true");
- // System.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
+ setFullscreenFeature(getWindow(), true);
+
+ final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext());
+ getWindow().setContentView(viewGroup);
+
+ final TextView tv = new TextView(getActivity());
+ final ScrollView scroller = new ScrollView(getActivity());
+ scroller.addView(tv);
+ viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT));
- tv = new TextView(this);
tv.setText(VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE);
- setContentView(tv);
+
+ // create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
+ GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
+ GLWindow glWindow = GLWindow.create(caps);
+ glWindow.setUndecorated(true);
+ glWindow.setSize(32, 32);
+ glWindow.setPosition(0, 0);
+ final android.view.View androidGLView = ((AndroidWindow)glWindow.getDelegatedWindow()).getAndroidView();
+ viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT));
+ registerNEWTWindow(glWindow);
+
+ glWindow.addGLEventListener(new GLEventListener() {
+ public void init(GLAutoDrawable drawable) {
+ GL gl = drawable.getGL();
+ final StringBuffer sb = new StringBuffer();
+ sb.append(JoglVersion.getGLInfo(gl, null)).append(Platform.NEWLINE);
+ sb.append("Requested: ").append(Platform.NEWLINE);
+ sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE);
+ sb.append("Chosen: ").append(Platform.NEWLINE);
+ sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE);
+ viewGroup.post(new Runnable() {
+ public void run() {
+ tv.append(sb.toString());
+ viewGroup.removeView(androidGLView);
+ } } );
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ }
+ public void dispose(GLAutoDrawable drawable) {
+ }
+ });
+ glWindow.setVisible(true);
Log.d(MD.TAG, "onCreate - X");
}
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java
new file mode 100644
index 0000000..cb8799b
--- /dev/null
+++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java
@@ -0,0 +1,21 @@
+package jogamp.newt.driver.android;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+
+public class NewtVersionActivityLauncher extends Activity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity");
+ final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri);
+ Log.d(getClass().getSimpleName(), "Launching Activity: "+intent);
+ startActivity (intent);
+
+ finish(); // done
+ }
+}
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java
index 40d0ad2..f90c62f 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java
+++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2012 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,11 +34,13 @@
package jogamp.newt.driver.broadcom.egl;
-import jogamp.newt.*;
-import jogamp.opengl.egl.*;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeWindowException;
-import com.jogamp.nativewindow.egl.*;
+import jogamp.newt.NEWTJNILibLoader;
+import jogamp.opengl.egl.EGL;
+
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
public class Display extends jogamp.newt.DisplayImpl {
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
index 11b8dfc..0544bc0 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2012 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,7 +34,7 @@
package jogamp.newt.driver.broadcom.egl;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.Point;
diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
index bd63f83..ed1d051 100644
--- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
+++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2012 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,12 +34,15 @@
package jogamp.newt.driver.broadcom.egl;
-import jogamp.opengl.egl.*;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
import javax.media.opengl.GLCapabilitiesImmutable;
+import jogamp.opengl.egl.EGLGraphicsConfiguration;
+
public class Window extends jogamp.newt.WindowImpl {
static {
Display.initSingleton();
diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java b/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java
index ed8cb82..73bbe0b 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/KDDisplay.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2012 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,12 +34,15 @@
package jogamp.newt.driver.kd;
-import com.jogamp.nativewindow.egl.*;
-import com.jogamp.newt.*;
+import javax.media.nativewindow.AbstractGraphicsDevice;
+import javax.media.nativewindow.NativeWindowException;
-import jogamp.newt.*;
-import jogamp.opengl.egl.*;
-import javax.media.nativewindow.*;
+import jogamp.newt.DisplayImpl;
+import jogamp.newt.NEWTJNILibLoader;
+import jogamp.opengl.egl.EGL;
+import jogamp.opengl.egl.EGLDisplayUtil;
+
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
public class KDDisplay extends DisplayImpl {
diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java b/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
index 6b6aecb..ee34758 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/KDScreen.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2012 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,11 +34,12 @@
package jogamp.newt.driver.kd;
-import jogamp.newt.ScreenImpl;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.Point;
+import jogamp.newt.ScreenImpl;
+
public class KDScreen extends ScreenImpl {
static {
KDDisplay.initSingleton();
diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
index 8ae0b65..d34ffd5 100644
--- a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2012 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,13 +34,16 @@
package jogamp.newt.driver.kd;
-import jogamp.newt.*;
-import jogamp.opengl.egl.*;
-import javax.media.nativewindow.*;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
import javax.media.opengl.GLCapabilitiesImmutable;
+import jogamp.newt.WindowImpl;
+import jogamp.opengl.egl.EGLGraphicsConfiguration;
+
public class KDWindow extends WindowImpl {
private static final String WINDOW_CLASS_NAME = "NewtWindow";
diff --git a/src/test/com/jogamp/opengl/test/android/LauncherUtil.java b/src/test/com/jogamp/opengl/test/android/LauncherUtil.java
index 1f9c26b..11416cd 100644
--- a/src/test/com/jogamp/opengl/test/android/LauncherUtil.java
+++ b/src/test/com/jogamp/opengl/test/android/LauncherUtil.java
@@ -249,7 +249,7 @@ public class LauncherUtil {
}
final String q = uri.getQuery();
- final int q_l = q.length();
+ final int q_l = null != q ? q.length() : -1;
int q_e = -1;
while(q_e < q_l) {
int q_b = q_e + 1; // next term
@@ -293,9 +293,6 @@ public class LauncherUtil {
if(null == activityName) {
throw new RuntimeException("Activity is not NULL");
}
- if(packages.size() == 0) {
- throw new RuntimeException("Empty package list");
- }
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
index 1dfdde5..0454d54 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java
@@ -43,11 +43,11 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc
final OrderedProperties props = getProperties();
// props.setProperty("jogamp.debug.JNILibLoader", "true");
// props.setProperty("jogamp.debug.NativeLibrary", "true");
+ // props.setProperty("jogamp.debug.IOUtil", "true");
// properties.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
- // properties.setProperty("jogamp.debug.IOUtil", "true");
- // properties.setProperty("nativewindow.debug", "all");
+ // props.setProperty("nativewindow.debug", "all");
props.setProperty("nativewindow.debug.GraphicsConfiguration", "true");
- // properties.setProperty("jogl.debug", "all");
+ // props.setProperty("jogl.debug", "all");
// properties.setProperty("jogl.debug.GLProfile", "true");
props.setProperty("jogl.debug.GLDrawable", "true");
props.setProperty("jogl.debug.GLContext", "true");
@@ -60,7 +60,6 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc
// props.setProperty("newt.debug.Window", "true");
// props.setProperty("newt.debug.Window.MouseEvent", "true");
// props.setProperty("newt.debug.Window.KeyEvent", "true");
- props.setProperty("jogamp.debug.IOUtil", "true");
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
index 889e094..e850b93 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
@@ -79,5 +79,20 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity {
glWindow.resetFPSCounter();
Log.d(TAG, "onCreate - X");
- }
+ }
+
+ @Override
+ public void onResume() {
+ // android.os.Debug.startMethodTracing("GearsES2.trace");
+ // android.os.Debug.startAllocCounting();
+ super.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ // android.os.Debug.stopAllocCounting();
+ // android.os.Debug.stopMethodTracing();
+ super.onPause();
+ }
+
}
diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug427GLJPanelTest1.java b/src/test/com/jogamp/opengl/test/bugs/Bug427GLJPanelTest1.java
index 18a4324..9bf492e 100644
--- a/src/test/com/jogamp/opengl/test/bugs/Bug427GLJPanelTest1.java
+++ b/src/test/com/jogamp/opengl/test/bugs/Bug427GLJPanelTest1.java
@@ -1,72 +1,72 @@
-package com.jogamp.opengl.test.bugs;
-
-import javax.swing.*;
-import java.awt.*;
-import javax.media.opengl.*;
-import javax.media.opengl.awt.*;
-
-public class Bug427GLJPanelTest1 extends JFrame implements GLEventListener {
-
- public Bug427GLJPanelTest1() {
- super("Bug427GLJPanelTest1");
-
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setLayout(new BorderLayout());
-
- setSize(600, 600);
- setLocation(40, 40);
- setVisible(true);
-
- GLProfile glp = GLProfile.get(GLProfile.GL2);
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setDoubleBuffered(true);
- caps.setHardwareAccelerated(true);
-
- GLJPanel panel = new GLJPanel(caps);
- panel.addGLEventListener(this);
-
- add(panel, BorderLayout.CENTER);
- }
-
- public static void main(String[] args) {
- Bug427GLJPanelTest1 demo = new Bug427GLJPanelTest1();
- demo.setVisible(true);
- }
-
- public void display(GLAutoDrawable drawable) {
- GL2 gl = drawable.getGL().getGL2();
-
- gl.glClear(GL.GL_COLOR_BUFFER_BIT);
- gl.glBegin(GL.GL_TRIANGLES);
-
- gl.glColor3f(1, 0, 0);
- gl.glVertex3f(0.25f, 0.25f, 0);
-
- gl.glColor3f(0, 1, 0);
- gl.glVertex3f(0.5f, 0.25f, 0);
-
- gl.glColor3f(0, 0, 1);
- gl.glVertex3f(0.25f, 0.5f, 0);
-
- gl.glEnd();
- gl.glFlush();
- }
-
- public void init(GLAutoDrawable drawable) {
- GL2 gl = drawable.getGL().getGL2();
-
- gl.glClearColor(0, 0, 0, 0);
- gl.glMatrixMode(GL2.GL_PROJECTION);
- gl.glLoadIdentity();
- gl.glOrtho(0, 1, 0, 1, -1, 1);
- }
-
- public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {
- }
-
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
- }
-
- public void dispose(GLAutoDrawable drawable) {
- }
-}
+package com.jogamp.opengl.test.bugs;
+
+import javax.swing.*;
+import java.awt.*;
+import javax.media.opengl.*;
+import javax.media.opengl.awt.*;
+
+public class Bug427GLJPanelTest1 extends JFrame implements GLEventListener {
+
+ public Bug427GLJPanelTest1() {
+ super("Bug427GLJPanelTest1");
+
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ setLayout(new BorderLayout());
+
+ setSize(600, 600);
+ setLocation(40, 40);
+ setVisible(true);
+
+ GLProfile glp = GLProfile.get(GLProfile.GL2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setDoubleBuffered(true);
+ caps.setHardwareAccelerated(true);
+
+ GLJPanel panel = new GLJPanel(caps);
+ panel.addGLEventListener(this);
+
+ add(panel, BorderLayout.CENTER);
+ }
+
+ public static void main(String[] args) {
+ Bug427GLJPanelTest1 demo = new Bug427GLJPanelTest1();
+ demo.setVisible(true);
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2 gl = drawable.getGL().getGL2();
+
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT);
+ gl.glBegin(GL.GL_TRIANGLES);
+
+ gl.glColor3f(1, 0, 0);
+ gl.glVertex3f(0.25f, 0.25f, 0);
+
+ gl.glColor3f(0, 1, 0);
+ gl.glVertex3f(0.5f, 0.25f, 0);
+
+ gl.glColor3f(0, 0, 1);
+ gl.glVertex3f(0.25f, 0.5f, 0);
+
+ gl.glEnd();
+ gl.glFlush();
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ GL2 gl = drawable.getGL().getGL2();
+
+ gl.glClearColor(0, 0, 0, 0);
+ gl.glMatrixMode(GL2.GL_PROJECTION);
+ gl.glLoadIdentity();
+ gl.glOrtho(0, 1, 0, 1, -1, 1);
+ }
+
+ public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
index a69f995..a661694 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRendererNEWT01.java
@@ -1,195 +1,222 @@
-package com.jogamp.opengl.test.junit.graph;
-
-import java.io.IOException;
-
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLProfile;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.jogamp.common.os.Platform;
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.geom.opengl.SVertex;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener01;
-import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener02;
-import com.jogamp.opengl.test.junit.graph.demos.GPURegionRendererListenerBase01;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.util.glsl.ShaderState;
-
-
-public class TestRegionRendererNEWT01 extends UITestCase {
-
- public static void main(String args[]) throws IOException {
- String tstname = TestRegionRendererNEWT01.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
- static void destroyWindow(GLWindow window) {
- if(null!=window) {
- window.destroy();
- }
- }
-
- static GLWindow createWindow(String title, GLCapabilitiesImmutable caps, int width, int height) {
- Assert.assertNotNull(caps);
-
- GLWindow window = GLWindow.create(caps);
- window.setSize(width, height);
- window.setPosition(10, 10);
- window.setTitle(title);
- Assert.assertNotNull(window);
- window.setVisible(true);
-
- return window;
- }
-
- @Test
- public void testRegionRendererR2T01() throws InterruptedException {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
- System.err.println("disabled on non desktop (x86) arch for now ..");
- return;
- }
- GLProfile glp = GLProfile.getGL2ES2();
-
- GLCapabilities caps = new GLCapabilities(glp);
- //caps.setOnscreen(false);
- caps.setAlphaBits(4);
-
- GLWindow window = createWindow("shape-vbaa1-msaa0", caps, 800,400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
- GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT, 1140, false, false);
- demo02Listener.attachInputListenerTo(window);
- window.addGLEventListener(demo02Listener);
-
- RegionGLListener listener = new RegionGLListener(demo02Listener, window.getTitle(), "GPURegionNewtDemo02");
- window.addGLEventListener(listener);
-
- listener.setTech(-20, 00, 0f, -300, 400);
- window.display();
-
- listener.setTech(-20, 00, 0f, -150, 800);
- window.display();
-
- listener.setTech(-20, 00, 0f, -50, 1000);
- window.display();
-
- destroyWindow(window);
- }
-
- @Test
- public void testRegionRendererMSAA01() throws InterruptedException {
- GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
- GLCapabilities caps = new GLCapabilities(glp);
- // caps.setOnscreen(false);
- caps.setAlphaBits(4);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4);
-
- GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
-
- GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
- demo01Listener.attachInputListenerTo(window);
- window.addGLEventListener(demo01Listener);
-
- RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01");
- window.addGLEventListener(listener);
-
- listener.setTech(-20, 00, 0f, -300, 400);
- window.display();
-
- listener.setTech(-20, 00, 0f, -150, 800);
- window.display();
-
- listener.setTech(-20, 00, 0f, -50, 1000);
- window.display();
-
- destroyWindow(window);
- }
-
- @Test
- public void testRegionRendererMSAA02() throws InterruptedException {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
- // FIXME: Also the GLSL code for VARIABLE_CURVE is not fit for mobile yet!
- System.err.println("disabled on non desktop (x86) arch for now ..");
- return;
- }
- GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setAlphaBits(4);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4);
-
- GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
-
- GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARIABLE_CURVE_WEIGHT_BIT, 0, false, false);
- demo01Listener.attachInputListenerTo(window);
- window.addGLEventListener(demo01Listener);
-
- RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02");
- window.addGLEventListener(listener);
-
- listener.setTech(-20, 00, 0f, -300, 400);
- window.display();
-
- listener.setTech(-20, 00, 0f, -150, 800);
- window.display();
-
- listener.setTech(-20, 00, 0f, -50, 1000);
- window.display();
-
- destroyWindow(window);
- }
-
- private class RegionGLListener implements GLEventListener {
- String winTitle;
- String name;
- GPURegionRendererListenerBase01 impl;
-
- public RegionGLListener(GPURegionRendererListenerBase01 impl, String title, String name) {
- this.impl = impl;
- this.winTitle = title;
- this.name = name;
- }
-
- public void setTech(float xt, float yt, float angle, int zoom, int fboSize){
- impl.setMatrix(xt, yt, angle, zoom, fboSize);
- }
-
- public void init(GLAutoDrawable drawable) {
- impl.init(drawable);
- }
-
- public void display(GLAutoDrawable drawable) {
- impl.display(drawable);
-
- try {
- impl.printScreen(drawable, "./", winTitle, name, false);
- } catch (GLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public void dispose(GLAutoDrawable drawable) {
- impl.dispose(drawable);
-
- }
-
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- impl.reshape(drawable, x, y, width, height);
-
- }
- }
-}
+/**
+ * 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;
+
+import java.io.IOException;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener01;
+import com.jogamp.opengl.test.junit.graph.demos.GPURegionGLListener02;
+import com.jogamp.opengl.test.junit.graph.demos.GPURegionRendererListenerBase01;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+
+public class TestRegionRendererNEWT01 extends UITestCase {
+
+ public static void main(String args[]) throws IOException {
+ String tstname = TestRegionRendererNEWT01.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ static void destroyWindow(GLWindow window) {
+ if(null!=window) {
+ window.destroy();
+ }
+ }
+
+ static GLWindow createWindow(String title, GLCapabilitiesImmutable caps, int width, int height) {
+ Assert.assertNotNull(caps);
+
+ GLWindow window = GLWindow.create(caps);
+ window.setSize(width, height);
+ window.setPosition(10, 10);
+ window.setTitle(title);
+ Assert.assertNotNull(window);
+ window.setVisible(true);
+
+ return window;
+ }
+
+ @Test
+ public void testRegionRendererR2T01() throws InterruptedException {
+ if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
+ // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
+ System.err.println("disabled on non desktop (x86) arch for now ..");
+ return;
+ }
+ GLProfile glp = GLProfile.getGL2ES2();
+
+ GLCapabilities caps = new GLCapabilities(glp);
+ //caps.setOnscreen(false);
+ caps.setAlphaBits(4);
+
+ GLWindow window = createWindow("shape-vbaa1-msaa0", caps, 800,400);
+ RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ GPURegionGLListener02 demo02Listener = new GPURegionGLListener02 (rs, Region.VBAA_RENDERING_BIT, 1140, false, false);
+ demo02Listener.attachInputListenerTo(window);
+ window.addGLEventListener(demo02Listener);
+
+ RegionGLListener listener = new RegionGLListener(demo02Listener, window.getTitle(), "GPURegionNewtDemo02");
+ window.addGLEventListener(listener);
+
+ listener.setTech(-20, 00, 0f, -300, 400);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -150, 800);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -50, 1000);
+ window.display();
+
+ destroyWindow(window);
+ }
+
+ @Test
+ public void testRegionRendererMSAA01() throws InterruptedException {
+ GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ // caps.setOnscreen(false);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+
+ GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
+ RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+
+ GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, 0, 0, false, false);
+ demo01Listener.attachInputListenerTo(window);
+ window.addGLEventListener(demo01Listener);
+
+ RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion01");
+ window.addGLEventListener(listener);
+
+ listener.setTech(-20, 00, 0f, -300, 400);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -150, 800);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -50, 1000);
+ window.display();
+
+ destroyWindow(window);
+ }
+
+ @Test
+ public void testRegionRendererMSAA02() throws InterruptedException {
+ if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
+ // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
+ // FIXME: Also the GLSL code for VARIABLE_CURVE is not fit for mobile yet!
+ System.err.println("disabled on non desktop (x86) arch for now ..");
+ return;
+ }
+ GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+
+ GLWindow window = createWindow("shape-vbaa0-msaa1", caps, 800, 400);
+ RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+
+ GPURegionGLListener01 demo01Listener = new GPURegionGLListener01 (rs, Region.VARIABLE_CURVE_WEIGHT_BIT, 0, false, false);
+ demo01Listener.attachInputListenerTo(window);
+ window.addGLEventListener(demo01Listener);
+
+ RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegion02");
+ window.addGLEventListener(listener);
+
+ listener.setTech(-20, 00, 0f, -300, 400);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -150, 800);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -50, 1000);
+ window.display();
+
+ destroyWindow(window);
+ }
+
+ private class RegionGLListener implements GLEventListener {
+ String winTitle;
+ String name;
+ GPURegionRendererListenerBase01 impl;
+
+ public RegionGLListener(GPURegionRendererListenerBase01 impl, String title, String name) {
+ this.impl = impl;
+ this.winTitle = title;
+ this.name = name;
+ }
+
+ public void setTech(float xt, float yt, float angle, int zoom, int fboSize){
+ impl.setMatrix(xt, yt, angle, zoom, fboSize);
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ impl.init(drawable);
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ impl.display(drawable);
+
+ try {
+ impl.printScreen(drawable, "./", winTitle, name, false);
+ } catch (GLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ impl.dispose(drawable);
+
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ impl.reshape(drawable, x, y, width, height);
+
+ }
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
new file mode 100644
index 0000000..a09cc76
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java
@@ -0,0 +1,236 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.graph;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLRunnable;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.TextRenderer;
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.geom.AABBox;
+import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+
+public class TestTextRendererNEWT00 extends UITestCase {
+ static final boolean DEBUG = false;
+ static final boolean TRACE = false;
+ static long duration = 100; // ms
+
+ static final float[] textPosition = new float[] {0,0,0};
+ static final int[] texSize = new int[] { 0 };
+ static final int fontSize = 24;
+ static Font font;
+
+ @BeforeClass
+ public static void setup() throws IOException {
+ font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ }
+
+ static int atoi(String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (Exception ex) { throw new RuntimeException(ex); }
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = atoi(args[i]);
+ }
+ }
+ String tstname = TestTextRendererNEWT00.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ static void sleep() {
+ try {
+ System.err.println("** new frame ** (sleep: "+duration+"ms)");
+ Thread.sleep(duration);
+ } catch (InterruptedException ie) {}
+ }
+
+ static void destroyWindow(GLWindow window) {
+ if(null!=window) {
+ window.destroy();
+ }
+ }
+
+ static GLWindow createWindow(String title, GLCapabilitiesImmutable caps, int width, int height) {
+ Assert.assertNotNull(caps);
+
+ GLWindow window = GLWindow.create(caps);
+ window.setSize(width, height);
+ window.setPosition(10, 10);
+ window.setTitle(title);
+ Assert.assertNotNull(window);
+ window.setVisible(true);
+
+ return window;
+ }
+
+ @Test
+ public void testTextRendererMSAA01() throws InterruptedException {
+ GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ System.err.println("Requested: "+caps);
+
+ GLWindow window = createWindow("text-vbaa0-msaa1", caps, 800, 400);
+ window.display();
+ System.err.println("Chosen: "+window.getChosenGLCapabilities());
+
+ final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ final TextRendererListener textGLListener = new TextRendererListener(rs);
+ final TextRenderer renderer = textGLListener.getRenderer();
+ window.addGLEventListener(textGLListener);
+
+ window.invoke(true, new GLRunnable() {
+ @Override
+ public boolean run(GLAutoDrawable drawable) {
+ int c=0;
+ renderString(drawable, renderer, "GlueGen", c++, -1, -1000);
+ renderString(drawable, renderer, "JOAL", c++, -1, -1000);
+ renderString(drawable, renderer, "JOGL", c++, -1, -1000);
+ renderString(drawable, renderer, "JOCL", c++, -1, -1000);
+ try {
+ textGLListener.printScreen(drawable, "./", "TestTextRendererNEWT00-snap"+screenshot_num, false);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+ });
+ sleep();
+
+ destroyWindow(window);
+ }
+ int screenshot_num = 0;
+
+ int lastRow = -1;
+
+ void renderString(GLAutoDrawable drawable, TextRenderer renderer, String text, int column, int row, int z0) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ final int height = drawable.getHeight();
+
+ int dx = 0;
+ int dy = height;
+ if(0>row) {
+ row = lastRow + 1;
+ }
+ AABBox textBox = font.getStringBounds(text, fontSize);
+ dx += font.getAdvanceWidth('X', fontSize) * column;
+ dy -= (int)textBox.getHeight() * ( row + 1 );
+ renderer.resetModelview(null);
+ renderer.translate(gl, dx, dy, z0);
+ renderer.drawString3D(gl, font, text, textPosition, fontSize, texSize);
+
+ lastRow = row;
+ }
+
+ public class TextRendererListener implements GLEventListener {
+ private GLReadBufferUtil screenshot;
+ private TextRenderer renderer;
+
+ public TextRendererListener(RenderState rs) {
+ this.screenshot = new GLReadBufferUtil(false, false);
+ this.renderer = TextRenderer.create(rs, 0);
+ }
+
+ public final TextRenderer getRenderer() { return renderer; }
+
+ public void printScreen(GLAutoDrawable drawable, String dir, String objName, boolean exportAlpha) throws GLException, IOException {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.printf("%s-%03dx%03d-T%04d", objName, drawable.getWidth(), drawable.getHeight(), texSize[0]);
+
+ final String filename = dir + sw +".png";
+ if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ renderer.init(gl);
+ renderer.setAlpha(gl, 1.0f);
+ renderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
+ }
+
+ public void reshape(GLAutoDrawable drawable, int xstart, int ystart, int width, int height) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glViewport(xstart, ystart, width, height);
+ // renderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 1000.0f);
+ renderer.reshapeOrtho(gl, width, height, 0.1f, 1000.0f);
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ renderString(drawable, renderer, "012345678901234567890123456789", 0, 0, -1000);
+ renderString(drawable, renderer, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000);
+ renderString(drawable, renderer, "Hello World", 0, -1, -1000);
+ renderString(drawable, renderer, "4567890123456", 4, -1, -1000);
+ renderString(drawable, renderer, "I like JogAmp", 4, -1, -1000);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ final GL2ES2 gl = drawable.getGL().getGL2ES2();
+ screenshot.dispose(gl);
+ renderer.destroy(gl);
+ }
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
index 3830b0c..ea02e93 100755
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java
@@ -1,218 +1,245 @@
-package com.jogamp.opengl.test.junit.graph;
-
-import java.io.IOException;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLProfile;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.jogamp.common.os.Platform;
-import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.RenderState;
-import com.jogamp.graph.curve.opengl.TextRenderer;
-import com.jogamp.graph.font.FontFactory;
-import com.jogamp.graph.geom.opengl.SVertex;
-import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.test.junit.graph.demos.GPUTextRendererListenerBase01;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-import com.jogamp.opengl.util.glsl.ShaderState;
-
-
-public class TestTextRendererNEWT01 extends UITestCase {
- static final boolean DEBUG = false;
- static final boolean TRACE = false;
- static long duration = 100; // ms
-
- static int atoi(String a) {
- try {
- return Integer.parseInt(a);
- } catch (Exception ex) { throw new RuntimeException(ex); }
- }
-
- public static void main(String args[]) throws IOException {
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-time")) {
- i++;
- duration = atoi(args[i]);
- }
- }
- String tstname = TestTextRendererNEWT01.class.getName();
- org.junit.runner.JUnitCore.main(tstname);
- }
-
- static void sleep() {
- try {
- System.err.println("** new frame ** (sleep: "+duration+"ms)");
- Thread.sleep(duration);
- } catch (InterruptedException ie) {}
- }
-
- static void destroyWindow(GLWindow window) {
- if(null!=window) {
- window.destroy();
- }
- }
-
- static GLWindow createWindow(String title, GLCapabilitiesImmutable caps, int width, int height) {
- Assert.assertNotNull(caps);
-
- GLWindow window = GLWindow.create(caps);
- window.setSize(width, height);
- window.setPosition(10, 10);
- window.setTitle(title);
- Assert.assertNotNull(window);
- window.setVisible(true);
-
- return window;
- }
-
- @Test
- public void testTextRendererR2T01() throws InterruptedException {
- if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
- // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
- System.err.println("disabled on non desktop (x86) arch for now ..");
- return;
- }
- GLProfile glp = GLProfile.getGL2ES2();
-
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setAlphaBits(4);
- System.err.println("Requested: "+caps);
-
- GLWindow window = createWindow("text-vbaa1-msaa0", caps, 800,400);
- window.display();
- System.err.println("Chosen: "+window.getChosenGLCapabilities());
-
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
- TextGLListener textGLListener = new TextGLListener(rs, Region.VBAA_RENDERING_BIT, DEBUG, TRACE);
- textGLListener.attachInputListenerTo(window);
- window.addGLEventListener(textGLListener);
-
- if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
- textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
- window.display();
- sleep();
- }
-
- if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
- textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
- window.display();
- sleep();
- }
-
- destroyWindow(window);
- }
-
- @Test
- public void testTextRendererMSAA01() throws InterruptedException {
- GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
- GLCapabilities caps = new GLCapabilities(glp);
- caps.setAlphaBits(4);
- caps.setSampleBuffers(true);
- caps.setNumSamples(4);
- System.err.println("Requested: "+caps);
-
- GLWindow window = createWindow("text-vbaa0-msaa1", caps, 800, 400);
- window.display();
- System.err.println("Chosen: "+window.getChosenGLCapabilities());
-
- RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
- TextGLListener textGLListener = new TextGLListener(rs, 0, DEBUG, TRACE);
- textGLListener.attachInputListenerTo(window);
- window.addGLEventListener(textGLListener);
-
- if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
- textGLListener.setTech(-400, -30, 0f, -1000, 0);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -30, 0, -380, 0);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -20, 0, -80, 0);
- window.display();
- sleep();
- }
-
- if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
- textGLListener.setTech(-400, -30, 0f, -1000, 0);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -30, 0, -380, 0);
- window.display();
- sleep();
-
- textGLListener.setTech(-400, -20, 0, -80, 0);
- window.display();
- sleep();
- }
-
- destroyWindow(window);
- }
-
- private class TextGLListener extends GPUTextRendererListenerBase01 {
- String winTitle;
-
- public TextGLListener(RenderState rs, int type, boolean debug, boolean trace) {
- super(rs, type, debug, trace);
- }
-
- public void attachInputListenerTo(GLWindow window) {
- super.attachInputListenerTo(window);
- winTitle = window.getTitle();
- }
- public void setTech(float xt, float yt, float angle, int zoom, int fboSize){
- setMatrix(xt, yt, angle, zoom, fboSize);
- }
-
- public void init(GLAutoDrawable drawable) {
- super.init(drawable);
-
- GL2ES2 gl = drawable.getGL().getGL2ES2();
- gl.setSwapInterval(1);
- gl.glEnable(GL.GL_DEPTH_TEST);
-
- final TextRenderer textRenderer = (TextRenderer) getRenderer();
-
- textRenderer.setAlpha(gl, 1.0f);
- textRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
- }
-
- public void display(GLAutoDrawable drawable) {
- super.display(drawable);
-
- try {
- printScreen(drawable, "./", winTitle, false);
- } catch (GLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-}
+/**
+ * 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;
+
+import java.io.IOException;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.TextRenderer;
+import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.graph.demos.GPUTextRendererListenerBase01;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+
+public class TestTextRendererNEWT01 extends UITestCase {
+ static final boolean DEBUG = false;
+ static final boolean TRACE = false;
+ static long duration = 100; // ms
+
+ static int atoi(String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (Exception ex) { throw new RuntimeException(ex); }
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = atoi(args[i]);
+ }
+ }
+ String tstname = TestTextRendererNEWT01.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ static void sleep() {
+ try {
+ System.err.println("** new frame ** (sleep: "+duration+"ms)");
+ Thread.sleep(duration);
+ } catch (InterruptedException ie) {}
+ }
+
+ static void destroyWindow(GLWindow window) {
+ if(null!=window) {
+ window.destroy();
+ }
+ }
+
+ static GLWindow createWindow(String title, GLCapabilitiesImmutable caps, int width, int height) {
+ Assert.assertNotNull(caps);
+
+ GLWindow window = GLWindow.create(caps);
+ window.setSize(width, height);
+ window.setPosition(10, 10);
+ window.setTitle(title);
+ Assert.assertNotNull(window);
+ window.setVisible(true);
+
+ return window;
+ }
+
+ @Test
+ public void testTextRendererR2T01() throws InterruptedException {
+ if(Platform.CPUFamily.X86 != Platform.CPU_ARCH.family) { // FIXME
+ // FIXME: Disabled for now - since it doesn't seem fit for mobile (performance wise).
+ System.err.println("disabled on non desktop (x86) arch for now ..");
+ return;
+ }
+ GLProfile glp = GLProfile.getGL2ES2();
+
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setAlphaBits(4);
+ System.err.println("Requested: "+caps);
+
+ GLWindow window = createWindow("text-vbaa1-msaa0", caps, 800,400);
+ window.display();
+ System.err.println("Chosen: "+window.getChosenGLCapabilities());
+
+ RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ TextGLListener textGLListener = new TextGLListener(rs, Region.VBAA_RENDERING_BIT, DEBUG, TRACE);
+ textGLListener.attachInputListenerTo(window);
+ window.addGLEventListener(textGLListener);
+
+ if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
+ window.display();
+ sleep();
+ }
+
+ if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, window.getWidth()*2);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, window.getWidth()*3);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, window.getWidth()*4);
+ window.display();
+ sleep();
+ }
+
+ destroyWindow(window);
+ }
+
+ @Test
+ public void testTextRendererMSAA01() throws InterruptedException {
+ GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ System.err.println("Requested: "+caps);
+
+ GLWindow window = createWindow("text-vbaa0-msaa1", caps, 800, 400);
+ window.display();
+ System.err.println("Chosen: "+window.getChosenGLCapabilities());
+
+ RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ TextGLListener textGLListener = new TextGLListener(rs, 0, DEBUG, TRACE);
+ textGLListener.attachInputListenerTo(window);
+ window.addGLEventListener(textGLListener);
+
+ if(textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, 0);
+ window.display();
+ sleep();
+ }
+
+ if(textGLListener.setFontSet(FontFactory.JAVA, 0, 0)) {
+ textGLListener.setTech(-400, -30, 0f, -1000, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -30, 0, -380, 0);
+ window.display();
+ sleep();
+
+ textGLListener.setTech(-400, -20, 0, -80, 0);
+ window.display();
+ sleep();
+ }
+
+ destroyWindow(window);
+ }
+
+ private class TextGLListener extends GPUTextRendererListenerBase01 {
+ String winTitle;
+
+ public TextGLListener(RenderState rs, int type, boolean debug, boolean trace) {
+ super(rs, type, debug, trace);
+ }
+
+ public void attachInputListenerTo(GLWindow window) {
+ super.attachInputListenerTo(window);
+ winTitle = window.getTitle();
+ }
+ public void setTech(float xt, float yt, float angle, int zoom, int fboSize){
+ setMatrix(xt, yt, angle, zoom, fboSize);
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ super.init(drawable);
+
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ gl.setSwapInterval(1);
+ gl.glEnable(GL.GL_DEPTH_TEST);
+
+ final TextRenderer textRenderer = (TextRenderer) getRenderer();
+
+ textRenderer.setAlpha(gl, 1.0f);
+ textRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ super.display(drawable);
+
+ try {
+ printScreen(drawable, "./", winTitle, false);
+ } catch (GLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
new file mode 100644
index 0000000..ff7eb4e
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java
@@ -0,0 +1,168 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.graph;
+
+import java.io.IOException;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLDrawable;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.graph.curve.opengl.RenderState;
+import com.jogamp.graph.curve.opengl.TextRenderer;
+import com.jogamp.graph.font.Font;
+import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.geom.AABBox;
+import com.jogamp.graph.geom.opengl.SVertex;
+import com.jogamp.opengl.test.junit.util.NEWTGLContext;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.glsl.ShaderState;
+
+
+public class TestTextRendererNEWT10 extends UITestCase {
+ static final boolean DEBUG = false;
+ static final boolean TRACE = false;
+ static long duration = 100; // ms
+
+ static final float[] textPosition = new float[] {0,0,0};
+ static final int[] texSize = new int[] { 0 };
+ static final int fontSize = 24;
+ static Font font;
+
+ @BeforeClass
+ public static void setup() throws IOException {
+ font = FontFactory.get(FontFactory.UBUNTU).getDefault();
+ }
+
+ static int atoi(String a) {
+ try {
+ return Integer.parseInt(a);
+ } catch (Exception ex) { throw new RuntimeException(ex); }
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = atoi(args[i]);
+ }
+ }
+ String tstname = TestTextRendererNEWT10.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ static void sleep() {
+ try {
+ System.err.println("** new frame ** (sleep: "+duration+"ms)");
+ Thread.sleep(duration);
+ } catch (InterruptedException ie) {}
+ }
+
+ @Test
+ public void testTextRendererMSAA01() throws InterruptedException {
+ GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+ System.err.println("Requested: "+caps);
+
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(caps, 800, 400, true);
+ final GLDrawable drawable = winctx.context.getGLDrawable();
+ final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
+ System.err.println(winctx.context);
+
+ Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
+
+ System.err.println("Chosen: "+winctx.window.getChosenCapabilities());
+
+ final RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
+ final TextRenderer renderer = TextRenderer.create(rs, 0);
+
+ // init
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ renderer.init(gl);
+ renderer.setAlpha(gl, 1.0f);
+ renderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
+
+ // reshape
+ gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
+
+ // renderer.reshapePerspective(gl, 45.0f, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
+ renderer.reshapeOrtho(gl, drawable.getWidth(), drawable.getHeight(), 0.1f, 1000.0f);
+
+ // display
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ renderString(drawable, gl, renderer, "012345678901234567890123456789", 0, 0, -1000);
+ renderString(drawable, gl, renderer, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, -1, -1000);
+ renderString(drawable, gl, renderer, "Hello World", 0, -1, -1000);
+ renderString(drawable, gl, renderer, "4567890123456", 4, -1, -1000);
+ renderString(drawable, gl, renderer, "I like JogAmp", 4, -1, -1000);
+
+ int c = 0;
+ renderString(drawable, gl, renderer, "GlueGen", c++, -1, -1000);
+ renderString(drawable, gl, renderer, "JOAL", c++, -1, -1000);
+ renderString(drawable, gl, renderer, "JOGL", c++, -1, -1000);
+ renderString(drawable, gl, renderer, "JOCL", c++, -1, -1000);
+
+ drawable.swapBuffers();
+ sleep();
+
+ // dispose
+ renderer.destroy(gl);
+
+ NEWTGLContext.destroyWindow(winctx);
+ }
+ int screenshot_num = 0;
+
+ int lastRow = -1;
+
+ void renderString(GLDrawable drawable, GL2ES2 gl, TextRenderer renderer, String text, int column, int row, int z0) {
+ final int height = drawable.getHeight();
+
+ int dx = 0;
+ int dy = height;
+ if(0>row) {
+ row = lastRow + 1;
+ }
+ AABBox textBox = font.getStringBounds(text, fontSize);
+ dx += font.getAdvanceWidth('X', fontSize) * column;
+ dy -= (int)textBox.getHeight() * ( row + 1 );
+ renderer.resetModelview(null);
+ renderer.translate(gl, dx, dy, z0);
+ renderer.drawString3D(gl, font, text, textPosition, fontSize, texSize);
+
+ lastRow = row;
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
index 551ab55..7fb199a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
@@ -66,7 +66,6 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
int headType = 0;
boolean drawFPS = false;
- boolean updateFont = true;
final int fontSizeFixed = 6;
int fontSize = 40;
final int fontSizeModulo = 100;
@@ -197,7 +196,6 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
public void fontIncr(int v) {
fontSize = Math.abs((fontSize + v) % fontSizeModulo) ;
- updateFont = true;
dumpMatrix(true);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java
new file mode 100755
index 0000000..42b5972
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.opengl.FloatUtil;
+
+public class TestFloatUtil01MatrixMatrixMultNOUI {
+
+ final float[] m1 = new float[]{ 1, 3, 4, 0,
+ 6, 7, 8, 5,
+ 98, 7, 6, 9,
+ 54, 3, 2, 5 };
+
+ final float[] m2 = new float[]{ 1, 6, 98, 54,
+ 3, 7, 7, 3,
+ 4, 8, 6, 2,
+ 0, 5, 9, 5 };
+
+ final float[] m1xm2_RM = // m2xm1_CM
+ new float[]{ 26, 59, 143, 71,
+ 59, 174, 730, 386,
+ 143, 730, 9770, 5370,
+ 71, 386, 5370, 2954 };
+
+ final float[] m2xm1_RM = // m1xm2_CM
+ new float[]{12557, 893, 748, 1182,
+ 893, 116, 116, 113,
+ 748, 116, 120, 104,
+ 1182, 113, 104, 131 };
+
+ public static final void multMatrixf_RM(final float[] a, int a_off, final float[] b, int b_off, float[] d, int d_off) {
+ for (int i = 0; i < 4; i++) {
+ final float ai0=a[a_off+i*4+0], ai1=a[a_off+i*4+1], ai2=a[a_off+i*4+2], ai3=a[a_off+i*4+3];
+ d[d_off+i*4+0] = ai0 * b[b_off+0*4+0] + ai1 * b[b_off+1*4+0] + ai2 * b[b_off+2*4+0] + ai3 * b[b_off+3*4+0] ;
+ d[d_off+i*4+1] = ai0 * b[b_off+0*4+1] + ai1 * b[b_off+1*4+1] + ai2 * b[b_off+2*4+1] + ai3 * b[b_off+3*4+1] ;
+ d[d_off+i*4+2] = ai0 * b[b_off+0*4+2] + ai1 * b[b_off+1*4+2] + ai2 * b[b_off+2*4+2] + ai3 * b[b_off+3*4+2] ;
+ d[d_off+i*4+3] = ai0 * b[b_off+0*4+3] + ai1 * b[b_off+1*4+3] + ai2 * b[b_off+2*4+3] + ai3 * b[b_off+3*4+3] ;
+ }
+ }
+
+ @Test
+ public void testCM_m1xm2(){
+
+ float[] r = new float[16];
+
+ FloatUtil.multMatrixf(m1, 0, m2, 0, r, 0);
+
+ Assert.assertArrayEquals(m2xm1_RM, r, 0f);
+ }
+
+ @Test
+ public void testCM_m2xm1(){
+
+ float[] r = new float[16];
+
+ FloatUtil.multMatrixf(m2, 0, m1, 0, r, 0);
+
+ Assert.assertArrayEquals(m1xm2_RM, r, 0f);
+ }
+
+ @Test
+ public void testRM_m1xm2(){
+
+ float[] r = new float[16];
+
+ multMatrixf_RM(m1, 0, m2, 0, r, 0);
+
+ Assert.assertArrayEquals(m1xm2_RM, r, 0f);
+ }
+
+ @Test
+ public void testRM_m2xm1(){
+
+ float[] r = new float[16];
+
+ multMatrixf_RM(m2, 0, m1, 0, r, 0);
+
+ Assert.assertArrayEquals(m2xm1_RM, r, 0f);
+ }
+
+ public static void main(String args[]) {
+ org.junit.runner.JUnitCore.main(TestFloatUtil01MatrixMatrixMultNOUI.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java
new file mode 100644
index 0000000..78988c0
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java
@@ -0,0 +1,220 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import java.io.IOException;
+
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+public class TestGLContextSurfaceLockNEWT extends UITestCase {
+ static final int demoSize = 64;
+
+ public abstract class MyRunnable implements Runnable {
+ final Object postSync;
+ final int id;
+ boolean done = false;
+
+ public MyRunnable(Object postSync, int id) {
+ this.postSync = postSync;
+ this.id = id;
+ }
+
+ public boolean done() { return done; }
+ }
+
+ public class RudeAnimator extends MyRunnable {
+ private final GLAutoDrawable glad;
+ private final int frameCount;
+
+ public RudeAnimator(GLAutoDrawable glad, int frameCount, Object postSync, int id) {
+ super(postSync, id);
+ this.glad = glad;
+ this.frameCount = frameCount;
+ }
+
+ public void run() {
+ System.err.println("Animatr "+id+": PRE: "+Thread.currentThread().getName());
+
+ for(int c=0; c<frameCount; c++) {
+ glad.display();
+ }
+
+ System.err.println("Animatr "+id+": DONE/SYNC: "+Thread.currentThread().getName());
+ synchronized (postSync) {
+ done = true;
+ System.err.println("Animatr "+id+": END: "+Thread.currentThread().getName());
+ postSync.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Emulates a resize behavior with immediate display() call
+ * while the surface is still locked.
+ */
+ public class RudeResizer extends MyRunnable {
+ private final GLWindow win;
+ private final int actionCount;
+
+ public RudeResizer(GLWindow win, int actionCount, Object postSync, int id) {
+ super(postSync, id);
+ this.win = win;
+ this.actionCount = actionCount;
+ }
+
+ public void run() {
+ System.err.println("Resizer "+id+": PRE: "+Thread.currentThread().getName());
+
+ for(int c=0; c<actionCount; c++) {
+ win.runOnEDTIfAvail(false, new Runnable() {
+ public void run() {
+ // Normal resize, may trigger immediate display within lock
+ win.setSize(win.getWidth()+1, win.getHeight()+1);
+
+ // Force display within surface lock.
+ // This procedure emulates the sensitive behavior
+ // for all platforms directly.
+ int res = win.lockSurface();
+ if(res > NativeSurface.LOCK_SURFACE_NOT_READY) {
+ try {
+ win.display();
+ } finally {
+ win.unlockSurface();
+ }
+ }
+ }});
+ }
+
+ System.err.println("Resizer "+id+": DONE/SYNC: "+Thread.currentThread().getName());
+ synchronized (postSync) {
+ done = true;
+ System.err.println("Resizer "+id+": END: "+Thread.currentThread().getName());
+ postSync.notifyAll();
+ }
+ }
+ }
+
+ protected static boolean done(MyRunnable[] tasks) {
+ for(int i=tasks.length-1; i>=0; i--) {
+ if(!tasks[i].done()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ protected static boolean isDead(Thread[] threads) {
+ for(int i=threads.length-1; i>=0; i--) {
+ if(threads[i].isAlive()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ protected void runJOGLTasks(int animThreadCount, int frameCount, int reszThreadCount, int resizeCount) throws InterruptedException {
+ GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
+ Assert.assertNotNull(glWindow);
+
+ glWindow.addGLEventListener(new GearsES2(0));
+ glWindow.setSize(demoSize, demoSize);
+ glWindow.setVisible(true);
+
+ final String currentThreadName = Thread.currentThread().getName();
+ final Object sync = new Object();
+ final MyRunnable[] tasks = new MyRunnable[animThreadCount+reszThreadCount];
+ final Thread[] threads = new Thread[animThreadCount+reszThreadCount];
+ int i=0;
+
+ System.err.println("animThreadCount "+animThreadCount+", frameCount "+frameCount);
+ System.err.println("reszThreadCount "+reszThreadCount+", resizeCount "+resizeCount);
+ System.err.println("tasks "+tasks.length+", threads "+threads.length);
+
+ for(; i<animThreadCount; i++) {
+ System.err.println("create anim task/thread "+i);
+ tasks[i] = new RudeAnimator(glWindow, frameCount, sync, i);
+ threads[i] = new Thread(tasks[i], currentThreadName+"-anim"+i);
+ }
+ for(; i<animThreadCount+reszThreadCount; i++) {
+ System.err.println("create resz task/thread "+i);
+ tasks[i] = new RudeResizer(glWindow, resizeCount, sync, i);
+ threads[i] = new Thread(tasks[i], currentThreadName+"-resz"+i);
+ }
+
+ for(i=0; i<animThreadCount+reszThreadCount; i++) {
+ System.err.println("start thread "+i);
+ threads[i].start();
+ }
+ synchronized (sync) {
+ while(!done(tasks)) {
+ try {
+ sync.wait();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ i=0;
+ while(i<30 && !isDead(threads)) {
+ Thread.sleep(100);
+ i++;
+ }
+
+ glWindow.destroy();
+ }
+
+ @Test
+ public void test01_1AThreads_600Frames() throws InterruptedException {
+ runJOGLTasks(1, 600, 1, 600);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ try {
+ // duration = Integer.parseInt(args[i]);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ }
+ }
+ String tstname = TestGLContextSurfaceLockNEWT.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+}
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
index 4fa587e..bebe353 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java
@@ -37,6 +37,7 @@ import java.nio.ByteBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
@@ -56,7 +57,8 @@ public class TestGPUMemSec01NEWT extends UITestCase {
}
static NEWTGLContext.WindowContext createCurrentGLOffscreenWindow(GLProfile glp, int width, int height) throws GLException, InterruptedException {
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(glp, width, height, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(
+ new GLCapabilities(glp), width, height, true);
final GL gl = winctx.context.getGL();
Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
index d264d42..158c2aa 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
@@ -37,6 +37,7 @@ import java.nio.ByteOrder;
import javax.media.opengl.GL;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -70,7 +71,8 @@ public class TestMapBufferRead01NEWT extends UITestCase {
}
private void testWriteRead01(ByteBuffer verticiesBB) throws InterruptedException {
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getGL2GL3(), 800, 600, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(
+ new GLCapabilities(GLProfile.getGL2GL3()), 800, 600, true);
final GL gl = winctx.context.getGL();
int[] vertexBuffer = new int[1];
diff --git a/src/jogl/classes/jogamp/graph/math/MathFloat.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java
similarity index 65%
copy from src/jogl/classes/jogamp/graph/math/MathFloat.java
copy to src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java
index 0b8d69e..b9ac9fa 100644
--- a/src/jogl/classes/jogamp/graph/math/MathFloat.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java
@@ -1,45 +1,35 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package jogamp.graph.math;
-
-public class MathFloat {
-
- public static final float E = 2.7182818284590452354f;
-
- public static final float PI = 3.14159265358979323846f;
-
- public static float abs(float a) { return (float) java.lang.Math.abs(a); }
- public static float pow(float a, float b) { return (float) java.lang.Math.pow(a, b); }
-
- public static float sin(float a) { return (float) java.lang.Math.sin(a); }
- public static float cos(float a) { return (float) java.lang.Math.cos(a); }
- public static float acos(float a) { return (float) java.lang.Math.acos(a); }
-
- public static float sqrt(float a) { return (float) java.lang.Math.sqrt(a); }
-
-}
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.demos;
+
+import com.jogamp.opengl.util.texture.Texture;
+
+public interface TextureDraw01Accessor {
+ public Texture getTexture();
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java
similarity index 93%
rename from src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java
rename to src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java
index 6dfb118..6fd47e6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java
@@ -6,22 +6,20 @@ import javax.media.opengl.GL;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import jogamp.opengl.util.av.NullGLMediaPlayer;
-
import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
import com.jogamp.opengl.util.texture.TextureSequence;
-public class TestTextureSequence implements TextureSequence {
+public class TextureSequenceDemo01 implements TextureSequence {
TextureSequence.TextureFrame frame = null;
int textureUnit = 0;
protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST };
protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE };
final boolean useBuildInTexLookup;
- public TestTextureSequence(boolean useBuildInTexLookup) {
+ public TextureSequenceDemo01(boolean useBuildInTexLookup) {
this.useBuildInTexLookup = useBuildInTexLookup;
}
@@ -29,7 +27,7 @@ public class TestTextureSequence implements TextureSequence {
if(null == frame) {
TextureData texData = null;
try {
- URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader());
+ URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
if(null != urlConn) {
texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/OneTriangle.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/OneTriangle.java
index a2455e7..8c9f53b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/OneTriangle.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/OneTriangle.java
@@ -1,78 +1,78 @@
-/**
- * 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.demos.es1;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.glu.GLU;
-import javax.media.opengl.glu.gl2es1.GLUgl2es1;
-
-import com.jogamp.opengl.util.ImmModeSink;
-
-/**
- * A utility class to encapsulate drawing a single triangle for unit tests.
- * @author Wade Walker
- */
-public class OneTriangle {
-
- public static void setup( GL2ES1 gl, int width, int height ) {
- gl.glMatrixMode( GL2ES1.GL_PROJECTION );
- gl.glLoadIdentity();
-
- // coordinate system origin at lower left with width and height same as the window
- GLU glu = new GLUgl2es1();
- glu.gluOrtho2D( 0.0f, width, 0.0f, height );
-
- gl.glMatrixMode( GL2ES1.GL_MODELVIEW );
- gl.glLoadIdentity();
-
- gl.glViewport( 0, 0, width, height );
- }
-
- public static void render( GL2ES1 gl, int width, int height) {
- gl.glClear( GL.GL_COLOR_BUFFER_BIT );
-
- // draw a triangle filling the window
- gl.glLoadIdentity();
-
- ImmModeSink immModeSink = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 3,
- 3, GL.GL_FLOAT, // vertex
- 3, GL.GL_FLOAT, // color
- 0, GL.GL_FLOAT,// normal
- 0, GL.GL_FLOAT); // texture
- immModeSink.glBegin(GL.GL_TRIANGLES);
- immModeSink.glColor3f( 1, 0, 0 );
- immModeSink.glVertex2f( 0, 0 );
- immModeSink.glColor3f( 0, 1, 0 );
- immModeSink.glVertex2f( width, 0 );
- immModeSink.glColor3f( 0, 0, 1 );
- immModeSink.glVertex2f( width / 2, height );
- immModeSink.glEnd(gl, true);
- }
-}
+/**
+ * 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.demos.es1;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.glu.GLU;
+import javax.media.opengl.glu.gl2es1.GLUgl2es1;
+
+import com.jogamp.opengl.util.ImmModeSink;
+
+/**
+ * A utility class to encapsulate drawing a single triangle for unit tests.
+ * @author Wade Walker
+ */
+public class OneTriangle {
+
+ public static void setup( GL2ES1 gl, int width, int height ) {
+ gl.glMatrixMode( GL2ES1.GL_PROJECTION );
+ gl.glLoadIdentity();
+
+ // coordinate system origin at lower left with width and height same as the window
+ GLU glu = new GLUgl2es1();
+ glu.gluOrtho2D( 0.0f, width, 0.0f, height );
+
+ gl.glMatrixMode( GL2ES1.GL_MODELVIEW );
+ gl.glLoadIdentity();
+
+ gl.glViewport( 0, 0, width, height );
+ }
+
+ public static void render( GL2ES1 gl, int width, int height) {
+ gl.glClear( GL.GL_COLOR_BUFFER_BIT );
+
+ // draw a triangle filling the window
+ gl.glLoadIdentity();
+
+ ImmModeSink immModeSink = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 3,
+ 3, GL.GL_FLOAT, // vertex
+ 3, GL.GL_FLOAT, // color
+ 0, GL.GL_FLOAT,// normal
+ 0, GL.GL_FLOAT); // texture
+ immModeSink.glBegin(GL.GL_TRIANGLES);
+ immModeSink.glColor3f( 1, 0, 0 );
+ immModeSink.glVertex2f( 0, 0 );
+ immModeSink.glColor3f( 0, 1, 0 );
+ immModeSink.glVertex2f( width, 0 );
+ immModeSink.glColor3f( 0, 0, 1 );
+ immModeSink.glVertex2f( width / 2, height );
+ immModeSink.glEnd(gl, true);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
index de9a047..6246b3e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -179,12 +179,8 @@ public class GearsES2 implements GLEventListener {
System.err.println(Thread.currentThread()+" GearsES2.init FIN");
}
- public void enableAndroidTrace(boolean v) {
- useAndroidDebug = v;
- }
-
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
+ // System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
GL2ES2 gl = drawable.getGL().getGL2ES2();
st.useProgram(gl, true);
@@ -205,24 +201,11 @@ public class GearsES2 implements GLEventListener {
st.uniform(gl, pmvMatrixUniform);
st.useProgram(gl, false);
- if(useAndroidDebug) {
- try {
- android.os.Debug.startMethodTracing("GearsES2.trace");
- // android.os.Debug.startAllocCounting();
- useAndroidDebug = true;
- } catch (NoClassDefFoundError e) { useAndroidDebug=false; }
- }
-
- System.err.println(Thread.currentThread()+" GearsES2.reshape FIN");
+ // System.err.println(Thread.currentThread()+" GearsES2.reshape FIN");
}
- private boolean useAndroidDebug = false;
+ // private boolean useAndroidDebug = false;
public void dispose(GLAutoDrawable drawable) {
- if(useAndroidDebug) {
- // android.os.Debug.stopAllocCounting();
- android.os.Debug.stopMethodTracing();
- }
-
System.err.println(Thread.currentThread()+" GearsES2.dispose ... ");
if (drawable instanceof Window) {
Window window = (Window) drawable;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
index a246625..6202671 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -156,10 +156,6 @@ public class RedSquareES2 implements GLEventListener {
st.useProgram(gl, false);
}
- public void enableAndroidTrace(boolean v) {
- useAndroidDebug = v;
- }
-
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
GL2ES2 gl = glad.getGL().getGL2ES2();
@@ -173,23 +169,10 @@ public class RedSquareES2 implements GLEventListener {
st.uniform(gl, pmvMatrixUniform);
st.useProgram(gl, false);
- if(useAndroidDebug) {
- try {
- android.os.Debug.startMethodTracing("RedSquareES2.trace");
- // android.os.Debug.startAllocCounting();
- useAndroidDebug = true;
- } catch (NoClassDefFoundError e) { useAndroidDebug=false; }
- }
-
System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN");
}
- private boolean useAndroidDebug = false;
public void dispose(GLAutoDrawable glad) {
- if(useAndroidDebug) {
- // android.os.Debug.stopAllocCounting();
- android.os.Debug.stopMethodTracing();
- }
System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... ");
if (null != glWindow) {
glWindow.removeMouseListener(myMouse);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java
new file mode 100644
index 0000000..6e70165
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java
@@ -0,0 +1,249 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.demos.es2;
+
+import java.nio.FloatBuffer;
+
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLUniformData;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+
+public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01Accessor {
+ TextureData textureData;
+ Texture texture;
+
+ ShaderState st;
+ PMVMatrix pmvMatrix;
+ GLUniformData pmvMatrixUniform;
+ GLArrayDataServer interleavedVBO;
+
+
+ public TextureDraw01ES2Listener(TextureData td) {
+ this.textureData = td;
+ }
+
+ static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
+ static final String gl2_prelude = "#version 110\n";
+ static final String shaderBasename = "texture01_xxx";
+
+ private void initShader(GL2ES2 gl, boolean use_program) {
+ // Create & Compile the shader objects
+ ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+ ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
+ "shader", "shader/bin", shaderBasename, true);
+
+ // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
+ int rsFpPos;
+ if(gl.isGLES2()) {
+ rsVp.insertShaderSource(0, 0, es2_prelude[0]);
+ rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]);
+ } else {
+ rsVp.insertShaderSource(0, 0, gl2_prelude);
+ rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude);
+ }
+ if(gl.isGLES2()) {
+ rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
+ }
+
+ // Create & Link the shader program
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(rsVp);
+ sp.add(rsFp);
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+
+ // Let's manage all our states using ShaderState.
+ st = new ShaderState();
+ st.attachShaderProgram(gl, sp, use_program);
+ }
+
+ public void init(GLAutoDrawable glad) {
+ if(null!=textureData) {
+ this.texture = TextureIO.newTexture(glad.getGL(), textureData);
+ }
+ GL2ES2 gl = glad.getGL().getGL2ES2();
+
+ initShader(gl, true);
+
+ // setup mgl_PMVMatrix
+ pmvMatrix = new PMVMatrix();
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
+
+ st.ownUniform(pmvMatrixUniform);
+ if(!st.uniform(gl, pmvMatrixUniform)) {
+ throw new GLException("Error setting PMVMatrix in shader: "+st);
+ }
+ if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) {
+ throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
+ }
+
+ // fetch the flipped texture coordinates
+ texture.getImageTexCoords().getST_LB_RB_LT_RT(s_quadTexCoords, 0, 1f, 1f);
+
+ interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
+ {
+ interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
+ //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
+
+ FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
+
+ for(int i=0; i<4; i++) {
+ ib.put(s_quadVertices, i*3, 3);
+ ib.put(s_quadColors, i*4, 4);
+ //ib.put(s_cubeNormals, i*3, 3);
+ ib.put(s_quadTexCoords, i*2, 2);
+ }
+ }
+ interleavedVBO.seal(gl, true);
+ interleavedVBO.enableBuffer(gl, false);
+ st.ownAttribute(interleavedVBO, true);
+
+ // OpenGL Render Settings
+ gl.glClearColor(0, 0, 0, 1);
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+ st.useProgram(gl, false);
+ }
+
+ public Texture getTexture( ) {
+ return this.texture;
+ }
+
+ /**
+ public void setTextureData(GL gl, TextureData textureData ) {
+ if(null!=texture) {
+ texture.disable(gl);
+ texture.destroy(gl);
+ }
+ if(null!=this.textureData) {
+ this.textureData.destroy();
+ }
+ this.textureData = textureData;
+ this.texture = TextureIO.newTexture(this.textureData);
+
+ // fix VBO !
+ } */
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glViewport(0, 0, width, height);
+
+ // Clear background to white
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f);
+
+ if(null != st) {
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f);
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+
+ st.useProgram(gl, true);
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+ }
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ if(null!=texture) {
+ texture.disable(gl);
+ texture.destroy(gl);
+ }
+ if(null!=textureData) {
+ textureData.destroy();
+ }
+
+ pmvMatrixUniform = null;
+ pmvMatrix.destroy();
+ pmvMatrix=null;
+ st.destroy(gl);
+ st=null;
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ st.useProgram(gl, true);
+ interleavedVBO.enableBuffer(gl, true);
+ gl.glActiveTexture(GL.GL_TEXTURE0);
+ texture.enable(gl);
+ texture.bind(gl);
+
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
+
+ texture.disable(gl);
+ interleavedVBO.enableBuffer(gl, false);
+ st.useProgram(gl, false);
+ }
+
+ private static final float[] s_quadVertices = {
+ -1f, -1f, 0f, // LB
+ 1f, -1f, 0f, // RB
+ -1f, 1f, 0f, // LT
+ 1f, 1f, 0f // RT
+ };
+ private static final float[] s_quadColors = {
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f,
+ 1f, 1f, 1f, 1f };
+ private static final float[] s_quadTexCoords = {
+ 0f, 0f, // LB
+ 1f, 0f, // RB
+ 0f, 1f, // LT
+ 1f, 1f // RT
+ };
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
similarity index 86%
rename from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java
rename to src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
index e85468b..b04bd07 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java
@@ -33,7 +33,6 @@ import java.nio.FloatBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLES2;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
@@ -45,13 +44,7 @@ import com.jogamp.newt.Window;
import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
-import com.jogamp.newt.event.WindowAdapter;
-import com.jogamp.newt.event.WindowEvent;
-import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.JoglVersion;
-import com.jogamp.opengl.test.junit.jogl.demos.TestTextureSequence;
-import com.jogamp.opengl.test.junit.util.MiscUtils;
-import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
import com.jogamp.opengl.util.glsl.ShaderCode;
@@ -61,8 +54,8 @@ import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureSequence;
-public class TexCubeES2 implements GLEventListener {
- public TexCubeES2 (TextureSequence texSource, boolean innerCube, float zoom0, float rotx, float roty) {
+public class TextureSequenceCubeES2 implements GLEventListener {
+ public TextureSequenceCubeES2 (TextureSequence texSource, boolean innerCube, float zoom0, float rotx, float roty) {
this.texSeq = texSource;
this.innerCube = innerCube;
this.zoom0 = zoom0;
@@ -153,9 +146,9 @@ public class TexCubeES2 implements GLEventListener {
private void initShader(GL2ES2 gl) {
// Create & Compile the shader objects
- ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TexCubeES2.class,
+ ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
- ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TexCubeES2.class,
+ ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
"shader", "shader/bin", shaderBasename, true);
// Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
@@ -212,7 +205,7 @@ public class TexCubeES2 implements GLEventListener {
pmvMatrix = new PMVMatrix();
reshapePMV(drawable.getWidth(), drawable.getHeight());
- pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
@@ -221,6 +214,8 @@ public class TexCubeES2 implements GLEventListener {
}
+ // calculate centered tex coords w/ aspect ratio
+ float[] fixedCubeTexCoords = new float[s_cubeTexCoords.length];
{
final float aspect = tex.getAspectRatio();
final TextureCoords tc = tex.getImageTexCoords();
@@ -235,17 +230,16 @@ public class TexCubeES2 implements GLEventListener {
final float tx = s_cubeTexCoords[i+0];
final float ty = s_cubeTexCoords[i+1];
if(tx!=0) {
- s_cubeTexCoords[i+0] = tc_x1 * ss;
+ fixedCubeTexCoords[i+0] = tc_x1 * ss;
}
if(ty==0 && !tex.getMustFlipVertically() || ty!=0 && tex.getMustFlipVertically()) {
- s_cubeTexCoords[i+1] = 0f + dy;
+ fixedCubeTexCoords[i+1] = 0f + dy;
} else {
- s_cubeTexCoords[i+1] = tc_y1 * ts + dy;
+ fixedCubeTexCoords[i+1] = tc_y1 * ts + dy;
}
}
}
-
-
+
interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*6*4, GL.GL_STATIC_DRAW);
{
interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
@@ -259,7 +253,7 @@ public class TexCubeES2 implements GLEventListener {
ib.put(s_cubeVertices, i*3, 3);
ib.put(s_cubeColors, i*4, 4);
//ib.put(s_cubeNormals, i*3, 3);
- ib.put(s_cubeTexCoords, i*2, 2);
+ ib.put(fixedCubeTexCoords, i*2, 2);
}
}
interleavedVBO.seal(gl, true);
@@ -274,6 +268,9 @@ public class TexCubeES2 implements GLEventListener {
if (drawable instanceof Window) {
Window window = (Window) drawable;
window.addMouseListener(mouseAction);
+ } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) drawable;
+ new com.jogamp.newt.event.awt.AWTMouseAdapter(mouseAction).addTo(comp);
}
// Let's show the completed shader state ..
@@ -432,6 +429,7 @@ public class TexCubeES2 implements GLEventListener {
255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f
};
+ /*
private static final float[] s_cubeNormals =
{
0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f,
@@ -445,7 +443,7 @@ public class TexCubeES2 implements GLEventListener {
1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f,
-1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f
- };
+ };*/
private static final byte[] s_cubeIndices =
{
0, 3, 1, 2, 0, 1, /* front */
@@ -455,53 +453,5 @@ public class TexCubeES2 implements GLEventListener {
16, 19, 17, 18, 16, 17, /* right */
23, 20, 21, 20, 22, 21 /* left */
};
-
- public static void main(String[] args) {
- int width = 510;
- int height = 300;
- boolean useBuildInTexLookup = false;
- System.err.println("TexCubeES2.run()");
-
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-width")) {
- i++;
- width = MiscUtils.atoi(args[i], width);
- } else if(args[i].equals("-height")) {
- i++;
- height = MiscUtils.atoi(args[i], height);
- } else if(args[i].equals("-shaderBuildIn")) {
- useBuildInTexLookup = true;
- }
- }
-
- final GLWindow window = GLWindow.create(new GLCapabilities(GLProfile.getGL2ES2()));
- // Size OpenGL to Video Surface
- window.setSize(width, height);
- window.setFullscreen(false);
- window.setSize(width, height);
- final TestTextureSequence texSource = new TestTextureSequence(useBuildInTexLookup);
- window.addGLEventListener(new GLEventListener() {
- @Override
- public void init(GLAutoDrawable drawable) {
- texSource.initGLResources(drawable.getGL());
- }
- @Override
- public void dispose(GLAutoDrawable drawable) { }
- @Override
- public void display(GLAutoDrawable drawable) { }
- @Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
- });
- window.addGLEventListener(new TexCubeES2(texSource, false, -2.3f, 0f, 0f));
- window.setVisible(true);
- final Animator anim = new Animator(window);
- // anim.setUpdateFPSFrames(60, System.err);
- anim.start();
- window.addWindowListener(new WindowAdapter() {
- public void windowDestroyed(WindowEvent e) {
- anim.stop();
- }
- });
- }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
index bb0d841..0b83aac 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
@@ -55,7 +55,7 @@ import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.JoglVersion;
-import com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.av.GLMediaPlayer;
@@ -66,7 +66,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener {
static boolean waitForKey = false;
final URLConnection stream;
final float zoom0, rotx, roty;
- TexCubeES2 cube=null;
+ TextureSequenceCubeES2 cube=null;
GLMediaPlayer mPlayer=null;
public MovieCube() throws IOException {
@@ -137,7 +137,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener {
mPlayer = GLMediaPlayerFactory.create();
mPlayer.addEventListener(this);
- cube = new TexCubeES2(mPlayer, false, zoom0, rotx, roty);
+ cube = new TextureSequenceCubeES2(mPlayer, false, zoom0, rotx, roty);
if(waitForKey) {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp
new file mode 100644
index 0000000..1a42541
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp
@@ -0,0 +1,20 @@
+// Copyright 2012 JogAmp Community. All rights reserved.
+
+varying vec2 mgl_texCoord;
+varying vec4 frontColor;
+
+uniform sampler2D mgl_ActiveTexture;
+
+void main (void)
+{
+ vec4 texColor;
+ if(0.0 <= mgl_texCoord.t && mgl_texCoord.t<=1.0) {
+ texColor = texture2D(mgl_ActiveTexture, mgl_texCoord);
+ } else {
+ texColor = vec4(1, 1, 1, 1);
+ }
+
+ // mix frontColor with texture ..
+ gl_FragColor = vec4(frontColor*texColor);
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp
new file mode 100644
index 0000000..c521e37
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp
@@ -0,0 +1,17 @@
+// Copyright 2012 JogAmp Community. All rights reserved.
+
+uniform mat4 mgl_PMVMatrix[2];
+// uniform mat4 mgl_STMatrix;
+attribute vec4 mgl_Vertex;
+attribute vec4 mgl_Color;
+attribute vec4 mgl_MultiTexCoord;
+varying vec4 frontColor;
+varying vec2 mgl_texCoord;
+
+void main(void)
+{
+ frontColor=mgl_Color;
+ // mgl_texCoord = (mgl_STMatrix * mgl_MultiTexCoord).st;
+ mgl_texCoord = mgl_MultiTexCoord.st;
+ gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java
similarity index 85%
rename from src/test/com/jogamp/opengl/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java
rename to src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java
index 084caa6..af30c26 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/gl2/TextureGL2ListenerDraw1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java
@@ -26,8 +26,9 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.util.texture.gl2;
+package com.jogamp.opengl.test.junit.jogl.demos.gl2;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureData;
@@ -38,25 +39,25 @@ import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
-public class TextureGL2ListenerDraw1 implements GLEventListener {
+public class TextureDraw01GL2Listener implements GLEventListener, TextureDraw01Accessor {
private GLU glu = new GLU();
private TextureData textureData;
private Texture texture;
- public TextureGL2ListenerDraw1(TextureData td) {
+ public TextureDraw01GL2Listener(TextureData td) {
this.textureData = td;
}
public void init(GLAutoDrawable drawable) {
if(null!=textureData) {
- this.texture = TextureIO.newTexture(textureData);
+ this.texture = TextureIO.newTexture(drawable.getGL(), textureData);
}
}
- public void setTexture( Texture texture ) {
- this.texture = texture;
+ public Texture getTexture( ) {
+ return this.texture;
}
-
+
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
GL2 gl = drawable.getGL().getGL2();
gl.glMatrixMode(GL2ES1.GL_PROJECTION);
@@ -80,16 +81,7 @@ public class TextureGL2ListenerDraw1 implements GLEventListener {
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
- // need a valid GL context for this ..
-
- /** OpenGL ..
- texture.updateSubImage(textureData, 0,
- 20, 20,
- 20, 20,
- 100, 100); */
-
-
- // Now draw one quad with the texture
+ // draw one quad with the texture
if(null!=texture) {
texture.enable(gl);
texture.bind(gl);
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 9b26b46..1b33866 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
@@ -43,6 +43,7 @@ import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLPipelineFactory;
import javax.media.opengl.GLProfile;
@@ -61,7 +62,8 @@ public class TestFBOMRTNEWT01 extends UITestCase {
System.err.println("Test requires GL2/GL3 profile.");
return;
}
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2GL3(), 640, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getGL2GL3()), 640, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
GL2GL3 gl = winctx.context.getGL().getGL2GL3();
gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) ).getGL2GL3();
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 fb05e26..881399d 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
@@ -40,6 +40,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLUniformData;
@@ -62,7 +63,8 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
@Test
public void testShaderState01Validation() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -190,7 +192,8 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
void testShaderState00PerformanceSingle(boolean toggleEnable) throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -278,7 +281,8 @@ public class TestGLSLShaderState01NEWT extends UITestCase {
@Test(timeout=240000)
public void testShaderState01PerformanceDouble() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
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/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java
index 6450965..6421c24 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
@@ -40,6 +40,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLUniformData;
@@ -69,7 +70,8 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
private void testShaderState01Validation(boolean linkSP1) throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, true);
final GLDrawable drawable = winctx.context.getGLDrawable();
final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
System.err.println(winctx.context);
@@ -238,7 +240,8 @@ public class TestGLSLShaderState02NEWT extends UITestCase {
@Test(timeout=240000)
public void testShaderState01PerformanceDouble() throws InterruptedException {
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getGL2ES2()), 480, 480, false);
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/glsl/TestGLSLSimple01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
index ba43cc2..dde7252 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLSimple01NEWT.java
@@ -65,7 +65,6 @@ public class TestGLSLSimple01NEWT extends UITestCase {
Assert.assertTrue(window.isNativeValid());
GLContext context = window.getContext();
- context.setSynchronized(true);
// trigger native creation of drawable/context
window.display();
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 f6e46da..87d3170 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
@@ -46,13 +46,13 @@ import java.nio.FloatBuffer;
import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLUniformData;
import org.junit.Assert;
import org.junit.Test;
-import org.junit.BeforeClass;
public class TestRulerNEWT01 extends UITestCase {
static long durationPerTest = 10; // ms
@@ -63,7 +63,8 @@ public class TestRulerNEWT01 extends UITestCase {
GLProfile.initSingleton();
long t1 = System.nanoTime();
// preset ..
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 640, 480, true);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(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/glsl/TestTransformFeedbackVaryingsBug407NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
index 685ceeb..3be0897 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestTransformFeedbackVaryingsBug407NEWT.java
@@ -9,6 +9,7 @@ import java.io.PrintStream;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GL3;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
@@ -83,7 +84,8 @@ public class TestTransformFeedbackVaryingsBug407NEWT extends UITestCase {
final static String glps = GLProfile.GL3;
private NEWTGLContext.WindowContext prepareTest() throws GLException, InterruptedException {
- final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getMaxProgrammable(true), 480, 480, debugGL);
+ final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(
+ new GLCapabilities(GLProfile.getMaxProgrammable(true)), 480, 480, debugGL);
if(!winctx.context.getGL().isGL3()) {
System.err.println("GL3 not available");
cleanupTest(winctx);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java
index 9e48a20..717d5e4 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java
@@ -33,14 +33,10 @@ import javax.media.opengl.glu.GLU;
import org.junit.Assert;
import org.junit.Test;
-/**
- * @author Julien Gouesse
- */
public class TestGluUnprojectFloatNOUI {
-
@Test
- public void test(){
+ public void testNaN(){
final GLU glu = new GLU();
final int[] pickedPoint = new int[]{400,300};
final float pickedPointDepth = 0;
@@ -52,6 +48,55 @@ public class TestGluUnprojectFloatNOUI {
Assert.assertTrue(!Double.isNaN(objCoords[0])&&!Double.isNaN(objCoords[1])&&!Double.isNaN(objCoords[2]));
}
+ @Test
+ public void test01(){
+ float[] mv = new float[] { 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1 };
+
+ float[] p = new float[] { 2.3464675f, 0, 0, 0,
+ 0, 2.4142134f, 0, 0,
+ 0, 0, -1.0002f, -1,
+ 0, 0, -20.002f, 0 };
+
+ int[] v = new int[] { 0, 0, 1000, 1000 };
+
+ float[] s = new float[] { 250, 250, 0.5f };
+
+ float[] expected = new float[] { -4.2612f, -4.1417f, -19.9980f };
+ float[] result = new float[] { 0, 0, 0 };
+
+ final GLU glu = new GLU();
+ glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0);
+
+ Assert.assertArrayEquals(expected, result, 0.0001f);
+ }
+
+ @Test
+ public void test02(){
+ float[] mv = new float[] { 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, -200, 1 } ;
+
+ float[] p = new float[] { 2.3464675f, 0, 0, 0,
+ 0, 2.4142134f, 0, 0,
+ 0, 0, -1.0002f, -1,
+ 0, 0, -20.002f, 0 };
+
+ int[] v = new int[] { 0, 0, 1000, 1000 };
+
+ float[] s = new float[] { 250, 250, 0.5f };
+ float[] expected = new float[] { -4.2612f, -4.1417f, 180.002f };
+ float[] result = new float[] { 0, 0, 0 };
+
+ final GLU glu = new GLU();
+ glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0);
+
+ Assert.assertArrayEquals(expected, result, 0.0001f);
+ }
+
public static void main(String args[]) {
org.junit.runner.JUnitCore.main(TestGluUnprojectFloatNOUI.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
index 03fed5e..021e117 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java
@@ -1,195 +1,195 @@
-/**
- * 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.swt;
-
-import java.awt.Frame;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLProfile;
-import javax.media.opengl.awt.GLCanvas;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.awt.SWT_AWT;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.After;
-import org.junit.Test;
-
-import com.jogamp.nativewindow.swt.SWTAccessor;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-/**
- * Tests that a basic SWT app can open without crashing under different GL profiles. Uses the AWT GL canvas with
- * the SWT_AWT bridge.
- * @author Wade Walker, et.al.
- */
-public class TestSWTAWT01GLn extends UITestCase {
-
- static final int duration = 250;
-
- Display display = null;
- Shell shell = null;
- Composite composite = null;
- Frame frame = null;
- GLCanvas glcanvas = null;
-
- @BeforeClass
- public static void startup() {
- System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
- if(!GLProfile.isAvailable(GLProfile.GL2)) {
- setTestSupported(false);
- }
- }
-
- @Before
- public void init() throws InterruptedException, InvocationTargetException {
- SWTAccessor.invoke(true, new Runnable() {
- public void run() {
- display = new Display();
- Assert.assertNotNull( display );
- shell = new Shell( display );
- Assert.assertNotNull( shell );
- shell.setLayout( new FillLayout() );
- composite = new Composite( shell, SWT.EMBEDDED | SWT.NO_BACKGROUND );
- composite.setLayout( new FillLayout() );
- Assert.assertNotNull( composite );
- frame = SWT_AWT.new_Frame( composite );
- Assert.assertNotNull( frame );
- }});
- }
-
- @After
- public void release() throws InterruptedException, InvocationTargetException {
- Assert.assertNotNull( display );
- Assert.assertNotNull( shell );
- Assert.assertNotNull( composite );
- Assert.assertNotNull( glcanvas );
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- frame.setVisible(false);
- frame.remove(glcanvas);
- frame.dispose();
- frame = null;
- glcanvas = null;
- }});
-
- SWTAccessor.invoke(true, new Runnable() {
- public void run() {
- composite.dispose();
- shell.close();
- shell.dispose();
- display.dispose();
- display = null;
- shell = null;
- composite = null;
- }});
- }
-
- protected void runTestGL( GLProfile glprofile ) throws InterruptedException {
- GLCapabilities glcapabilities = new GLCapabilities( glprofile );
- glcanvas = new GLCanvas( glcapabilities );
- Assert.assertNotNull( glcanvas );
- frame.add( glcanvas );
-
- glcanvas.addGLEventListener( new GLEventListener() {
- /* @Override */
- public void init( GLAutoDrawable glautodrawable ) {
- }
-
- /* @Override */
- public void dispose( GLAutoDrawable glautodrawable ) {
- }
-
- /* @Override */
- public void display( GLAutoDrawable glautodrawable ) {
- Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() );
- GL2ES1 gl = glautodrawable.getGL().getGL2ES1();
- OneTriangle.render( gl, rectangle.width, rectangle.height );
- }
-
- /* @Override */
- public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) {
- Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() );
- GL2ES1 gl = glautodrawable.getGL().getGL2ES1();
- OneTriangle.setup( gl, rectangle.width, rectangle.height );
- }
- });
-
- SWTAccessor.invoke(true, new Runnable() {
- public void run() {
- shell.setText( getClass().getName() );
- shell.setSize( 640, 480 );
- shell.open();
- }});
-
- long lStartTime = System.currentTimeMillis();
- long lEndTime = lStartTime + duration;
- try {
- while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) {
- SWTAccessor.invoke(true, new Runnable() {
- public void run() {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) { }
- }
- }});
- }
- }
- catch( Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
- }
- }
-
- @Test
- public void test() throws InterruptedException {
- GLProfile glprofile = GLProfile.getGL2ES1();
- runTestGL( glprofile );
- }
-
- public static void main(String args[]) {
- org.junit.runner.JUnitCore.main( TestSWTAWT01GLn.class.getName() );
- }
-}
+/**
+ * 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.swt;
+
+import java.awt.Frame;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.awt.SWT_AWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Test;
+
+import com.jogamp.nativewindow.swt.SWTAccessor;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Tests that a basic SWT app can open without crashing under different GL profiles. Uses the AWT GL canvas with
+ * the SWT_AWT bridge.
+ * @author Wade Walker, et.al.
+ */
+public class TestSWTAWT01GLn extends UITestCase {
+
+ static final int duration = 250;
+
+ Display display = null;
+ Shell shell = null;
+ Composite composite = null;
+ Frame frame = null;
+ GLCanvas glcanvas = null;
+
+ @BeforeClass
+ public static void startup() {
+ System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
+ if(!GLProfile.isAvailable(GLProfile.GL2)) {
+ setTestSupported(false);
+ }
+ }
+
+ @Before
+ public void init() throws InterruptedException, InvocationTargetException {
+ SWTAccessor.invoke(true, new Runnable() {
+ public void run() {
+ display = new Display();
+ Assert.assertNotNull( display );
+ shell = new Shell( display );
+ Assert.assertNotNull( shell );
+ shell.setLayout( new FillLayout() );
+ composite = new Composite( shell, SWT.EMBEDDED | SWT.NO_BACKGROUND );
+ composite.setLayout( new FillLayout() );
+ Assert.assertNotNull( composite );
+ frame = SWT_AWT.new_Frame( composite );
+ Assert.assertNotNull( frame );
+ }});
+ }
+
+ @After
+ public void release() throws InterruptedException, InvocationTargetException {
+ Assert.assertNotNull( display );
+ Assert.assertNotNull( shell );
+ Assert.assertNotNull( composite );
+ Assert.assertNotNull( glcanvas );
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ frame.remove(glcanvas);
+ frame.dispose();
+ frame = null;
+ glcanvas = null;
+ }});
+
+ SWTAccessor.invoke(true, new Runnable() {
+ public void run() {
+ composite.dispose();
+ shell.close();
+ shell.dispose();
+ display.dispose();
+ display = null;
+ shell = null;
+ composite = null;
+ }});
+ }
+
+ protected void runTestGL( GLProfile glprofile ) throws InterruptedException {
+ GLCapabilities glcapabilities = new GLCapabilities( glprofile );
+ glcanvas = new GLCanvas( glcapabilities );
+ Assert.assertNotNull( glcanvas );
+ frame.add( glcanvas );
+
+ glcanvas.addGLEventListener( new GLEventListener() {
+ /* @Override */
+ public void init( GLAutoDrawable glautodrawable ) {
+ }
+
+ /* @Override */
+ public void dispose( GLAutoDrawable glautodrawable ) {
+ }
+
+ /* @Override */
+ public void display( GLAutoDrawable glautodrawable ) {
+ Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() );
+ GL2ES1 gl = glautodrawable.getGL().getGL2ES1();
+ OneTriangle.render( gl, rectangle.width, rectangle.height );
+ }
+
+ /* @Override */
+ public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) {
+ Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() );
+ GL2ES1 gl = glautodrawable.getGL().getGL2ES1();
+ OneTriangle.setup( gl, rectangle.width, rectangle.height );
+ }
+ });
+
+ SWTAccessor.invoke(true, new Runnable() {
+ public void run() {
+ shell.setText( getClass().getName() );
+ shell.setSize( 640, 480 );
+ shell.open();
+ }});
+
+ long lStartTime = System.currentTimeMillis();
+ long lEndTime = lStartTime + duration;
+ try {
+ while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) {
+ SWTAccessor.invoke(true, new Runnable() {
+ public void run() {
+ if( !display.readAndDispatch() ) {
+ // blocks on linux .. display.sleep();
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) { }
+ }
+ }});
+ }
+ }
+ catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
+ @Test
+ public void test() throws InterruptedException {
+ GLProfile glprofile = GLProfile.getGL2ES1();
+ runTestGL( glprofile );
+ }
+
+ public static void main(String args[]) {
+ org.junit.runner.JUnitCore.main( TestSWTAWT01GLn.class.getName() );
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java
index ce3100a..f38d5c7 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTEclipseGLCanvas01GLn.java
@@ -1,194 +1,194 @@
-/**
- * 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.swt;
-
-import javax.media.opengl.GL2ES1;
-import javax.media.opengl.GLContext;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLProfile;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.opengl.GLCanvas;
-import org.eclipse.swt.opengl.GLData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.After;
-import org.junit.Test;
-
-import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-/**
- * Tests that a basic SWT app can open without crashing under different GL profiles.
- * <p>
- * Uses the SWT GLCanvas <code>org.eclipse.swt.opengl.GLCanvas</code>.
- * </p>
- * @author Wade Walker, et.al.
- */
-public class TestSWTEclipseGLCanvas01GLn extends UITestCase {
-
- static int duration = 250;
-
- static final int iwidth = 640;
- static final int iheight = 480;
-
- Display display = null;
- Shell shell = null;
- Composite composite = null;
-
- @BeforeClass
- public static void startup() {
- System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
- }
-
- @Before
- public void init() {
- display = new Display();
- Assert.assertNotNull( display );
- shell = new Shell( display );
- Assert.assertNotNull( shell );
- shell.setLayout( new FillLayout() );
- composite = new Composite( shell, SWT.NONE );
- composite.setLayout( new FillLayout() );
- Assert.assertNotNull( composite );
- }
-
- @After
- public void release() {
- Assert.assertNotNull( display );
- Assert.assertNotNull( shell );
- Assert.assertNotNull( composite );
- try {
- composite.dispose();
- shell.dispose();
- display.dispose();
- }
- catch( Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
- }
- display = null;
- shell = null;
- composite = null;
- }
-
- protected void runTestAGL( GLProfile glprofile ) throws InterruptedException {
- GLData gldata = new GLData();
- gldata.doubleBuffer = true;
- // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
- // at the wrong times (we use glClear for this instead)
- final GLCanvas glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
- Assert.assertNotNull( glcanvas );
- glcanvas.setCurrent();
- final GLContext glcontext = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();
- Assert.assertNotNull( glcontext );
-
- // fix the viewport when the user resizes the window
- glcanvas.addListener( SWT.Resize, new Listener() {
- public void handleEvent( Event event ) {
- Rectangle rectangle = glcanvas.getClientArea();
- glcanvas.setCurrent();
- glcontext.makeCurrent();
- GL2ES1 gl = glcontext.getGL().getGL2ES1();
- OneTriangle.setup( gl, rectangle.width, rectangle.height );
- glcontext.release();
- System.err.println("resize");
- }
- });
-
- // draw the triangle when the OS tells us that any part of the window needs drawing
- glcanvas.addPaintListener( new PaintListener() {
- public void paintControl( PaintEvent paintevent ) {
- Rectangle rectangle = glcanvas.getClientArea();
- glcanvas.setCurrent();
- glcontext.makeCurrent();
- GL2ES1 gl = glcontext.getGL().getGL2ES1();
- OneTriangle.render( gl, rectangle.width, rectangle.height );
- glcanvas.swapBuffers();
- glcontext.release();
- System.err.println("paint");
- }
- });
-
- shell.setText( getClass().getName() );
- shell.setSize( 640, 480 );
- shell.open();
-
- long lStartTime = System.currentTimeMillis();
- long lEndTime = lStartTime + duration;
- try {
- while( (System.currentTimeMillis() < lEndTime) && !glcanvas.isDisposed() ) {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- Thread.sleep(10);
- }
- }
- } catch( Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
- }
- glcanvas.dispose();
- }
-
- @Test
- public void test() throws InterruptedException {
- GLProfile glprofile = GLProfile.getGL2ES1();
- runTestAGL( glprofile );
- }
-
- static int atoi(String a) {
- int i=0;
- try {
- i = Integer.parseInt(a);
- } catch (Exception ex) { ex.printStackTrace(); }
- return i;
- }
-
- public static void main(String args[]) {
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-time")) {
- duration = atoi(args[++i]);
- }
- }
- System.out.println("durationPerTest: "+duration);
- org.junit.runner.JUnitCore.main(TestSWTEclipseGLCanvas01GLn.class.getName());
- }
-}
+/**
+ * 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.swt;
+
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLProfile;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.opengl.GLCanvas;
+import org.eclipse.swt.opengl.GLData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Test;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Tests that a basic SWT app can open without crashing under different GL profiles.
+ * <p>
+ * Uses the SWT GLCanvas <code>org.eclipse.swt.opengl.GLCanvas</code>.
+ * </p>
+ * @author Wade Walker, et.al.
+ */
+public class TestSWTEclipseGLCanvas01GLn extends UITestCase {
+
+ static int duration = 250;
+
+ static final int iwidth = 640;
+ static final int iheight = 480;
+
+ Display display = null;
+ Shell shell = null;
+ Composite composite = null;
+
+ @BeforeClass
+ public static void startup() {
+ System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
+ }
+
+ @Before
+ public void init() {
+ display = new Display();
+ Assert.assertNotNull( display );
+ shell = new Shell( display );
+ Assert.assertNotNull( shell );
+ shell.setLayout( new FillLayout() );
+ composite = new Composite( shell, SWT.NONE );
+ composite.setLayout( new FillLayout() );
+ Assert.assertNotNull( composite );
+ }
+
+ @After
+ public void release() {
+ Assert.assertNotNull( display );
+ Assert.assertNotNull( shell );
+ Assert.assertNotNull( composite );
+ try {
+ composite.dispose();
+ shell.dispose();
+ display.dispose();
+ }
+ catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ display = null;
+ shell = null;
+ composite = null;
+ }
+
+ protected void runTestAGL( GLProfile glprofile ) throws InterruptedException {
+ GLData gldata = new GLData();
+ gldata.doubleBuffer = true;
+ // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
+ // at the wrong times (we use glClear for this instead)
+ final GLCanvas glcanvas = new GLCanvas( composite, SWT.NO_BACKGROUND, gldata );
+ Assert.assertNotNull( glcanvas );
+ glcanvas.setCurrent();
+ final GLContext glcontext = GLDrawableFactory.getFactory( glprofile ).createExternalGLContext();
+ Assert.assertNotNull( glcontext );
+
+ // fix the viewport when the user resizes the window
+ glcanvas.addListener( SWT.Resize, new Listener() {
+ public void handleEvent( Event event ) {
+ Rectangle rectangle = glcanvas.getClientArea();
+ glcanvas.setCurrent();
+ glcontext.makeCurrent();
+ GL2ES1 gl = glcontext.getGL().getGL2ES1();
+ OneTriangle.setup( gl, rectangle.width, rectangle.height );
+ glcontext.release();
+ System.err.println("resize");
+ }
+ });
+
+ // draw the triangle when the OS tells us that any part of the window needs drawing
+ glcanvas.addPaintListener( new PaintListener() {
+ public void paintControl( PaintEvent paintevent ) {
+ Rectangle rectangle = glcanvas.getClientArea();
+ glcanvas.setCurrent();
+ glcontext.makeCurrent();
+ GL2ES1 gl = glcontext.getGL().getGL2ES1();
+ OneTriangle.render( gl, rectangle.width, rectangle.height );
+ glcanvas.swapBuffers();
+ glcontext.release();
+ System.err.println("paint");
+ }
+ });
+
+ shell.setText( getClass().getName() );
+ shell.setSize( 640, 480 );
+ shell.open();
+
+ long lStartTime = System.currentTimeMillis();
+ long lEndTime = lStartTime + duration;
+ try {
+ while( (System.currentTimeMillis() < lEndTime) && !glcanvas.isDisposed() ) {
+ if( !display.readAndDispatch() ) {
+ // blocks on linux .. display.sleep();
+ Thread.sleep(10);
+ }
+ }
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ glcanvas.dispose();
+ }
+
+ @Test
+ public void test() throws InterruptedException {
+ GLProfile glprofile = GLProfile.getGL2ES1();
+ runTestAGL( glprofile );
+ }
+
+ static int atoi(String a) {
+ int i=0;
+ try {
+ i = Integer.parseInt(a);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ return i;
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ duration = atoi(args[++i]);
+ }
+ }
+ System.out.println("durationPerTest: "+duration);
+ org.junit.runner.JUnitCore.main(TestSWTEclipseGLCanvas01GLn.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLnAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLnAWT.java
index f7e839c..6abca28 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLnAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLnAWT.java
@@ -1,174 +1,174 @@
-/**
- * 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.swt;
-
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLEventListener;
-import javax.media.opengl.GLProfile;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.After;
-import org.junit.Test;
-
-import com.jogamp.opengl.swt.GLCanvas;
-import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-/**
- * Tests that a basic SWT app can open without crashing under different GL profiles.
- * <p>
- * Uses JOGL's new SWT GLCanvas.
- * </p>
- * <p>
- * Holds AWT in it's test name, since our impl. still needs the AWT threading,
- * see {@link GLCanvas}.
- * </p>
- * @author Wade Walker, et.al.
- */
-public class TestSWTJOGLGLCanvas01GLnAWT extends UITestCase {
-
- static int duration = 250;
-
- static final int iwidth = 640;
- static final int iheight = 480;
-
- Display display = null;
- Shell shell = null;
- Composite composite = null;
-
- @BeforeClass
- public static void startup() {
- System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
- }
-
- @Before
- public void init() {
- display = new Display();
- Assert.assertNotNull( display );
- shell = new Shell( display );
- Assert.assertNotNull( shell );
- shell.setLayout( new FillLayout() );
- composite = new Composite( shell, SWT.NONE );
- composite.setLayout( new FillLayout() );
- Assert.assertNotNull( composite );
- }
-
- @After
- public void release() {
- Assert.assertNotNull( display );
- Assert.assertNotNull( shell );
- Assert.assertNotNull( composite );
- try {
- composite.dispose();
- shell.dispose();
- display.dispose();
- }
- catch( Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
- }
- display = null;
- shell = null;
- composite = null;
- }
-
- protected void runTestAGL( GLProfile glprofile ) throws InterruptedException {
- // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
- // at the wrong times (we use glClear for this instead)
- final GLCapabilitiesImmutable caps = new GLCapabilities( glprofile );
-
- final GLCanvas canvas = new GLCanvas( composite, SWT.NO_BACKGROUND, caps, null, null);
- Assert.assertNotNull( canvas );
-
- canvas.addGLEventListener(new GLEventListener() {
- public void init(final GLAutoDrawable drawable) { }
- public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
- OneTriangle.setup( drawable.getGL().getGL2(), width, height );
- }
- public void display(final GLAutoDrawable drawable) {
- OneTriangle.render( drawable.getGL().getGL2(), drawable.getWidth(), drawable.getHeight());
- }
- public void dispose(final GLAutoDrawable drawable) {}
- });
-
- shell.setText( getClass().getName() );
- shell.setSize( 640, 480 );
- shell.open();
-
- long lStartTime = System.currentTimeMillis();
- long lEndTime = lStartTime + duration;
- try {
- while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) {
- if( !display.readAndDispatch() ) {
- // blocks on linux .. display.sleep();
- Thread.sleep(10);
- }
- }
- } catch( Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
- }
- canvas.dispose();
- }
-
- @Test
- public void test() throws InterruptedException {
- GLProfile glprofile = GLProfile.getGL2ES1();
- runTestAGL( glprofile );
- }
-
- static int atoi(String a) {
- int i=0;
- try {
- i = Integer.parseInt(a);
- } catch (Exception ex) { ex.printStackTrace(); }
- return i;
- }
-
- public static void main(String args[]) {
- for(int i=0; i<args.length; i++) {
- if(args[i].equals("-time")) {
- duration = atoi(args[++i]);
- }
- }
- System.out.println("durationPerTest: "+duration);
- org.junit.runner.JUnitCore.main(TestSWTJOGLGLCanvas01GLnAWT.class.getName());
- }
-}
+/**
+ * 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.swt;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Test;
+
+import com.jogamp.opengl.swt.GLCanvas;
+import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+/**
+ * Tests that a basic SWT app can open without crashing under different GL profiles.
+ * <p>
+ * Uses JOGL's new SWT GLCanvas.
+ * </p>
+ * <p>
+ * Holds AWT in it's test name, since our impl. still needs the AWT threading,
+ * see {@link GLCanvas}.
+ * </p>
+ * @author Wade Walker, et.al.
+ */
+public class TestSWTJOGLGLCanvas01GLnAWT extends UITestCase {
+
+ static int duration = 250;
+
+ static final int iwidth = 640;
+ static final int iheight = 480;
+
+ Display display = null;
+ Shell shell = null;
+ Composite composite = null;
+
+ @BeforeClass
+ public static void startup() {
+ System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() );
+ }
+
+ @Before
+ public void init() {
+ display = new Display();
+ Assert.assertNotNull( display );
+ shell = new Shell( display );
+ Assert.assertNotNull( shell );
+ shell.setLayout( new FillLayout() );
+ composite = new Composite( shell, SWT.NONE );
+ composite.setLayout( new FillLayout() );
+ Assert.assertNotNull( composite );
+ }
+
+ @After
+ public void release() {
+ Assert.assertNotNull( display );
+ Assert.assertNotNull( shell );
+ Assert.assertNotNull( composite );
+ try {
+ composite.dispose();
+ shell.dispose();
+ display.dispose();
+ }
+ catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ display = null;
+ shell = null;
+ composite = null;
+ }
+
+ protected void runTestAGL( GLProfile glprofile ) throws InterruptedException {
+ // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
+ // at the wrong times (we use glClear for this instead)
+ final GLCapabilitiesImmutable caps = new GLCapabilities( glprofile );
+
+ final GLCanvas canvas = new GLCanvas( composite, SWT.NO_BACKGROUND, caps, null, null);
+ Assert.assertNotNull( canvas );
+
+ canvas.addGLEventListener(new GLEventListener() {
+ public void init(final GLAutoDrawable drawable) { }
+ public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
+ OneTriangle.setup( drawable.getGL().getGL2(), width, height );
+ }
+ public void display(final GLAutoDrawable drawable) {
+ OneTriangle.render( drawable.getGL().getGL2(), drawable.getWidth(), drawable.getHeight());
+ }
+ public void dispose(final GLAutoDrawable drawable) {}
+ });
+
+ shell.setText( getClass().getName() );
+ shell.setSize( 640, 480 );
+ shell.open();
+
+ long lStartTime = System.currentTimeMillis();
+ long lEndTime = lStartTime + duration;
+ try {
+ while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) {
+ if( !display.readAndDispatch() ) {
+ // blocks on linux .. display.sleep();
+ Thread.sleep(10);
+ }
+ }
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ canvas.dispose();
+ }
+
+ @Test
+ public void test() throws InterruptedException {
+ GLProfile glprofile = GLProfile.getGL2ES1();
+ runTestAGL( glprofile );
+ }
+
+ static int atoi(String a) {
+ int i=0;
+ try {
+ i = Integer.parseInt(a);
+ } catch (Exception ex) { ex.printStackTrace(); }
+ return i;
+ }
+
+ public static void main(String args[]) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ duration = atoi(args[++i]);
+ }
+ }
+ System.out.println("durationPerTest: "+duration);
+ org.junit.runner.JUnitCore.main(TestSWTJOGLGLCanvas01GLnAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestGrayTextureFromFileAWTBug417.java b/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestGrayTextureFromFileAWTBug417.java
deleted file mode 100644
index d43a3a0..0000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestGrayTextureFromFileAWTBug417.java
+++ /dev/null
@@ -1,150 +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.texture;
-
-import com.jogamp.opengl.test.junit.jogl.util.texture.gl2.TextureGL2ListenerDraw1;
-
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLProfile;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.texture.TextureIO;
-import com.jogamp.opengl.util.Animator;
-
-import java.awt.Frame;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Assert;
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Unit test for bug 417, which shows a GLException when reading a grayscale texture.
- * Couldn't duplicate the failure, so it must have been fixed unknowingly sometime
- * after the bug was submitted.
- * @author Wade Walker
- */
-public class TestGrayTextureFromFileAWTBug417 extends UITestCase {
- static GLProfile glp;
- static GLCapabilities caps;
- InputStream textureStream;
-
- @BeforeClass
- public static void initClass() {
- if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
- UITestCase.setTestSupported(false);
- return;
- }
- glp = GLProfile.getGL2GL3();
- Assert.assertNotNull(glp);
- caps = new GLCapabilities(glp);
- Assert.assertNotNull(caps);
- }
-
- @Before
- public void initTest() {
- textureStream = TestGrayTextureFromFileAWTBug417.class.getResourceAsStream( "grayscale_texture.png" );
- Assert.assertNotNull(textureStream);
- }
-
- @After
- public void cleanupTest() {
- textureStream=null;
- }
-
- @Test
- public void test1() throws InterruptedException {
- final GLCanvas glCanvas = new GLCanvas(caps);
- final Frame frame = new Frame("Texture Test");
- Assert.assertNotNull(frame);
- frame.add(glCanvas);
- frame.setSize( 256, 128 );
-
- // load texture from file inside current GL context to match the way
- // the bug submitter was doing it
- glCanvas.addGLEventListener(new TextureGL2ListenerDraw1( null ) {
- @Override
- public void init(GLAutoDrawable drawable) {
- try {
- setTexture( TextureIO.newTexture( textureStream, true, TextureIO.PNG ) );
- }
- catch(GLException glexception) {
- glexception.printStackTrace();
- Assume.assumeNoException(glexception);
- }
- catch(IOException ioexception) {
- ioexception.printStackTrace();
- Assume.assumeNoException(ioexception);
- }
- }
- });
-
- Animator animator = new Animator(glCanvas);
- frame.setVisible(true);
- animator.start();
-
- Thread.sleep(500); // 500 ms
-
- animator.stop();
- try {
- javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- frame.setVisible(false);
- frame.remove(glCanvas);
- frame.dispose();
- }});
- } catch( Throwable throwable ) {
- throwable.printStackTrace();
- Assume.assumeNoException( throwable );
- }
- }
-
- public static void main(String args[]) throws IOException {
- String tstname = TestGrayTextureFromFileAWTBug417.class.getName();
- org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] {
- tstname,
- "filtertrace=true",
- "haltOnError=false",
- "haltOnFailure=false",
- "showoutput=true",
- "outputtoformatters=true",
- "logfailedtests=true",
- "logtestlistenerevents=true",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter",
- "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } );
- }
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
index 5a0c18d..c7e975f 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java
@@ -18,7 +18,7 @@ public class TestPNGImage01NEWT extends UITestCase {
final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png");
final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png");
final String url_s="jogl/util/data/av/test-ntsc01-160x90.png";
- URLConnection urlConn = IOUtil.getResource(url_s, PNGImage.class.getClassLoader());
+ URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader());
PNGImage image0 = PNGImage.read(urlConn.getInputStream());
System.err.println("PNGImage - Orig: "+image0);
image0.write(out1_f, true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
similarity index 98%
rename from src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java
rename to src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
index ab8e542..687465a 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.util;
+package com.jogamp.opengl.test.junit.jogl.util.texture;
import java.io.File;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
similarity index 99%
rename from src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java
rename to src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
index 79ae316..6bb7f3b 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestGLReadBufferUtilTextureIOWrite02NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java
@@ -26,7 +26,7 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.util;
+package com.jogamp.opengl.test.junit.jogl.util.texture;
import java.io.File;
import java.io.PrintWriter;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java
new file mode 100644
index 0000000..0687326
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java
@@ -0,0 +1,238 @@
+/**
+ * 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.util.texture;
+
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.awt.GLCanvas;
+
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.util.texture.spi.TextureProvider;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+
+import java.awt.Dimension;
+import java.awt.Frame;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLConnection;
+
+import org.junit.Assert;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit test for bug 417, which shows a GLException when reading a grayscale texture.
+ * Couldn't duplicate the failure, so it must have been fixed unknowingly sometime
+ * after the bug was submitted.
+ * @author Wade Walker, et.al.
+ */
+public class TestPNGTextureFromFileAWT extends UITestCase {
+ static boolean showFPS = false;
+ static long duration = 100; // ms
+ InputStream grayTextureStream;
+ InputStream testTextureStream;
+
+ @BeforeClass
+ public static void initClass() {
+ }
+
+ @Before
+ public void initTest() throws IOException {
+ grayTextureStream = TestPNGTextureFromFileAWT.class.getResourceAsStream( "grayscale_texture.png" );
+ Assert.assertNotNull(grayTextureStream);
+ URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
+ Assert.assertNotNull(testTextureUrlConn);
+ testTextureStream = testTextureUrlConn.getInputStream();
+ Assert.assertNotNull(testTextureStream);
+ }
+
+ @After
+ public void cleanupTest() {
+ grayTextureStream = null;
+ testTextureStream = null;
+ }
+
+ protected void snapshot(GLAutoDrawable drawable, String filename) {
+ GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
+ if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+ public void testImpl(boolean useFFP, final InputStream istream, final boolean useAWTIIOP)
+ throws InterruptedException, IOException
+ {
+ GLProfile glp;
+ if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ glp = GLProfile.getGL2GL3();
+ } else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.getGL2ES2();
+ } else {
+ System.err.println(getSimpleTestName(".")+": GLProfile n/a, useFFP: "+useFFP);
+ return;
+ }
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final TextureData texData;
+ if(useAWTIIOP) {
+ final TextureProvider texProvider = new com.jogamp.opengl.util.texture.spi.awt.IIOTextureProvider();
+ texData = texProvider.newTextureData(glp, istream, 0 /* internalFormat */, 0 /* pixelFormat */, false /* mipmap */, TextureIO.PNG);
+ } else {
+ texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG);
+ }
+ System.err.println("TextureData: "+texData);
+
+ final GLCanvas glc = new GLCanvas(caps);
+ Dimension glc_sz = new Dimension(texData.getWidth(), texData.getHeight());
+ glc.setMinimumSize(glc_sz);
+ glc.setPreferredSize(glc_sz);
+ final Frame frame = new Frame("TestPNGTextureGL2FromFileAWT");
+ Assert.assertNotNull(frame);
+ frame.add(glc);
+
+ // load texture from file inside current GL context to match the way
+ // the bug submitter was doing it
+ final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ;
+ glc.addGLEventListener(gle);
+ glc.addGLEventListener(new GLEventListener() {
+ boolean shot = false;
+
+ @Override public void init(GLAutoDrawable drawable) {}
+
+ @Override
+ public void display(GLAutoDrawable drawable) {
+ // 1 snapshot
+ if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) {
+ shot = true;
+ snapshot(drawable, getSimpleTestName(".")+".png");
+ }
+ }
+
+ @Override public void dispose(GLAutoDrawable drawable) { }
+ @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+
+ Animator animator = new Animator(glc);
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+ QuitAdapter quitAdapter = new QuitAdapter();
+ new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc);
+ new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc);
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.pack();
+ frame.setVisible(true);
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ animator.start();
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ frame.remove(glc);
+ frame.dispose();
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
+ @Test
+ public void testGrayAWTILoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, grayTextureStream, true);
+ }
+ @Test
+ public void testGrayAWTILoaderES2() throws InterruptedException, IOException {
+ testImpl(false, grayTextureStream, true);
+ }
+
+ @Test
+ public void testGrayPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, grayTextureStream, false);
+ }
+ @Test
+ public void testGrayPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, grayTextureStream, false);
+ }
+
+ @Test
+ public void testTestAWTILoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, testTextureStream, true);
+ }
+ @Test
+ public void testTestAWTILoaderES2() throws InterruptedException, IOException {
+ testImpl(false, testTextureStream, true);
+ }
+
+ @Test
+ public void testTestPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, testTextureStream, false);
+ }
+ @Test
+ public void testTestPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, testTextureStream, false);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestPNGTextureFromFileAWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java
new file mode 100644
index 0000000..d973dea
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java
@@ -0,0 +1,173 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.opengl.test.junit.jogl.util.texture;
+
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLCapabilities;
+
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLReadBufferUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLConnection;
+
+import org.junit.Assert;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestPNGTextureFromFileNEWT extends UITestCase {
+ static boolean showFPS = false;
+ static long duration = 100; // ms
+ InputStream grayTextureStream;
+ InputStream testTextureStream;
+
+ @Before
+ public void initTest() throws IOException {
+ grayTextureStream = TestPNGTextureFromFileNEWT.class.getResourceAsStream( "grayscale_texture.png" );
+ Assert.assertNotNull(grayTextureStream);
+ URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader());
+ Assert.assertNotNull(testTextureUrlConn);
+ testTextureStream = testTextureUrlConn.getInputStream();
+ Assert.assertNotNull(testTextureStream);
+ }
+
+ @After
+ public void cleanupTest() {
+ grayTextureStream = null;
+ testTextureStream = null;
+ }
+
+ protected void snapshot(GLAutoDrawable drawable, String filename) {
+ GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false);
+ if(screenshot.readPixels(drawable.getGL(), drawable, false)) {
+ screenshot.write(new File(filename));
+ }
+ }
+
+ public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException {
+ GLProfile glp;
+ if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) {
+ glp = GLProfile.getGL2GL3();
+ } else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
+ glp = GLProfile.getGL2ES2();
+ } else {
+ System.err.println(getSimpleTestName(".")+": GLProfile n/a, useFFP: "+useFFP);
+ return;
+ }
+ final GLCapabilities caps = new GLCapabilities(glp);
+ final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG);
+ System.err.println("TextureData: "+texData);
+
+ final GLWindow glad = GLWindow.create(caps);
+ glad.setTitle("TestPNGTextureGL2FromFileNEWT");
+ // Size OpenGL to Video Surface
+ glad.setSize(texData.getWidth(), texData.getHeight());
+
+ // load texture from file inside current GL context to match the way
+ // the bug submitter was doing it
+ final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ;
+ glad.addGLEventListener(gle);
+ glad.addGLEventListener(new GLEventListener() {
+ boolean shot = false;
+
+ @Override public void init(GLAutoDrawable drawable) {}
+
+ public void display(GLAutoDrawable drawable) {
+ // 1 snapshot
+ if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) {
+ shot = true;
+ snapshot(drawable, getSimpleTestName(".")+".png");
+ }
+ }
+
+ @Override public void dispose(GLAutoDrawable drawable) { }
+ @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+
+ Animator animator = new Animator(glad);
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+ QuitAdapter quitAdapter = new QuitAdapter();
+ glad.addKeyListener(quitAdapter);
+ glad.addWindowListener(quitAdapter);
+ glad.setVisible(true);
+ animator.start();
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ glad.destroy();
+ }
+
+ @Test
+ public void testGrayPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, grayTextureStream);
+ }
+ @Test
+ public void testGrayPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, grayTextureStream);
+ }
+
+ @Test
+ public void testTestPNGJLoaderGL2() throws InterruptedException, IOException {
+ testImpl(true, testTextureStream);
+ }
+ @Test
+ public void testTestPNGJLoaderES2() throws InterruptedException, IOException {
+ testImpl(false, testTextureStream);
+ }
+
+ public static void main(String args[]) throws IOException {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestPNGTextureFromFileNEWT.class.getName());
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestTexture01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java
similarity index 96%
rename from src/test/com/jogamp/opengl/test/junit/jogl/texture/TestTexture01AWT.java
rename to src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java
index 217b8ac..2d7b3b0 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestTexture01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java
@@ -26,10 +26,10 @@
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.test.junit.jogl.texture;
+package com.jogamp.opengl.test.junit.jogl.util.texture;
-import com.jogamp.opengl.test.junit.jogl.util.texture.gl2.TextureGL2ListenerDraw1;
+import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener;
import com.jogamp.opengl.test.junit.util.UITestCase;
import javax.media.opengl.GLProfile;
@@ -115,7 +115,7 @@ public class TestTexture01AWT extends UITestCase {
// create texture
TextureData textureData = AWTTextureIO.newTextureData(caps.getGLProfile(), textureImage, false);
- glCanvas.addGLEventListener(new TextureGL2ListenerDraw1(textureData));
+ glCanvas.addGLEventListener(new TextureDraw01GL2Listener(textureData));
Animator animator = new Animator(glCanvas);
frame.setVisible(true);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java
new file mode 100644
index 0000000..36dad45
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java
@@ -0,0 +1,112 @@
+package com.jogamp.opengl.test.junit.jogl.util.texture;
+
+import java.awt.Frame;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.awt.GLCanvas;
+
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.opengl.test.junit.jogl.demos.TextureSequenceDemo01;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestTextureSequence01AWT extends UITestCase {
+ static boolean showFPS = false;
+ static int width = 510;
+ static int height = 300;
+ static boolean useBuildInTexLookup = false;
+ static long duration = 500; // ms
+ static GLProfile glp;
+ static GLCapabilities caps;
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getGL2ES2();
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ }
+
+ void testImpl() throws InterruptedException {
+ final GLCanvas glc = new GLCanvas(caps);
+ final Frame frame = new Frame("TestTextureSequence01AWT");
+ Assert.assertNotNull(frame);
+ frame.add(glc);
+ frame.setSize(width, height);
+
+ final TextureSequenceDemo01 texSource = new TextureSequenceDemo01(useBuildInTexLookup);
+ glc.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ texSource.initGLResources(drawable.getGL());
+ }
+ @Override
+ public void dispose(GLAutoDrawable drawable) { }
+ @Override
+ public void display(GLAutoDrawable drawable) { }
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+ glc.addGLEventListener(new TextureSequenceCubeES2(texSource, false, -2.3f, 0f, 0f));
+ final Animator animator = new Animator(glc);
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+ QuitAdapter quitAdapter = new QuitAdapter();
+ new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc);
+ new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc);
+ frame.setVisible(true);
+ animator.start();
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+ try {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame.setVisible(false);
+ frame.remove(glc);
+ frame.dispose();
+ }});
+ } catch( Throwable throwable ) {
+ throwable.printStackTrace();
+ Assume.assumeNoException( throwable );
+ }
+ }
+
+ @Test
+ public void test1() throws InterruptedException {
+ testImpl();
+ }
+
+ public static void main(String[] args) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-width")) {
+ i++;
+ width = MiscUtils.atoi(args[i], width);
+ } else if(args[i].equals("-height")) {
+ i++;
+ height = MiscUtils.atoi(args[i], height);
+ } else if(args[i].equals("-shaderBuildIn")) {
+ useBuildInTexLookup = true;
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestTextureSequence01AWT.class.getName());
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java
new file mode 100644
index 0000000..ae4d2c3
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java
@@ -0,0 +1,97 @@
+package com.jogamp.opengl.test.junit.jogl.util.texture;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.test.junit.jogl.demos.TextureSequenceDemo01;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.test.junit.util.QuitAdapter;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+import com.jogamp.opengl.util.Animator;
+
+public class TestTextureSequence01NEWT extends UITestCase {
+ static boolean showFPS = false;
+ static int width = 510;
+ static int height = 300;
+ static boolean useBuildInTexLookup = false;
+ static long duration = 500; // ms
+ static GLProfile glp;
+ static GLCapabilities caps;
+
+ @BeforeClass
+ public static void initClass() {
+ glp = GLProfile.getGL2ES2();
+ Assert.assertNotNull(glp);
+ caps = new GLCapabilities(glp);
+ Assert.assertNotNull(caps);
+ }
+
+ void testImpl() throws InterruptedException {
+ final GLWindow window = GLWindow.create(caps);
+ window.setTitle("TestTextureSequence01NEWT");
+ // Size OpenGL to Video Surface
+ window.setSize(width, height);
+ final TextureSequenceDemo01 texSource = new TextureSequenceDemo01(useBuildInTexLookup);
+ window.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ texSource.initGLResources(drawable.getGL());
+ }
+ @Override
+ public void dispose(GLAutoDrawable drawable) { }
+ @Override
+ public void display(GLAutoDrawable drawable) { }
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+ window.addGLEventListener(new TextureSequenceCubeES2(texSource, false, -2.3f, 0f, 0f));
+ final Animator animator = new Animator(window);
+ animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
+ QuitAdapter quitAdapter = new QuitAdapter();
+ window.addKeyListener(quitAdapter);
+ window.addWindowListener(quitAdapter);
+ animator.start();
+ window.setVisible(true);
+
+ while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
+ Thread.sleep(100);
+ }
+
+ animator.stop();
+ Assert.assertFalse(animator.isAnimating());
+ Assert.assertFalse(animator.isStarted());
+ window.destroy();
+ }
+
+ @Test
+ public void test1() throws InterruptedException {
+ testImpl();
+ }
+
+ public static void main(String[] args) {
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-time")) {
+ i++;
+ duration = MiscUtils.atol(args[i], duration);
+ } else if(args[i].equals("-width")) {
+ i++;
+ width = MiscUtils.atoi(args[i], width);
+ } else if(args[i].equals("-height")) {
+ i++;
+ height = MiscUtils.atoi(args[i], height);
+ } else if(args[i].equals("-shaderBuildIn")) {
+ useBuildInTexLookup = true;
+ }
+ }
+ org.junit.runner.JUnitCore.main(TestTextureSequence01NEWT.class.getName());
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/texture/grayscale_texture.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png
similarity index 100%
rename from src/test/com/jogamp/opengl/test/junit/jogl/texture/grayscale_texture.png
rename to src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png
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 c74d2ea..4edac15 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java
@@ -36,7 +36,6 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -52,8 +51,7 @@ public class NEWTGLContext {
}
}
- public static WindowContext createOffscreenWindow(GLProfile glp, int width, int height, boolean debugGL) throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
+ public static WindowContext createOffscreenWindow(GLCapabilities caps, int width, int height, boolean debugGL) throws InterruptedException {
caps.setOnscreen(false);
caps.setPBuffer(true);
@@ -73,7 +71,7 @@ public class NEWTGLContext {
AWTRobotUtil.waitForVisible(window, true);
AWTRobotUtil.waitForRealized(window, true);
- GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
+ GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
GLDrawable drawable = factory.createGLDrawable(window);
Assert.assertNotNull(drawable);
@@ -91,8 +89,7 @@ public class NEWTGLContext {
return new WindowContext(window, context);
}
- public static WindowContext createOnscreenWindow(GLProfile glp, int width, int height, boolean debugGL) throws InterruptedException {
- GLCapabilities caps = new GLCapabilities(glp);
+ public static WindowContext createOnscreenWindow(GLCapabilities caps, int width, int height, boolean debugGL) throws InterruptedException {
//
// Create native windowing resources .. X11/Win/OSX
//
@@ -109,7 +106,7 @@ public class NEWTGLContext {
Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true));
Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true));
- GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
+ GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
GLDrawable drawable = factory.createGLDrawable(window);
Assert.assertNotNull(drawable);
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 368291a..672675f 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
@@ -28,7 +28,6 @@
package com.jogamp.opengl.test.junit.util;
-import com.jogamp.common.os.Platform;
import com.jogamp.common.util.locks.SingletonInstance;
import org.junit.Assume;
@@ -38,7 +37,6 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Rule;
import org.junit.rules.TestName;
-import org.junit.runner.manipulation.NoTestsRemainException;
public abstract class UITestCase {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libjogl2-java.git
More information about the pkg-java-commits
mailing list