summaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-30 17:07:33 +0200
committerSven Gothel <[email protected]>2011-09-30 17:07:33 +0200
commit71fb7c1271cc1dbbcacdaf6da093055ec61835d3 (patch)
tree8652e5eb706c0b287b6f073fbda46c7517400204 /src/test/com
parentfeac236a9ec62a5a51053e06ad08ba9847c1b540 (diff)
Android: Use standard launch mode; Add default actions to NewtBaseActivity; Add RedSquare ES1 + ES2
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java36
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java36
-rw-r--r--src/test/com/jogamp/opengl/test/android/NEWTGraphUIActivity.java36
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java6
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java20
5 files changed, 9 insertions, 125 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
index c0b358d07..897df89cd 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java
@@ -41,12 +41,8 @@ import com.jogamp.opengl.util.Animator;
import android.os.Bundle;
import android.util.Log;
-import android.widget.TextView;
public class NEWTGearsES1Activity extends NewtBaseActivity {
- GLWindow glWindow = null;
- Animator animator = null;
- TextView tv = null;
static String TAG = "NEWTGearsES1Activity";
@Override
@@ -57,7 +53,7 @@ public class NEWTGearsES1Activity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1));
Log.d(TAG, "req caps: "+caps);
- glWindow = GLWindow.create(caps);
+ GLWindow glWindow = GLWindow.create(caps);
setContentView(glWindow);
glWindow.addGLEventListener(new GearsES1(1));
@@ -68,36 +64,10 @@ public class NEWTGearsES1Activity extends NewtBaseActivity {
}
});
glWindow.setVisible(true);
- animator = new Animator(glWindow);
+ Animator animator = new Animator(glWindow);
animator.setUpdateFPSFrames(60, System.err);
+ setAnimator(animator);
Log.d(TAG, "onCreate - X");
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if(null != animator) {
- animator.start();
- }
- }
-
- @Override
- public void onPause() {
- if(null != animator) {
- animator.pause();
- }
- super.onPause();
- }
-
- @Override
- public void onDestroy() {
- if(null != animator) {
- animator.stop();
- }
- if(null != glWindow) {
- glWindow.destroy();
- }
- super.onDestroy();
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
index 12ef40280..b19c12d4a 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java
@@ -41,12 +41,8 @@ import com.jogamp.opengl.util.Animator;
import android.os.Bundle;
import android.util.Log;
-import android.widget.TextView;
public class NEWTGearsES2Activity extends NewtBaseActivity {
- GLWindow glWindow = null;
- Animator animator = null;
- TextView tv = null;
static String TAG = "NEWTGearsES2Activity";
@Override
@@ -57,7 +53,7 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
// create GLWindow (-> incl. underlying NEWT Display, Screen & Window)
GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2));
Log.d(TAG, "req caps: "+caps);
- glWindow = GLWindow.create(caps);
+ GLWindow glWindow = GLWindow.create(caps);
setContentView(glWindow);
glWindow.addGLEventListener(new GearsES2(1));
@@ -68,36 +64,10 @@ public class NEWTGearsES2Activity extends NewtBaseActivity {
}
});
glWindow.setVisible(true);
- animator = new Animator(glWindow);
+ Animator animator = new Animator(glWindow);
animator.setUpdateFPSFrames(60, System.err);
+ setAnimator(animator);
Log.d(TAG, "onCreate - X");
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if(null != animator) {
- animator.start();
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- if(null != animator) {
- animator.pause();
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if(null != animator) {
- animator.stop();
- }
- if(null != glWindow) {
- glWindow.destroy();
- }
}
}
diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUIActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUIActivity.java
index d6ab28f13..3fcc82689 100644
--- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUIActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUIActivity.java
@@ -41,12 +41,8 @@ import com.jogamp.opengl.util.Animator;
import android.os.Bundle;
import android.util.Log;
-import android.widget.TextView;
public class NEWTGraphUIActivity extends NewtBaseActivity {
- GLWindow glWindow = null;
- Animator animator = null;
- TextView tv = null;
static String TAG = "NEWTGraphUIActivity";
@Override
@@ -60,7 +56,7 @@ public class NEWTGraphUIActivity extends NewtBaseActivity {
caps.setNumSamples(4);
caps.setSampleBuffers(true);
Log.d(TAG, "req caps: "+caps);
- glWindow = GLWindow.create(caps);
+ GLWindow glWindow = GLWindow.create(caps);
setContentView(glWindow);
glWindow.addGLEventListener(new GPUUISceneGLListener0A());
@@ -71,36 +67,10 @@ public class NEWTGraphUIActivity extends NewtBaseActivity {
}
});
glWindow.setVisible(true);
- animator = new Animator(glWindow);
+ Animator animator = new Animator(glWindow);
animator.setUpdateFPSFrames(60, System.err);
+ setAnimator(animator);
Log.d(TAG, "onCreate - X");
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if(null != animator) {
- animator.start();
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- if(null != animator) {
- animator.pause();
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if(null != animator) {
- animator.stop();
- }
- if(null != glWindow) {
- glWindow.destroy();
- }
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
index cc2578e9d..38afec7f1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java
@@ -7,8 +7,6 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.media.opengl.fixedfunc.GLPointerFunc;
import javax.media.opengl.glu.*;
-import org.junit.Assert;
-
import com.jogamp.opengl.util.glsl.fixedfunc.*;
public class RedSquareES1 implements GLEventListener {
@@ -45,7 +43,6 @@ public class RedSquareES1 implements GLEventListener {
public void init(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" RedSquareES1.init ...");
- Assert.assertNull("GLU object is not null -> already init", glu);
GL _gl = drawable.getGL();
if(glDebugEmu) {
@@ -111,7 +108,6 @@ public class RedSquareES1 implements GLEventListener {
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
System.err.println(Thread.currentThread()+" RedSquareES1.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval);
- Assert.assertNotNull("GLU object is null -> not init or already disposed", glu);
GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.setSwapInterval(swapInterval);
@@ -125,7 +121,6 @@ public class RedSquareES1 implements GLEventListener {
}
public void display(GLAutoDrawable drawable) {
- Assert.assertNotNull("GLU object is null -> not init or already disposed", glu);
curTime = System.currentTimeMillis();
GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
@@ -148,7 +143,6 @@ public class RedSquareES1 implements GLEventListener {
public void dispose(GLAutoDrawable drawable) {
System.err.println(Thread.currentThread()+" RedSquareES1.dispose ... ");
- Assert.assertNotNull("GLU object is null -> not init or already disposed", glu);
GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
gl.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
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 c3dfb8897..b750e8eb1 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
@@ -36,9 +36,7 @@ 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 org.junit.Assert;
public class RedSquareES2 implements GLEventListener {
ShaderState st;
@@ -59,7 +57,6 @@ public class RedSquareES2 implements GLEventListener {
public void init(GLAutoDrawable glad) {
System.err.println(Thread.currentThread()+" RedSquareES2.init ...");
- Assert.assertNull("ShaderState object is not null -> already init", st);
GL2ES2 gl = glad.getGL().getGL2ES2();
System.err.println(Thread.currentThread()+" GL Profile: "+gl.getGLProfile());
@@ -77,7 +74,6 @@ public class RedSquareES2 implements GLEventListener {
sp0.add(gl, fp0, System.err);
st.attachShaderProgram(gl, sp0);
st.useProgram(gl, true);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// setup mgl_PMVMatrix
pmvMatrix = new PMVMatrix();
@@ -88,7 +84,6 @@ public class RedSquareES2 implements GLEventListener {
pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv
st.ownUniform(pmvMatrixUniform);
st.uniform(gl, pmvMatrixUniform);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// Allocate Vertex Array
vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
@@ -99,7 +94,6 @@ public class RedSquareES2 implements GLEventListener {
vertices.seal(gl, true);
st.ownAttribute(vertices, true);
vertices.enableBuffer(gl, false);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// Allocate Color Array
colors= GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
@@ -110,13 +104,11 @@ public class RedSquareES2 implements GLEventListener {
colors.seal(gl, true);
st.ownAttribute(colors, true);
colors.enableBuffer(gl, false);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// OpenGL Render Settings
gl.glClearColor(0, 0, 0, 1);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
st.useProgram(gl, false);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
t0 = System.currentTimeMillis();
System.err.println(Thread.currentThread()+" RedSquareES2.init FIN");
@@ -124,33 +116,26 @@ public class RedSquareES2 implements GLEventListener {
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);
- Assert.assertNotNull("ShaderState object is null -> not init or already disposed", st);
GL2ES2 gl = glad.getGL().getGL2ES2();
gl.setSwapInterval(swapInterval);
st.useProgram(gl, true);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// 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);
gl.glUniform(pmvMatrixUniform);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
st.useProgram(gl, false);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN");
}
public void display(GLAutoDrawable glad) {
- Assert.assertNotNull("ShaderState object is null -> not init or already disposed", st);
long t1 = System.currentTimeMillis();
GL2ES2 gl = glad.getGL().getGL2ES2();
st.useProgram(gl, true);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// One rotation every four seconds
pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
@@ -159,24 +144,19 @@ public class RedSquareES2 implements GLEventListener {
pmvMatrix.glRotatef(ang, 0, 0, 1);
pmvMatrix.glRotatef(ang, 0, 1, 0);
gl.glUniform(pmvMatrixUniform);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
// Draw a square
vertices.enableBuffer(gl, true);
colors.enableBuffer(gl, true);
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
vertices.enableBuffer(gl, false);
colors.enableBuffer(gl, false);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
st.useProgram(gl, false);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
}
public void dispose(GLAutoDrawable glad) {
System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... ");
- Assert.assertNotNull("ShaderState object is null -> not init or already disposed", st);
GL2ES2 gl = glad.getGL().getGL2ES2();
st.destroy(gl);
- Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
st = null;
pmvMatrix.destroy();
pmvMatrix = null;