From 90e9104f0acd9eb014f3361139119c3f53b955a3 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Mon, 12 Oct 2015 08:25:22 +0200
Subject: TestGearsES2NEWT: Adding programmatic Debug|Trace pipeline

---
 make/scripts/tests.sh                              |  8 ++---
 .../jogl/demos/es2/newt/TestGearsES2NEWT.java      | 37 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 62f7dc5da..d721def3f 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -252,7 +252,7 @@ function jrun() {
     #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable"
     #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent"
     #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent"
-    D_ARGS="-Dnewt.debug.Window"
+    #D_ARGS="-Dnewt.debug.Window"
     #D_ARGS="-Dnewt.debug.Window.visibility.failure.freeze"
     #D_ARGS="-Xprof"
     #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
@@ -429,6 +429,7 @@ function testawtswt() {
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile03NEWTOffscreen $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile04NEWTOffscreenNoARBCtx $*
 #testawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $*
+#
 
 #
 # Stereo
@@ -438,7 +439,7 @@ function testawtswt() {
 #
 # HiDPI
 #
-#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.es2.newt.TestGearsES2SimpleNEWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
@@ -809,8 +810,7 @@ function testawtswt() {
 # Bug 1249 - NEWT X11: 
 #   - setVisible(false) IconicState not listening to _NET_WM_STATE_HIDDEN; 
 #   - setVisible(true) not restoring from _NET_WM_STATE_HIDDEN
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
-testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows00NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows00NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT
 #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT
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 cbc26066c..55b318d23 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
@@ -58,11 +58,13 @@ import com.jogamp.nativewindow.util.Dimension;
 import com.jogamp.nativewindow.util.Point;
 import com.jogamp.nativewindow.util.PointImmutable;
 import com.jogamp.nativewindow.util.DimensionImmutable;
+import com.jogamp.opengl.GL;
 import com.jogamp.opengl.GLAnimatorControl;
 import com.jogamp.opengl.GLAutoDrawable;
 import com.jogamp.opengl.GLCapabilities;
 import com.jogamp.opengl.GLCapabilitiesImmutable;
 import com.jogamp.opengl.GLEventListener;
+import com.jogamp.opengl.GLPipelineFactory;
 import com.jogamp.opengl.GLProfile;
 
 import jogamp.newt.DefaultEDTUtil;
@@ -104,6 +106,8 @@ public class TestGearsES2NEWT extends UITestCase {
     static boolean forceES3 = false;
     static boolean forceGL3 = false;
     static boolean forceGL2 = false;
+    static boolean forceDebug = false;
+    static boolean forceTrace = false;
     static int demoType = 1;
     static boolean traceMouse = false;
     static boolean manualTest = false;
@@ -160,6 +164,33 @@ public class TestGearsES2NEWT extends UITestCase {
         } else {
             demo = null;
         }
+        if( forceDebug || forceTrace ) {
+            glWindow.addGLEventListener(new GLEventListener() {
+                @Override
+                public void init(final GLAutoDrawable drawable) {
+                    GL _gl = drawable.getGL();
+                    if(forceDebug) {
+                        try {
+                            _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, _gl, null) );
+                        } catch (final Exception e) {e.printStackTrace();}
+                    }
+
+                    if(forceTrace) {
+                        try {
+                            // Trace ..
+                            _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, _gl, new Object[] { System.err } ) );
+                        } catch (final Exception e) {e.printStackTrace();}
+                    }
+                }
+                @Override
+                public void dispose(final GLAutoDrawable drawable) {}
+                @Override
+                public void display(final GLAutoDrawable drawable) {}
+                @Override
+                public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {}
+            });
+        }
+
         if( null != demo ) {
             glWindow.addGLEventListener(demo);
         }
@@ -468,6 +499,10 @@ public class TestGearsES2NEWT extends UITestCase {
                 forceGL3 = true;
             } else if(args[i].equals("-gl2")) {
                 forceGL2 = true;
+            } else if(args[i].equals("-debug")) {
+                forceDebug = true;
+            } else if(args[i].equals("-trace")) {
+                forceTrace = true;
             } else if(args[i].equals("-mappedBuffers")) {
                 useMappedBuffers = true;
             } else if(args[i].equals("-wait")) {
@@ -556,6 +591,8 @@ public class TestGearsES2NEWT extends UITestCase {
         System.err.println("forceES3 "+forceES3);
         System.err.println("forceGL3 "+forceGL3);
         System.err.println("forceGL2 "+forceGL2);
+        System.err.println("forceDebug "+forceDebug);
+        System.err.println("forceTrace "+forceTrace);
         System.err.println("swapInterval "+swapInterval);
         System.err.println("exclusiveContext "+exclusiveContext);
         System.err.println("useAnimator "+useAnimator);
-- 
cgit v1.2.3