summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build-common.xml5
-rw-r--r--make/build-test.xml103
-rw-r--r--make/build.xml28
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-common.java6
-rwxr-xr-xmake/scripts/make.jogl.all.android-armv7-cross.sh4
-rwxr-xr-xmake/scripts/tests.sh4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java69
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java36
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java29
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java49
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java9
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java23
-rw-r--r--src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java126
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java9
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java8
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java12
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java18
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java5
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java5
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java11
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java14
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java4
28 files changed, 352 insertions, 287 deletions
diff --git a/make/build-common.xml b/make/build-common.xml
index 6f2a9900a..e560cd8b9 100644
--- a/make/build-common.xml
+++ b/make/build-common.xml
@@ -387,6 +387,7 @@
<!-- JavaSE combinations -->
<property name="gluegen-rt.jar" value="${build.gluegen}/gluegen-rt.jar" />
<property name="jogl.test.jar" value="${jar}/jogl.test.jar"/>
+ <property name="jogl.test.apk" value="${jar}/jogl.test.apk"/>
<!-- JavaSE combinations . AWT -->
<property name="jogl.all.jar" value="${jar}/jogl.all.jar" />
@@ -395,6 +396,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" />
<path id="swt_gluegen.classpath">
<pathelement location="${gluegen-rt.jar}" />
@@ -464,8 +466,7 @@
<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="${ant-junit-all.apk}${path.separator}${gluegen.root}/${rootrel.build}/gluegen.apk${path.separator}${build_t}/gluegen-test.apk"/-->
-
+ <property name="junit.run.remote.apks" value="${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">
diff --git a/make/build-test.xml b/make/build-test.xml
index 0dc5e07d7..8a3bb3d24 100644
--- a/make/build-test.xml
+++ b/make/build-test.xml
@@ -56,25 +56,22 @@
<!--
- Build/run tests/junit.
-->
- <target name="test.compile.check" depends="declare.common">
- <!-- Create the required output directories. -->
- <mkdir dir="${obj.test}" />
- <mkdir dir="${classes}" />
-
- <property name="jogl.test.jar.path" location="${jogl.test.jar}"/> <!-- absolute path -->
- <echo message="jogl.test.jar ${jogl.test.jar.path}"/>
- <uptodate property="test.compile.skip">
- <srcfiles dir= "." includes="*.xml"/>
- <srcfiles dir= "${src.test}" includes="**"/>
- <srcfiles file="${gluegen.jar}" />
- <srcfiles dir="${src}/nativewindow" />
- <srcfiles dir="${src}/jogl" />
- <srcfiles dir="${src}/newt" />
- <mapper type="merge" to="${jogl.test.jar.path}"/>
- </uptodate>
+ <target name="android.test.package" if="isAndroid">
+ <aapt.signed
+ 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-jogl"
+ jarmanifest.path="${build.jogl}/manifest.mf"
+ version.code="${jogl_int_version}"
+ version.name="${jogl.version.plus}" />
</target>
- <target name="test.compile" depends="test.compile.check" unless="test.compile.skip">
+ <target name="test.compile.java">
<!-- Perform the junit pass Java compile -->
<javac destdir="${classes}"
fork="yes"
@@ -103,6 +100,29 @@
</jar>
</target>
+ <target name="test.compile.check" depends="declare.common">
+ <!-- Create the required output directories. -->
+ <mkdir dir="${obj.test}" />
+ <mkdir dir="${classes}" />
+
+ <property name="jogl.test.jar.path" location="${jogl.test.jar}"/> <!-- absolute path -->
+ <echo message="jogl.test.jar ${jogl.test.jar.path}"/>
+ <uptodate property="test.compile.skip">
+ <srcfiles dir= "." includes="*.xml"/>
+ <srcfiles dir= "${src.test}" includes="**"/>
+ <srcfiles file="${gluegen.jar}" />
+ <srcfiles dir="${src}/nativewindow" />
+ <srcfiles dir="${src}/jogl" />
+ <srcfiles dir="${src}/newt" />
+ <mapper type="merge" to="${jogl.test.jar.path}"/>
+ </uptodate>
+ </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"/>
+ </target>
+
<target name="test.manual.run" depends="test.compile">
<for param="test.class.path.m" keepgoing="true">
<!-- results in absolute path -->
@@ -756,40 +776,56 @@ ${line.separator}
</exec>
</target>
+<!--
+rsync:
+ -a == -rlptgoD
+ -rt
+-->
+
<target name="junit.run.remote.adb" if="isAndroidARMv7">
<echo message="#! /system/bin/sh${line.separator}" append="false" file="${build.test}/targetcommand.sh" />
<echo message="${line.separator}
-rsync -av --delete --delete-after --delete-excluded \${line.separator}
+rsync -rtv --delete --delete-after --delete-excluded \${line.separator}
--exclude 'build-x86*/' --exclude 'build-linux*/' --exclude 'build-win*/' --exclude 'build-mac*/' \${line.separator}
--exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \${line.separator}
- ${env.HOST_UID}@${env.HOST_IP}::${env.HOST_RSYNC_ROOT}/${jogl.basename} ${env.TARGET_ROOT} ${line.separator}
+ --exclude 'gensrc/' --exclude 'doc/' --exclude 'jnlp-files' --exclude 'archive/' \${line.separator}
+ --exclude 'android-sdk/' --exclude 'resources/' --exclude 'scripts/' \${line.separator}
+ --exclude 'stub_includes/' --exclude 'nbproject/' --exclude '*.log' --exclude '*.zip' --exclude '*.7z' \${line.separator}
+ ${env.HOST_UID}@${env.HOST_IP}::${env.HOST_RSYNC_ROOT}/${gluegen.basename} \${line.separator}
+ ${env.HOST_UID}@${env.HOST_IP}::${env.HOST_RSYNC_ROOT}/${jogl.basename} \${line.separator}
+ ${env.TARGET_ROOT} ${line.separator}
+mkdir ${env.TARGET_ROOT}/tmp ${line.separator}
cd ${env.TARGET_ROOT}/${jogl.basename}/${env.NODE_LABEL}/make ${line.separator}
-export ${system.env.library.path}=/system/lib:${env.TARGET_ROOT}/${gluegen.basename}/${rootrel.build}/obj:${env.TARGET_ROOT}/${gluegen.basename}/${rootrel.build}/test/build/natives ${line.separator}
-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 ${line.separator}
+export ${system.env.library.path}=/system/lib:${env.TARGET_ROOT}/${gluegen.basename}/${env.NODE_LABEL}/${rootrel.build}/obj:${env.TARGET_ROOT}/${jogl.basename}/${env.NODE_LABEL}/${rootrel.build}/lib ${line.separator}
+# 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 ${line.separator}
" append="true" file="${build.test}/targetcommand.sh" />
<for param="test.class.path.m" keepgoing="true">
<!-- results in absolute path -->
- <fileset dir="${build_t.java}">
- <include name="${test.junit.rel}/**/*Test*"/>
+ <fileset dir="${classes}">
+ <!--include name="${java.dir.junit}/**/Test*NEWT*"/-->
+ <include name="${java.dir.junit}/**/TestMainVersionGLWindowNEWT*"/>
+ <!--include name="${java.dir.junit}/**/TestGLProfile01NEWT*"/-->
<exclude name="**/*$$*"/>
</fileset>
<sequential>
<var name="test.class.path" unset="true"/>
- <property name="test.class.path" basedir="${build_t.java}" relative="true" location="@{test.class.path.m}"/>
+ <property name="test.class.path" basedir="${classes}" relative="true" location="@{test.class.path.m}"/>
<var name="test.class.fqn" unset="true"/>
<pathconvert property="test.class.fqn">
- <fileset file="${build_t.java}${file.separator}${test.class.path}"/>
+ <fileset file="${classes}${file.separator}${test.class.path}"/>
<chainedmapper>
- <globmapper from="${build_t.java.path}${file.separator}*" to="*"/> <!-- rel. -->
+ <globmapper from="${classes.path}${file.separator}*" to="*"/> <!-- rel. -->
<packagemapper from="*.class" to="*"/> <!-- FQCN -->
</chainedmapper>
</pathconvert>
- <var name="test.class.result.file" value="${results}/TEST-${test.class.fqn}.xml"/>
+ <var name="test.class.result.file" value="${results.test}/TEST-${test.class.fqn}.xml"/>
<echo message="Testing ${test.class.fqn} -- ${test.class.result.file}"/>
<echo message="${line.separator}
dalvikvm \${line.separator}
-Xjnigreflimit:2000 \${line.separator}
+${junit.run.arg0}\${line.separator}
+${junit.run.arg1}\${line.separator}
-cp ${junit.run.remote.apks} \${line.separator}
-Dgluegen.root=${gluegen.root} \${line.separator}
-Drootrel.build=${rootrel.build} \${line.separator}
@@ -806,19 +842,20 @@ logtestlistenerevents=true \${line.separator}
formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter \${line.separator}
formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.class.result.file} ${line.separator}
${line.separator}
-" append="true" file="${build_t}/targetcommand.sh" />
+" append="true" file="${build.test}/targetcommand.sh" />
</sequential>
</for>
<exec dir="." executable="sh" logError="true" failonerror="true" failifexecutionfails="true">
<arg line='-x -c "
- chmod 0755 ${build_t}/targetcommand.sh ;
- adb push ${build_t}/targetcommand.sh ${env.TARGET_ROOT}/jogl-targetcommand.sh ;
- adb shell ${env.TARGET_ROOT}/jogl-targetcommand.sh ;
- adb pull ${env.TARGET_ROOT}/${jogl.basename}/${env.NODE_LABEL}/make/${results}/ ${results}/ "'/>
+ chmod 0755 ${build.test}/targetcommand.sh ;
+ adb connect ${env.TARGET_IP}:${env.TARGET_ADB_PORT} ;
+ adb -s ${env.TARGET_IP}:${env.TARGET_ADB_PORT} push ${build.test}/targetcommand.sh ${env.TARGET_ROOT}/jogl-targetcommand.sh ;
+ adb -s ${env.TARGET_IP}:${env.TARGET_ADB_PORT} shell ${env.TARGET_ROOT}/jogl-targetcommand.sh ;
+ adb -s ${env.TARGET_IP}:${env.TARGET_ADB_PORT} pull ${env.TARGET_ROOT}/${jogl.basename}/${env.NODE_LABEL}/make/${results.test}/ ${results.test}/ "'/>
</exec>
</target>
- <target name="junit.run.tests" depends="junit.run.local.d32, junit.run.local, junit.run.remote.ssh.newt"/>
+ <target name="junit.run.tests" depends="junit.run.local.d32, junit.run.local, junit.run.remote.ssh.newt, junit.run.remote.adb"/>
<target name="junit.run.settings" depends="declare.common">
<delete quiet="true">
diff --git a/make/build.xml b/make/build.xml
index a39707769..5a17812e0 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -16,12 +16,10 @@
<target name="all.ide" description="Debug IDE build nativewindow, jogl and newt projects, including all junit tests, but don't tag the build or create archives" depends="init.debug,build.nativewindow,build.jogl,build.newt,one.dir,test.compile" />
- <target name="test.compile.1">
+ <target name="test.compile">
<ant antfile="build-test.xml" target="test.compile" inheritRefs="true" inheritAll="true"/>
</target>
- <target name="test.compile" depends="test.compile.1,android.test.package"/>
-
<target name="test.auto.run" description="Run automated tests (junit and others) in nativewindow, jogl and newt projects">
<ant antfile="build-test.xml" target="test.auto.run" inheritRefs="true" inheritAll="true"/>
</target>
@@ -149,7 +147,7 @@
</target>
<target name="android.package.jogl.skip.check" depends="init,gluegen.cpptasks.detect.os">
- <uptodate property="android.package.jogl.skip" targetfile="${jar}/jogl.all-android.apk">
+ <uptodate property="android.package.jogl.skip" targetfile="${jogl.all-android.apk}">
<srcfiles dir="${jar}" includes="jogl.all-android.jar" />
<srcfiles dir="resources/android" includes="**" />
</uptodate>
@@ -170,28 +168,6 @@
version.name="${jogl.version.plus}" />
</target>
- <target name="android.package.test.skip.check" depends="init,gluegen.cpptasks.detect.os">
- <uptodate property="android.package.test.skip" targetfile="${jar}/jogl.test.apk">
- <srcfiles dir="${jar}" includes="jogl.test.jar" />
- <srcfiles dir="resources/android" includes="**" />
- </uptodate>
- </target>
-
- <target name="android.test.package" depends="init,gluegen.cpptasks.detect.os,android.package.test.skip.check" if="isAndroid" unless="android.package.test.skip">
- <aapt.signed
- 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-jogl"
- jarmanifest.path="${build.jogl}/manifest.mf"
- version.code="${jogl_int_version}"
- version.name="${jogl.version.plus}" />
- </target>
-
<target name="android.launcher.package" depends="init,gluegen.cpptasks.detect.os" if="isAndroid">
<mkdir dir="${build}/android/classes" />
<mkdir dir="${build}/android/lib" />
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java
index 0a8e90171..2c3227ee5 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-common.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java
@@ -48,10 +48,16 @@
private GLContextImpl _context;
+ /**
+ * @see javax.media.opengl.GLContext#setSwapInterval(int)
+ */
public void setSwapInterval(int interval) {
_context.setSwapInterval(interval);
}
+ /**
+ * @see javax.media.opengl.GLContext#getSwapInterval()
+ */
public int getSwapInterval() {
return _context.getSwapInterval();
}
diff --git a/make/scripts/make.jogl.all.android-armv7-cross.sh b/make/scripts/make.jogl.all.android-armv7-cross.sh
index 25ff05a22..4f302355e 100755
--- a/make/scripts/make.jogl.all.android-armv7-cross.sh
+++ b/make/scripts/make.jogl.all.android-armv7-cross.sh
@@ -8,9 +8,9 @@ export HOST_IP=10.1.0.122
export HOST_RSYNC_ROOT=PROJECTS/JOGL
export TARGET_UID=jogamp
-#export TARGET_IP=panda02
+export TARGET_IP=panda02
#export TARGET_IP=jautab03
-export TARGET_IP=jauphone04
+#export TARGET_IP=jauphone04
export TARGET_ADB_PORT=5555
# needs executable bit (probably su)
export TARGET_ROOT=/data/projects
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 6e8627813..c61b03fab 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -205,7 +205,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $*
@@ -261,7 +261,7 @@ function testawtswt() {
#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn $*
#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn $*
#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTGLCanvas01GLn $*
-testawt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $*
+#testawt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $*
#
# awtswt (testawtswt)
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
index 85e288638..eec055ed4 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -295,39 +295,43 @@ public class ShaderCode {
}
}
- private static int readShaderSource(Class<?> context, URL url, StringBuffer result, int lineno) {
+ private static int readShaderSource(Class<?> context, URL url, StringBuffer result, int lineno) {
try {
if(DEBUG_CODE) {
System.err.printf("%3d: // %s\n", lineno, url);
}
- BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
- String line = null;
- while ((line = reader.readLine()) != null) {
- lineno++;
- if(DEBUG_CODE) {
- System.err.printf("%3d: %s\n", lineno, line);
- }
- if (line.startsWith("#include ")) {
- String includeFile = line.substring(9).trim();
- URL nextURL = null;
-
- // Try relative path first
- String next = IOUtil.getRelativeOf(url, includeFile);
- if(null != next) {
- nextURL = IOUtil.getResource(context, next);
- }
- if (nextURL == null) {
- // Try absolute path
- nextURL = IOUtil.getResource(context, includeFile);
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
+ try {
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ lineno++;
+ if(DEBUG_CODE) {
+ System.err.printf("%3d: %s\n", lineno, line);
}
- if (nextURL == null) {
- // Fail
- throw new FileNotFoundException("Can't find include file " + includeFile);
+ if (line.startsWith("#include ")) {
+ String includeFile = line.substring(9).trim();
+ URL nextURL = null;
+
+ // Try relative path first
+ String next = IOUtil.getRelativeOf(url, includeFile);
+ if(null != next) {
+ nextURL = IOUtil.getResource(context, next);
+ }
+ if (nextURL == null) {
+ // Try absolute path
+ nextURL = IOUtil.getResource(context, includeFile);
+ }
+ if (nextURL == null) {
+ // Fail
+ throw new FileNotFoundException("Can't find include file " + includeFile);
+ }
+ lineno = readShaderSource(context, nextURL, result, lineno);
+ } else {
+ result.append(line + "\n");
}
- lineno = readShaderSource(context, nextURL, result, lineno);
- } else {
- result.append(line + "\n");
}
+ } finally {
+ IOUtil.close(reader, false);
}
} catch (IOException e) {
throw new RuntimeException(e);
@@ -358,12 +362,17 @@ public class ShaderCode {
}
public static ByteBuffer readShaderBinary(Class<?> context, String path) {
+ final URL url = IOUtil.getResource(context, path);
+ if (url == null) {
+ return null;
+ }
try {
- URL url = IOUtil.getResource(context, path);
- if (url == null) {
- return null;
+ final BufferedInputStream bis = new BufferedInputStream( url.openStream() );
+ try {
+ return IOUtil.copyStream2ByteBuffer( bis );
+ } finally {
+ IOUtil.close(bis, false);
}
- return IOUtil.copyStream2ByteBuffer( new BufferedInputStream( url.openStream() ) );
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
index 4b680b849..245f5fb06 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
@@ -31,7 +31,6 @@ package com.jogamp.opengl.util.glsl;
import java.security.AccessController;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import javax.media.opengl.GL;
@@ -205,8 +204,6 @@ public class ShaderState {
* @throws GLException if program was not linked and linking fails
*/
public synchronized void attachShaderProgram(GL2ES2 gl, ShaderProgram prog, boolean enable) throws GLException {
- boolean prgInUse = false; // earmarked state
-
if(DEBUG) {
int curId = (null!=shaderProgram)?shaderProgram.id():-1;
int newId = (null!=prog)?prog.id():-1;
@@ -317,7 +314,7 @@ public class ShaderState {
* @see GL2ES2#glGetAttribLocation(int, String)
*/
public int getCachedAttribLocation(String name) {
- Integer idx = (Integer) activeAttribLocationMap.get(name);
+ Integer idx = activeAttribLocationMap.get(name);
return (null!=idx)?idx.intValue():-1;
}
@@ -337,7 +334,7 @@ public class ShaderState {
* @see ShaderProgram#glReplaceShader
*/
public GLArrayData getAttribute(String name) {
- return (GLArrayData) activeAttribDataMap.get(name);
+ return activeAttribDataMap.get(name);
}
/**
@@ -485,7 +482,8 @@ public class ShaderState {
* @return true if the named attribute is enable
*/
public final boolean isVertexAttribArrayEnabled(String name) {
- return enabledAttributes.contains(name);
+ final Boolean v = activedAttribEnabledMap.get(name);
+ return null != v && v.booleanValue();
}
/**
@@ -496,7 +494,7 @@ public class ShaderState {
}
private boolean enableVertexAttribArray(GL2ES2 gl, String name, int location) {
- enabledAttributes.add(name);
+ activedAttribEnabledMap.put(name, Boolean.TRUE);
if(0>location) {
location = getAttribLocation(gl, name);
if(0>location) {
@@ -569,7 +567,7 @@ public class ShaderState {
}
private boolean disableVertexAttribArray(GL2ES2 gl, String name, int location) {
- enabledAttributes.remove(name);
+ activedAttribEnabledMap.put(name, Boolean.FALSE);
if(0>location) {
location = getAttribLocation(gl, name);
if(0>location) {
@@ -691,14 +689,14 @@ public class ShaderState {
throw new GLException("Internal Error: mapped vertex attribute couldn't be disabled");
}
}
- for(Iterator<String> iter = enabledAttributes.iterator(); iter.hasNext(); ) {
+ for(Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) {
if(!disableVertexAttribArray(gl, iter.next())) {
throw new GLException("Internal Error: prev enabled vertex attribute couldn't be disabled");
}
}
}
activeAttribDataMap.clear();
- enabledAttributes.clear();
+ activedAttribEnabledMap.clear();
activeAttribLocationMap.clear();
managedAttributes.clear();
}
@@ -721,10 +719,10 @@ public class ShaderState {
* @see ShaderProgram#glReplaceShader
*/
public void disableAllVertexAttributeArrays(GL2ES2 gl, boolean removeFromState) {
- for(Iterator<String> iter = enabledAttributes.iterator(); iter.hasNext(); ) {
+ for(Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) {
final String name = iter.next();
if(removeFromState) {
- enabledAttributes.remove(name);
+ activedAttribEnabledMap.remove(name);
}
final int index = getAttribLocation(gl, name);
if(0<=index) {
@@ -740,7 +738,7 @@ public class ShaderState {
attribute.setLocation(loc);
if(0<=loc) {
- if(enabledAttributes.contains(name)) {
+ if(isVertexAttribArrayEnabled(name)) {
// enable attrib, VBO and pass location/data
gl.glEnableVertexAttribArray(loc);
}
@@ -787,7 +785,7 @@ public class ShaderState {
if(0<=loc) {
this.bindAttribLocation(gl, loc, name);
- if(enabledAttributes.contains(name)) {
+ if(isVertexAttribArrayEnabled(name)) {
// enable attrib, VBO and pass location/data
gl.glEnableVertexAttribArray(loc);
}
@@ -1006,8 +1004,12 @@ public class ShaderState {
sb.append("ShaderProgram: null");
}
sb.append(Platform.getNewline()).append(" enabledAttributes [");
- for(Iterator<String> iter = enabledAttributes.iterator(); iter.hasNext(); ) {
- sb.append(Platform.getNewline()).append(" ").append(iter.next());
+ {
+ Iterator<String> names = activedAttribEnabledMap.keySet().iterator();
+ Iterator<Boolean> values = activedAttribEnabledMap.values().iterator();
+ while( names.hasNext() ) {
+ sb.append(Platform.getNewline()).append(" ").append(names.next()).append(": ").append(values.next());
+ }
}
sb.append(Platform.getNewline()).append(" ],").append(" activeAttributes [");
for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
@@ -1037,7 +1039,7 @@ public class ShaderState {
private boolean verbose = DEBUG ? true : false;
private ShaderProgram shaderProgram=null;
- private HashSet<String> enabledAttributes = new HashSet<String>();
+ private HashMap<String, Boolean> activedAttribEnabledMap = new HashMap<String, Boolean>();
private HashMap<String, Integer> activeAttribLocationMap = new HashMap<String, Integer>();
private HashMap<String, GLArrayData> activeAttribDataMap = new HashMap<String, GLArrayData>();
private ArrayList<GLArrayData> managedAttributes = new ArrayList<GLArrayData>();
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index 1bb509479..8aa6d5165 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -88,6 +88,21 @@ import javax.media.nativewindow.CapabilitiesImmutable;
public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true, AccessController.getContext());
+ final static int NO_SCORE = -9999999;
+ final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
+ final static int OPAQUE_MISMATCH_PENALTY = 750;
+ final static int STENCIL_MISMATCH_PENALTY = 500;
+ final static int MULTISAMPLE_MISMATCH_PENALTY = 500;
+ final static int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale
+ // Pseudo attempt to keep equal rank penalties scale-equivalent
+ // (e.g., stencil mismatch is 3 * accum because there are 3 accum
+ // components)
+ final static int COLOR_MISMATCH_PENALTY_SCALE = 36;
+ final static int DEPTH_MISMATCH_PENALTY_SCALE = 6;
+ final static int ACCUM_MISMATCH_PENALTY_SCALE = 1;
+ final static int STENCIL_MISMATCH_PENALTY_SCALE = 3;
+ final static int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3;
+
public int chooseCapabilities(final CapabilitiesImmutable desired,
final List /*<CapabilitiesImmutable>*/ available,
final int windowSystemRecommendedChoice) {
@@ -122,20 +137,6 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
// Create score array
int[] scores = new int[availnum];
- final int NO_SCORE = -9999999;
- final int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000;
- final int OPAQUE_MISMATCH_PENALTY = 750;
- final int STENCIL_MISMATCH_PENALTY = 500;
- final int MULTISAMPLE_MISMATCH_PENALTY = 500;
- final int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale
- // Pseudo attempt to keep equal rank penalties scale-equivalent
- // (e.g., stencil mismatch is 3 * accum because there are 3 accum
- // components)
- final int COLOR_MISMATCH_PENALTY_SCALE = 36;
- final int DEPTH_MISMATCH_PENALTY_SCALE = 6;
- final int ACCUM_MISMATCH_PENALTY_SCALE = 1;
- final int STENCIL_MISMATCH_PENALTY_SCALE = 3;
- final int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3;
for (int i = 0; i < scores.length; i++) {
scores[i] = NO_SCORE;
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index c039112c1..cc6b40f54 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -128,6 +128,7 @@ public abstract class GLContext {
protected int ctxMinorVersion;
protected int ctxOptions;
protected String ctxVersionString;
+ private int currentSwapInterval;
protected void resetStates() {
ctxMajorVersion=-1;
@@ -137,6 +138,7 @@ public abstract class GLContext {
attachedObjectsByString.clear();
attachedObjectsByInt.clear();
contextHandle=0;
+ currentSwapInterval = -1;
}
/**
@@ -621,17 +623,54 @@ public abstract class GLContext {
return isGL2GL3() || isGLES2() ;
}
- public final void setSwapInterval(int interval) {
+ /**
+ * Set the swap interval if the current context.
+ * @param interval Should be &ge; 0. 0 Disables the vertical synchronisation,
+ * where &ge; 1 is the number of vertical refreshes before a swap buffer occurs.
+ * A value &lt; 0 is ignored.
+ * @return true if the operation was successful, otherwise false
+ *
+ * @throws GLException if the context is not current.
+ */
+ public final boolean setSwapInterval(int interval) throws GLException {
if (!isCurrent()) {
throw new GLException("This context is not current. Current context: "+getCurrent()+", this context "+this);
}
- setSwapIntervalImpl(interval);
+ if(0<=interval) {
+ if( setSwapIntervalImpl(interval) ) {
+ currentSwapInterval = interval;
+ return true;
+ }
+ }
+ return false;
}
- protected void setSwapIntervalImpl(int interval) { /** nop per default .. **/ }
- protected int currentSwapInterval = -1; // default: not set yet ..
- public int getSwapInterval() {
+ protected boolean setSwapIntervalImpl(int interval) {
+ return false;
+ }
+ /** Return the current swap interval.
+ * <p>
+ * If the context has not been made current at all,
+ * the default value <code>-1</code> is returned.
+ * </p>
+ * <p>
+ * The default value for a valid context is <code>1</code> for
+ * an EGL based profile (ES1 or ES2) and <code>-1</code> (undefined)
+ * for desktop.
+ * </p>
+ */
+ public final int getSwapInterval() {
+ if(-1 == currentSwapInterval && this.isGLES()) {
+ currentSwapInterval = 1;
+ }
return currentSwapInterval;
}
+ protected final void setDefaultSwapInterval() {
+ if(this.isGLES()) {
+ currentSwapInterval = 1;
+ } else {
+ currentSwapInterval = -1;
+ }
+ }
public final boolean queryMaxSwapGroups(int[] maxGroups, int maxGroups_offset,
int[] maxBarriers, int maxBarriers_offset) {
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 8c9ac589a..49b90008b 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -1083,6 +1083,8 @@ public abstract class GLContextImpl extends GLContext {
// Set GL Version (complete w/ version string)
//
setContextVersion(major, minor, ctxProfileBits, true);
+
+ setDefaultSwapInterval();
}
protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index dc47799c1..f5f9f62c4 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -274,18 +274,19 @@ public abstract class EGLContext extends GLContextImpl {
return sb;
}
- protected void setSwapIntervalImpl(int interval) {
+ @Override
+ protected boolean setSwapIntervalImpl(int interval) {
// FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// eglSwapInterval(..) issued:
// Android 4.0.3 / Pandaboard ES / PowerVR SGX 540: crashes
// FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- if( ! ( Platform.OSType.ANDROID == Platform.getOSType() && getGLRendererString(true).contains("powervr") ) ) {
- if (EGL.eglSwapInterval(((EGLDrawable)drawable).getDisplay(), interval)) {
- currentSwapInterval = interval ;
+ if( Platform.OSType.ANDROID == Platform.getOSType() && getGLRendererString(true).contains("powervr") ) {
+ if(DEBUG) {
+ System.err.println("Ignored: eglSwapInterval("+interval+") - cause: OS "+Platform.getOSType() + " / Renderer " + getGLRendererString(false));
}
- } else if(DEBUG) {
- System.err.println("Ignored: eglSwapInterval("+interval+") - cause: OS "+Platform.getOSType() + " / Renderer " + getGLRendererString(false));
+ return false;
}
+ return EGL.eglSwapInterval(((EGLDrawable)drawable).getDisplay(), interval);
}
public abstract void bindPbufferToTexture();
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 4ef49e337..63d58f447 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -279,14 +279,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
}
- protected void setSwapIntervalImpl(int interval) {
- if( ! isCreated() ) {
- throw new GLException("OpenGL context not created");
- }
- if(!impl.setSwapInterval(interval)) {
- throw new GLException("Error set swap-interval: "+this);
- }
- currentSwapInterval = interval ;
+ @Override
+ protected boolean setSwapIntervalImpl(int interval) {
+ return impl.setSwapInterval(interval);
}
public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index 06dc07c1e..a6ef9bd1c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -435,7 +435,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
@Override
- protected void setSwapIntervalImpl(int interval) {
+ protected boolean setSwapIntervalImpl(int interval) {
WGLExt wglExt = getWGLExt();
if(0==hasSwapIntervalSGI) {
try {
@@ -444,11 +444,10 @@ public class WindowsWGLContext extends GLContextImpl {
}
if (hasSwapIntervalSGI>0) {
try {
- if ( wglExt.wglSwapIntervalEXT(interval) ) {
- currentSwapInterval = interval ;
- }
+ return wglExt.wglSwapIntervalEXT(interval);
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
}
+ return false;
}
private final int initSwapGroupImpl(WGLExt wglExt) {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 79361ac0c..1dc1441e1 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -509,10 +509,10 @@ public abstract class X11GLXContext extends GLContextImpl {
}
@Override
- protected void setSwapIntervalImpl(int interval) {
+ protected boolean setSwapIntervalImpl(int interval) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration();
GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
- if(!glCaps.isOnscreen()) return;
+ if(!glCaps.isOnscreen()) { return false; }
GLXExt glXExt = getGLXExt();
if(0==hasSwapIntervalSGI) {
@@ -522,11 +522,10 @@ public abstract class X11GLXContext extends GLContextImpl {
}
if (hasSwapIntervalSGI>0) {
try {
- if( 0 == glXExt.glXSwapIntervalSGI(interval) ) {
- currentSwapInterval = interval;
- }
+ return 0 == glXExt.glXSwapIntervalSGI(interval);
} catch (Throwable t) { hasSwapIntervalSGI=-1; }
}
+ return false;
}
private final int initSwapGroupImpl(GLXExt glXExt) {
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index d7382e0ea..c73f72cfd 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -1702,17 +1702,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private class FullScreenActionImpl implements Runnable {
boolean fullscreen;
- boolean nativeFullscreenChange;
private FullScreenActionImpl() { }
- public void init(boolean fullscreen) {
- this.fullscreen = fullscreen;
- this.nativeFullscreenChange = isNativeValid() && isFullscreen() != fullscreen ;
+ public boolean init(boolean fullscreen) {
+ if(isNativeValid()) {
+ this.fullscreen = fullscreen;
+ return isFullscreen() != fullscreen;
+ } else {
+ WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..)
+ return false;
+ }
}
- public boolean nativeFullscreenChange() { return nativeFullscreenChange; }
- public boolean nativeFullscreenOn() { return nativeFullscreenChange && fullscreen; }
- public boolean nativeFullscreenOff() { return nativeFullscreenChange && !fullscreen; }
+ public boolean fsOn() { return fullscreen; }
public final void run() {
windowLock.lock();
@@ -1801,9 +1803,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
public boolean setFullscreen(boolean fullscreen) {
synchronized(fullScreenAction) {
- fullScreenAction.init(fullscreen);
- if( fullScreenAction.nativeFullscreenChange() ) {
- if(fullScreenAction.nativeFullscreenOn() &&
+ if( fullScreenAction.init(fullscreen) ) {
+ if(fullScreenAction.fsOn() &&
isOffscreenInstance(WindowImpl.this, parentWindow)) {
// enable fullscreen on offscreen instance
if(null != parentWindow) {
@@ -1816,7 +1817,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
runOnEDTIfAvail(true, fullScreenAction);
- if(fullScreenAction.nativeFullscreenOff() && null != nfs_parent) {
+ if(!fullScreenAction.fsOn() && null != nfs_parent) {
// disable fullscreen on offscreen instance
reparentWindow(nfs_parent, true);
nfs_parent = null;
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
index ec687277a..f56e9bb5f 100644
--- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
+++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java
@@ -28,19 +28,17 @@
package jogamp.newt.driver.android;
-import java.nio.IntBuffer;
-
import jogamp.newt.driver.android.event.AndroidNewtEventFactory;
import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.VisualIDHolder;
import javax.media.nativewindow.util.Insets;
import javax.media.nativewindow.util.Point;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
-import com.jogamp.common.nio.Buffers;
import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
import com.jogamp.newt.event.MouseEvent;
@@ -65,16 +63,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
AndroidDisplay.initSingleton();
}
- public static CapabilitiesImmutable fixCapsAlpha(CapabilitiesImmutable rCaps) {
- if(rCaps.getAlphaBits()==0) {
- Capabilities nCaps = (Capabilities) rCaps.cloneMutable();
- nCaps.setAlphaBits(1);
- return nCaps;
- }
- return rCaps;
- }
-
- public static CapabilitiesImmutable fixCaps(int format, CapabilitiesImmutable rCaps) {
+ public static CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) {
PixelFormat pf = new PixelFormat();
PixelFormat.getPixelFormatInfo(format, pf);
final CapabilitiesImmutable res;
@@ -90,18 +79,19 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
case PixelFormat.RGB_332: r=3; g=3; b=2; a=0; break;
default: throw new InternalError("Unhandled pixelformat: "+format);
}
- final boolean fits = rCaps.getRedBits() <= r &&
- rCaps.getGreenBits() <= g &&
- rCaps.getBlueBits() <= b &&
- rCaps.getAlphaBits() <= a ;
+ final boolean change = matchFormatPrecise ||
+ rCaps.getRedBits() > r &&
+ rCaps.getGreenBits() > g &&
+ rCaps.getBlueBits() > b &&
+ rCaps.getAlphaBits() > a ;
- if(!fits) {
+ if(change) {
Capabilities nCaps = (Capabilities) rCaps.cloneMutable();
nCaps.setRedBits(r);
nCaps.setGreenBits(g);
nCaps.setBlueBits(b);
nCaps.setAlphaBits(a);
- res = nCaps;
+ res = nCaps;
} else {
res = rCaps;
}
@@ -138,32 +128,43 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
return fmt;
}
- class AndroidEvents implements /* View.OnKeyListener, */ View.OnTouchListener {
+ class AndroidEvents implements /* View.OnKeyListener, */ View.OnTouchListener, View.OnFocusChangeListener {
public boolean onTouch(View v, MotionEvent event) {
MouseEvent[] newtEvents = AndroidNewtEventFactory.createMouseEvents(AndroidWindow.this, event);
if(null != newtEvents) {
+ focusChanged(false, true);
for(int i=0; i<newtEvents.length; i++) {
AndroidWindow.this.enqueueEvent(false, newtEvents[i]);
}
+ try { Thread.sleep((long) (1000.0F/30.0F)); }
+ catch(InterruptedException e) { }
+ return true; // consumed/handled, further interest in events
}
- return true;
+ return false; // no mapping, no further interest in the event!
}
/** TODO
public boolean onKey(View v, int keyCode, KeyEvent event) {
return false;
} */
+
+ public void onFocusChange(View v, boolean hasFocus) {
+ AndroidWindow.this.focusChanged(false, hasFocus);
+ }
+
}
@Override
protected void instantiationFinished() {
androidView = new MSurfaceView(jogamp.common.os.android.StaticContext.getContext());
- AndroidEvents ae = new AndroidEvents();
+ final AndroidEvents ae = new AndroidEvents();
androidView.setOnTouchListener(ae);
androidView.setClickable(false);
- // nsv.setOnKeyListener(ae);
- SurfaceHolder sh = androidView.getHolder();
+ // androidView.setOnKeyListener(ae);
+ androidView.setOnFocusChangeListener(ae);
+
+ final SurfaceHolder sh = androidView.getHolder();
sh.addCallback(this);
// setFormat is done by SurfaceView in SDK 2.3 and newer. Uncomment
// this statement if back-porting to 2.2 or older:
@@ -186,10 +187,8 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
System.err.println("setandroidWindow: "+window+", "+getWidth()+"x"+getHeight());
androidWindow = window;
androidWindowConfigurationPreCreate();
- if(getWidth()>0 && getHeight()>0 && !isFullscreen()) {
- if(null != androidWindow) {
- androidWindow.setLayout(getWidth(), getHeight());
- }
+ if(null != androidWindow && getWidth()>0 && getHeight()>0 && !isFullscreen()) {
+ androidWindow.setLayout(getWidth(), getHeight());
}
}
public android.view.Window getAndroidWindow() { return androidWindow; }
@@ -220,16 +219,10 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
if (eglConfig == null) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
- // query native VisualID and pass it to Surface
- final long eglConfigHandle = eglConfig.getNativeConfig();
- final IntBuffer nativeVisualID = Buffers.newDirectIntBuffer(1);
- if(!EGL.eglGetConfigAttrib(eglDevice.getHandle(), eglConfigHandle, EGL.EGL_NATIVE_VISUAL_ID, nativeVisualID)) {
- throw new NativeWindowException("eglgetConfigAttrib EGL_NATIVE_VISUAL_ID failed eglDisplay 0x"+Long.toHexString(eglDevice.getHandle())+
- ", error 0x"+Integer.toHexString(EGL.eglGetError()));
- }
- Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID.get(0)));
- if(nativeVisualID.get(0)>0) {
- setSurfaceVisualID0(surfaceHandle, nativeVisualID.get(0));
+ final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE);
+ Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID));
+ if(VisualIDHolder.VID_UNDEFINED != nativeVisualID) {
+ setSurfaceVisualID0(surfaceHandle, nativeVisualID);
}
eglSurface = EGL.eglCreateWindowSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null);
@@ -240,6 +233,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
// propagate data ..
setGraphicsConfiguration(eglConfig);
setWindowHandle(surfaceHandle);
+ focusChanged(false, true);
Log.d(MD.TAG, "createNativeImpl X");
}
@@ -256,33 +250,40 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
return eglSurface;
}
- protected void requestFocusImpl(boolean reparented) { }
+ protected void requestFocusImpl(boolean reparented) {
+ if(null != androidView) {
+ androidView.requestFocus();
+ }
+ }
protected void androidWindowConfigurationPreCreate() {
if( null != androidWindow) {
if( isFullscreen() || isUndecorated() ) {
- androidWindow.requestFeature(Window.FEATURE_NO_TITLE);
+ boolean r = androidWindow.requestFeature(Window.FEATURE_NO_TITLE);
}
if( isFullscreen() ) {
- androidWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ androidWindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ } else {
+ androidWindow.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
}
protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) {
if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) {
- System.err.println("reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a");
+ Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a");
return false;
}
if(width>0 || height>0) {
if(0!=getWindowHandle()) {
- System.err.println("reconfigureWindowImpl.setSize n/a");
+ Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a");
return false;
}
}
if(x>=0 || y>=0) {
- System.err.println("reconfigureWindowImpl.setPos n/a");
+ Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a");
return false;
}
if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) {
@@ -291,29 +292,6 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
return true;
}
- /**
- android.graphics.Canvas cLock = null;
-
- @Override
- protected int lockSurfaceImpl() {
- if (null != cLock) {
- throw new InternalError("surface already locked");
- }
- if (0 != surfaceHandle) {
- cLock = androidView.getHolder().lockCanvas();
- }
- return ( null != cLock ) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY;
- }
-
- @Override
- protected void unlockSurfaceImpl() {
- if (null == cLock) {
- throw new InternalError("surface not locked");
- }
- androidView.getHolder().unlockCanvasAndPost(cLock);
- cLock=null;
- } */
-
protected Point getLocationOnScreenImpl(int x, int y) {
return new Point(x,y);
}
@@ -354,19 +332,21 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 {
surface = aHolder.getSurface();
surfaceHandle = getSurfaceHandle0(surface);
acquire0(surfaceHandle);
- if(PixelFormat.UNKNOWN == aFormat) {
- format = getSurfaceVisualID0(surfaceHandle);
+ final int nFormat = getSurfaceVisualID0(surfaceHandle);
+ if(PixelFormat.UNKNOWN == aFormat || 0 >= aFormat) {
+ format = nFormat;
} else {
format = aFormat;
}
final int nWidth = getWidth0(surfaceHandle);
final int nHeight = getHeight0(surfaceHandle);
- capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities());
+ capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, format, getRequestedCapabilities());
sizeChanged(false, nWidth, nHeight, false);
Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+
- ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+
- ", "+getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible());
+ ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+
+ ", format: "+format+"(a "+aFormat+"/n "+nFormat+"), "+
+ getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible());
if(isVisible()) {
setVisible(true);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
index 74419e564..d1c8f2743 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
@@ -52,10 +52,6 @@ public class NEWTElektronActivity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
- caps.setRedBits(5);
- caps.setGreenBits(6);
- caps.setBlueBits(5);
- caps.setAlphaBits(0);
Log.d(TAG, "req caps: "+caps);
GLWindow glWindow = GLWindow.create(caps);
glWindow.setFullscreen(true);
@@ -70,9 +66,12 @@ public class NEWTElektronActivity extends NewtBaseActivity {
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
setAnimator(animator);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
+
Log.d(TAG, "onCreate - X");
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
index ba861d012..c24c3af28 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
@@ -59,9 +59,10 @@ public class NEWTGearsES1Activity extends NewtBaseActivity {
caps.setAlphaBits(0); */
Log.d(TAG, "req caps: "+caps);
GLWindow glWindow = GLWindow.create(caps);
+ glWindow.setFullscreen(true);
setContentView(getWindow(), glWindow);
- glWindow.addGLEventListener(new GearsES1(1));
+ glWindow.addGLEventListener(new GearsES1(-1));
glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
@@ -70,9 +71,12 @@ public class NEWTGearsES1Activity extends NewtBaseActivity {
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
setAnimator(animator);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
+
Log.d(TAG, "onCreate - X");
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
index 89ecf4cb9..c0eaec842 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
@@ -52,17 +52,12 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
- /*
- caps.setRedBits(5);
- caps.setGreenBits(6);
- caps.setBlueBits(5);
- caps.setAlphaBits(0); */
Log.d(TAG, "req caps: "+caps);
GLWindow glWindow = GLWindow.create(caps);
glWindow.setFullscreen(true);
setContentView(getWindow(), glWindow);
- GearsES2 demo = new GearsES2(0);
+ GearsES2 demo = new GearsES2(-1);
// demo.enableAndroidTrace(true);
glWindow.addGLEventListener(demo);
glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
@@ -72,13 +67,16 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
}
});
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
// animator.setRunAsFastAsPossible(true);
setAnimator(animator);
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
+
Log.d(TAG, "onCreate - X");
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
index d6b7507a3..9e50a1be1 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java
@@ -32,6 +32,8 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.driver.android.NewtBaseActivity;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.Screen;
import com.jogamp.newt.ScreenMode;
import com.jogamp.newt.event.ScreenModeListener;
import com.jogamp.newt.opengl.GLWindow;
@@ -53,14 +55,16 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
caps.setBackgroundOpaque(false);
+
Log.d(TAG, "req caps: "+caps);
- GLWindow glWindow = GLWindow.create(caps);
- glWindow.setSize(300, 300);
- // glWindow.setFullscreen(true);
+ Screen screen = NewtFactory.createScreen(NewtFactory.createDisplay(null), 0);
+ screen.addReference();
+ GLWindow glWindow = GLWindow.create(screen, caps);
+ glWindow.setSize(2*screen.getWidth()/3, 2*screen.getHeight()/3);
glWindow.setUndecorated(true);
setContentView(getWindow(), glWindow);
- glWindow.addGLEventListener(new GearsES2(1));
+ glWindow.addGLEventListener(new GearsES2(-1));
glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
@@ -68,12 +72,16 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity {
}
});
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
setAnimator(animator);
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
+
+ screen.removeReference();
Log.d(TAG, "onCreate - X");
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
index 1efedcd6d..b8bf285c6 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java
@@ -69,9 +69,12 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity {
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
setAnimator(animator);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
+
Log.d(TAG, "onCreate - X");
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
index 39fb5e2cc..103af1aab 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java
@@ -70,9 +70,12 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity {
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
setAnimator(animator);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
+
Log.d(TAG, "onCreate - X");
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
index 99d7fd723..a394482fc 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
@@ -52,15 +52,11 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
- caps.setRedBits(5);
- caps.setGreenBits(6);
- caps.setBlueBits(5);
- caps.setAlphaBits(0);
Log.d(TAG, "req caps: "+caps);
GLWindow glWindow = GLWindow.create(caps);
setContentView(getWindow(), glWindow);
- glWindow.addGLEventListener(new RedSquareES1(1));
+ glWindow.addGLEventListener(new RedSquareES1(-1));
glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
@@ -69,9 +65,12 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity {
});
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
setAnimator(animator);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
+
Log.d(TAG, "onCreate - X");
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
index 804e627a5..889e0944e 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
@@ -52,16 +52,14 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
- caps.setRedBits(5);
- caps.setGreenBits(6);
- caps.setBlueBits(5);
- caps.setAlphaBits(0);
Log.d(TAG, "req caps: "+caps);
GLWindow glWindow = GLWindow.create(caps);
- glWindow.setFullscreen(true);
+ // glWindow.setSize(200, 200);
+ // glWindow.setUndecorated(true);
+ glWindow.setFullscreen(true);
setContentView(getWindow(), glWindow);
- final RedSquareES2 demo = new RedSquareES2(0);
+ final RedSquareES2 demo = new RedSquareES2(-1);
// demo.enableAndroidTrace(true);
glWindow.addGLEventListener(demo);
glWindow.getScreen().addScreenModeListener(new ScreenModeListener() {
@@ -71,12 +69,14 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity {
}
});
Animator animator = new Animator(glWindow);
- animator.setUpdateFPSFrames(60, System.err);
// animator.setRunAsFastAsPossible(true);
setAnimator(animator);
// glWindow.setSkipContextReleaseThread(animator.getThread());
glWindow.setVisible(true);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ glWindow.resetFPSCounter();
Log.d(TAG, "onCreate - X");
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
index b5a729e02..fb2c9c7ea 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java
@@ -48,7 +48,6 @@ public class GearsES1 implements GLEventListener {
private GearsObject gear1=null, gear2=null, gear3=null;
private float angle = 0.0f;
private int swapInterval;
- private boolean initialized = false;
private int prevMouseX, prevMouseY;
@@ -83,7 +82,6 @@ public class GearsES1 implements GLEventListener {
public void init(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" GearsES1.init ...");
- initialized = true;
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
@@ -150,12 +148,16 @@ public class GearsES1 implements GLEventListener {
gl.setSwapInterval(swapInterval);
- float h = (float)height / (float)width;
-
gl.glMatrixMode(GL2ES1.GL_PROJECTION);
gl.glLoadIdentity();
- gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ if(height>width) {
+ float h = (float)height / (float)width;
+ gl.glFrustumf(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ } else {
+ float h = (float)width / (float)height;
+ gl.glFrustumf(-h, h, -1.0f, 1.0f, 5.0f, 60.0f);
+ }
gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -40.0f);
@@ -164,7 +166,6 @@ public class GearsES1 implements GLEventListener {
public void dispose(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" GearsES1.dispose ... ");
- initialized = false;
GL gl = drawable.getGL();
gear1.destroy(gl);
gear1 = null;
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 5a106901d..81e3a5c80 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java
@@ -174,9 +174,7 @@ public class GearsES2 implements GLEventListener {
}
st.useProgram(gl, false);
- if(0<=swapInterval) {
- gl.setSwapInterval(swapInterval);
- }
+ gl.setSwapInterval(swapInterval);
System.err.println(Thread.currentThread()+" GearsES2.init FIN");
}
@@ -189,12 +187,18 @@ public class GearsES2 implements GLEventListener {
System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
GL2ES2 gl = drawable.getGL().getGL2ES2();
- float h = (float)height / (float)width;
-
st.useProgram(gl, true);
pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
pmvMatrix.glLoadIdentity();
- pmvMatrix.glFrustumf(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+
+ if(height>width) {
+ float h = (float)height / (float)width;
+ pmvMatrix.glFrustumf(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
+ } else {
+ float h = (float)width / (float)height;
+ pmvMatrix.glFrustumf(-h, h, -1.0f, 1.0f, 5.0f, 60.0f);
+ }
+
pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f);
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 6f3438ec8..dcda10426 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java
@@ -122,9 +122,7 @@ public class RedSquareES2 implements GLEventListener {
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
st.useProgram(gl, false);
- if(0<=swapInterval) {
- gl.setSwapInterval(swapInterval);
- }
+ gl.setSwapInterval(swapInterval);
if (glad instanceof GLWindow) {
glWindow = (GLWindow) glad;