aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java7
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java5
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java10
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java4
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java9
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java27
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java48
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java59
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp8
9 files changed, 148 insertions, 29 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
index 442400868..21eb8af2d 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java
@@ -52,9 +52,10 @@ public class NEWTElektronActivity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
- // caps.setAlphaBits(4);
- // caps.setNumSamples(4);
- // caps.setSampleBuffers(true);
+ 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);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
index bc4e7d394..337dafc71 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
@@ -52,6 +52,11 @@ public class NEWTGearsES1Activity 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);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
index 939bfa210..3e9869c95 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
@@ -52,12 +52,19 @@ 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);
- glWindow.addGLEventListener(new GearsES2(1));
+ GearsES2 demo = new GearsES2(0);
+ // demo.enableAndroidTrace(true);
+ glWindow.addGLEventListener(demo);
glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
@@ -67,6 +74,7 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
animator.setUpdateFPSFrames(60, System.err);
+ // animator.setRunAsFastAsPossible(true);
setAnimator(animator);
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 6fc3a46d6..24b4eaf0c 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java
@@ -52,6 +52,10 @@ 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);
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
index e9ef981b8..70d1c382d 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java
@@ -52,12 +52,18 @@ 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);
setContentView(getWindow(), glWindow);
- glWindow.addGLEventListener(new RedSquareES2(1));
+ final RedSquareES2 demo = new RedSquareES2(0);
+ // demo.enableAndroidTrace(true);
+ glWindow.addGLEventListener(demo);
glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() {
public void screenModeChangeNotify(ScreenMode sm) { }
public void screenModeChanged(ScreenMode sm, boolean success) {
@@ -67,6 +73,7 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity {
glWindow.setVisible(true);
Animator animator = new Animator(glWindow);
animator.setUpdateFPSFrames(60, System.err);
+ // animator.setRunAsFastAsPossible(true);
setAnimator(animator);
Log.d(TAG, "onCreate - X");
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 9bff38fce..573d92ad9 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
@@ -56,6 +56,7 @@ public class GearsES2 implements GLEventListener {
private GearsObjectES2 gear1=null, gear2=null, gear3=null;
private float angle = 0.0f;
private int swapInterval = 0;
+ private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster
// private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
private MouseListener gearsMouse = new GearsMouseAdapter();
private KeyListener gearsKeys = new GearsKeyAdapter();
@@ -70,6 +71,10 @@ public class GearsES2 implements GLEventListener {
this.swapInterval = 1;
}
+ public void setPMVUseBackingArray(boolean pmvUseBackingArray) {
+ this.pmvUseBackingArray = pmvUseBackingArray;
+ }
+
public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) {
gear1 = g1;
gear2 = g2;
@@ -119,7 +124,7 @@ public class GearsES2 implements GLEventListener {
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
- pmvMatrix = new PMVMatrix();
+ pmvMatrix = new PMVMatrix(pmvUseBackingArray);
st.attachObject("pmvMatrix", pmvMatrix);
pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit
st.ownUniform(pmvMatrixUniform);
@@ -173,6 +178,10 @@ 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);
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -189,10 +198,24 @@ 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");
}
+ 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;
@@ -244,7 +267,7 @@ public class GearsES2 implements GLEventListener {
gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f, GearsObject.green);
gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f, GearsObject.blue);
pmvMatrix.glPopMatrix();
- st.useProgram(gl, false);
+ st.useProgram(gl, false);
}
class GearsKeyAdapter extends KeyAdapter {
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 d06c6da97..01790de10 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
@@ -131,21 +131,6 @@ public class RedSquareES2 implements GLEventListener {
System.err.println(Thread.currentThread()+" RedSquareES2.init FIN");
}
- 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();
-
- st.useProgram(gl, true);
- // Set location in front of camera
- pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- pmvMatrix.gluPerspective(45.0F, (float) width / (float) height, 1.0F, 100.0F);
- //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
- st.uniform(gl, pmvMatrixUniform);
- st.useProgram(gl, false);
- System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN");
- }
-
public void display(GLAutoDrawable glad) {
long t1 = System.currentTimeMillis();
@@ -170,7 +155,40 @@ 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();
+
+ st.useProgram(gl, true);
+ // Set location in front of camera
+ pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.gluPerspective(45.0F, (float) width / (float) height, 1.0F, 100.0F);
+ //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
+ 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/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index df86b83d2..64eb518fb 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -28,6 +28,10 @@
package com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.opengl.GLWindow;
@@ -38,7 +42,10 @@ import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2;
+import javax.media.opengl.GLAnimatorControl;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import org.junit.Assert;
@@ -78,7 +85,29 @@ public class TestGearsES2NEWT extends UITestCase {
glWindow.setUndecorated(undecorated);
glWindow.setAlwaysOnTop(alwaysOnTop);
glWindow.setFullscreen(fullscreen);
- glWindow.addGLEventListener(new GearsES2());
+ GearsES2 demo = new GearsES2(vsync ? 1 : 0);
+ demo.setPMVUseBackingArray(pmvUseBackingArray);
+ glWindow.addGLEventListener(demo);
+ if(waitForKey) {
+ glWindow.addGLEventListener(new GLEventListener() {
+ public void init(GLAutoDrawable drawable) { }
+ public void dispose(GLAutoDrawable drawable) { }
+ public void display(GLAutoDrawable drawable) {
+ GLAnimatorControl actrl = drawable.getAnimator();
+ if(waitForKey && actrl.getTotalFPSFrames() == 60*3) {
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ try {
+ System.err.println(stdin.readLine());
+ } catch (IOException e) { }
+ actrl.resetFPSCounter();
+ waitForKey = false;
+ }
+ }
+ public void reshape(GLAutoDrawable drawable, int x, int y,
+ int width, int height) { }
+ });
+ }
Animator animator = new Animator(glWindow);
QuitAdapter quitAdapter = new QuitAdapter();
@@ -128,7 +157,7 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("size/pos: "+f_glWindow.getX()+"/"+f_glWindow.getY()+" "+f_glWindow.getWidth()+"x"+f_glWindow.getHeight()+", "+f_glWindow.getInsets());
System.err.println("chosen: "+glWindow.getChosenCapabilities());
- animator.setUpdateFPSFrames(1, null);
+ animator.setUpdateFPSFrames(60, System.err);
animator.start();
while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()<duration) {
@@ -151,8 +180,12 @@ public class TestGearsES2NEWT extends UITestCase {
static boolean undecorated = false;
static boolean alwaysOnTop = false;
static boolean fullscreen = false;
+ static boolean pmvUseBackingArray = true;
+ static boolean vsync = false;
+ static boolean waitForKey = false;
- public static void main(String args[]) {
+ public static void main(String args[]) throws IOException {
+
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
@@ -167,8 +200,28 @@ public class TestGearsES2NEWT extends UITestCase {
alwaysOnTop = true;
} else if(args[i].equals("-fullscreen")) {
fullscreen = true;
+ } else if(args[i].equals("-pmvDirect")) {
+ pmvUseBackingArray = false;
+ } else if(args[i].equals("-vsync")) {
+ vsync = true;
+ } else if(args[i].equals("-wait")) {
+ waitForKey = true;
}
}
+ System.err.println("translucent "+(!opaque));
+ System.err.println("undecorated "+undecorated);
+ System.err.println("atop "+alwaysOnTop);
+ System.err.println("fullscreen "+fullscreen);
+ System.err.println("pmvDirect "+(!pmvUseBackingArray));
+ System.err.println("vsync "+vsync);
+
+ if(waitForKey) {
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ System.err.println("Press enter to continue");
+ try {
+ System.err.println(stdin.readLine());
+ } catch (IOException e) { }
+ }
org.junit.runner.JUnitCore.main(TestGearsES2NEWT.class.getName());
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
index e8feef2fa..768e23b36 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/gears.fp
@@ -23,12 +23,12 @@ const vec4 matSpecular = vec4(0.8, 0.8, 0.8, 1.0);
const float matShininess = 0.5;
void main()
-{
- float lambertTerm = dot(normal, lightDir);
-
+{
vec4 ambient = color * matAmbient;
- vec4 diffuse = color * lambertTerm * attenuation * matDiffuse;
vec4 specular = vec4(0.0);
+
+ float lambertTerm = dot(normal, lightDir);
+ vec4 diffuse = color * lambertTerm * attenuation * matDiffuse;
if (lambertTerm > 0.0) {
float NdotHV;
/*