aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-10 04:48:39 +0100
committerSven Gothel <[email protected]>2012-03-10 04:48:39 +0100
commit42a08f9c8a6b86a104d9feba6e29397933b020c5 (patch)
treec167312095de5c0fe14c2da17273ad853dd6ba3d /src
parent3424091ecaa0d885ce7fd7c3a2279930cfd56040 (diff)
Minor changes: DefaultGLCapabilitiesChooser + GearsES1/2 and Android demos
DefaultGLCapabilitiesChooser: Move 'static' values to final static. GearsES1/2: Handle width>=height case -> flip frustum. Android: Enable fps trace dump after visibility, use default RGBA_8888, Explicitly don't use swapInterval (-1). NEWTGearsES2TransActivity: Gather Screen size and set demo view 2/3 of it.
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java29
-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
12 files changed, 81 insertions, 63 deletions
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/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;