diff options
author | Sven Gothel <[email protected]> | 2011-10-07 20:01:37 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-07 20:01:37 +0200 |
commit | e3441bccf296927549d41e6472cca8c03259f8f3 (patch) | |
tree | ee31049734752d98b5c6512e109187ec695fac77 /src/test | |
parent | 5a8d002b3d955f7ad7d0854d4cb416388340d9fc (diff) |
Android Demos GearsES2 + RedSquareES2: Add tracing .. and no vsync (doesn't work)
Diffstat (limited to 'src/test')
5 files changed, 66 insertions, 27 deletions
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/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 050d9eb6e..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 @@ -178,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(); @@ -194,11 +198,13 @@ public class GearsES2 implements GLEventListener { st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); - try { - android.os.Debug.startMethodTracing("GearsES2.trace"); - android.os.Debug.startAllocCounting(); - useAndroidDebug = true; - } catch (NoClassDefFoundError e) {} + 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"); } @@ -206,7 +212,7 @@ public class GearsES2 implements GLEventListener { public void dispose(GLAutoDrawable drawable) { if(useAndroidDebug) { - android.os.Debug.stopAllocCounting(); + // android.os.Debug.stopAllocCounting(); android.os.Debug.stopMethodTracing(); } 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/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; /* |