From 2958508131e5f0b3336f07c6f1c2865eb954921b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 12 Oct 2012 15:12:39 +0200 Subject: Adding unit tests for ImmModeSink and FixedFunctionPipeline (single & combinations, plus texture usage) --- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 44 +++- .../test/junit/jogl/demos/es1/RedSquareES1.java | 46 +++-- .../jogl/demos/es1/newt/TestGearsES1NEWT.java | 27 ++- .../jogl/demos/es1/newt/TestRedSquareES1NEWT.java | 27 ++- .../junit/jogl/util/DemoGL2ES1ImmModeSink.java | 97 +++++++++ .../test/junit/jogl/util/DemoGL2ES1Plain.java | 161 +++++++++++++++ .../jogl/util/DemoGL2ES1TextureImmModeSink.java | 142 +++++++++++++ .../util/TestES1FixedFunctionPipelineNEWT.java | 151 ++++++++++++++ .../junit/jogl/util/TestImmModeSinkES1NEWT.java | 226 +-------------------- .../jogamp/opengl/test/junit/util/UITestCase.java | 6 +- 10 files changed, 669 insertions(+), 258 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/TestES1FixedFunctionPipelineNEWT.java (limited to 'src/test/com/jogamp') 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 40b351a75..5186fd7fd 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 @@ -27,6 +27,7 @@ import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLPipelineFactory; import javax.media.opengl.GLProfile; import com.jogamp.newt.Window; @@ -37,12 +38,21 @@ import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; +import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil; +import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode; /** * GearsES1.java
* @author Brian Paul (converted to Java by Ron Cemer and Sven Gothel)

*/ public class GearsES1 implements GLEventListener { + private boolean debugFFPEmu = false; + private boolean verboseFFPEmu = false; + private boolean traceFFPEmu = false; + private boolean forceFFPEmu = false; + private boolean debug = false ; + private boolean trace = false ; + private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; @@ -63,6 +73,13 @@ public class GearsES1 implements GLEventListener { this.swapInterval = 1; } + public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { + this.forceFFPEmu = forceFFPEmu; + this.verboseFFPEmu = verboseFFPEmu; + this.debugFFPEmu = debugFFPEmu; + this.traceFFPEmu = traceFFPEmu; + } + public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) { gear1 = g1; gear2 = g2; @@ -91,8 +108,31 @@ public class GearsES1 implements GLEventListener { // drawable.setGL(new DebugGL(drawable.getGL())); GL _gl = drawable.getGL(); - // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/); - GL2ES1 gl = _gl.getGL2ES1(); + + if(debugFFPEmu) { + // Debug .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); + debug = false; + } + if(traceFFPEmu) { + // Trace .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); + trace = false; + } + GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu); + + if(debug) { + try { + // Debug .. + gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); + } catch (Exception e) {e.printStackTrace();} + } + if(trace) { + try { + // Trace .. + gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); + } catch (Exception e) {e.printStackTrace();} + } System.err.println("GearsES1 init on "+Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); 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 84234d464..37ed83eb6 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 @@ -10,11 +10,14 @@ import com.jogamp.opengl.util.glsl.fixedfunc.*; public class RedSquareES1 implements GLEventListener { - public static boolean glDebugEmu = false; - public static boolean glDebug = false ; - public static boolean glTrace = false ; public static boolean oneThread = false; public static boolean useAnimator = false; + private boolean debugFFPEmu = false; + private boolean verboseFFPEmu = false; + private boolean traceFFPEmu = false; + private boolean forceFFPEmu = false; + private boolean debug = false ; + private boolean trace = false ; private int swapInterval = 0; long startTime = 0; @@ -28,6 +31,13 @@ public class RedSquareES1 implements GLEventListener { this.swapInterval = 1; } + public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { + this.forceFFPEmu = forceFFPEmu; + this.verboseFFPEmu = verboseFFPEmu; + this.debugFFPEmu = debugFFPEmu; + this.traceFFPEmu = traceFFPEmu; + } + // FIXME: we must add storage of the pointers in the GL state to // the GLImpl classes. The need for this can be seen by making // these variables method local instead of instance members. The @@ -42,29 +52,25 @@ public class RedSquareES1 implements GLEventListener { System.err.println(Thread.currentThread()+" RedSquareES1.init ..."); GL _gl = drawable.getGL(); - if(glDebugEmu) { - try { - // Debug .. - _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); - - if(glTrace) { - // Trace .. - _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); - } - } catch (Exception e) {e.printStackTrace();} - glDebug = false; - glTrace = false; + if(debugFFPEmu) { + // Debug .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); + debug = false; } - - GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl); - if(glDebug) { + if(traceFFPEmu) { + // Trace .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); + trace = false; + } + GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu); + + if(debug) { try { // Debug .. gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); } catch (Exception e) {e.printStackTrace();} } - - if(glTrace) { + if(trace) { try { // Trace .. gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java index ff168d9e9..9e0bbae71 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java @@ -48,6 +48,8 @@ import org.junit.Test; public class TestGearsES1NEWT extends UITestCase { static int width, height; + static boolean forceES2 = false; + static boolean forceFFPEmu = false; @BeforeClass public static void initClass() { @@ -59,12 +61,16 @@ public class TestGearsES1NEWT extends UITestCase { public static void releaseClass() { } - protected void runTestGL(GLCapabilities caps) throws InterruptedException { + protected void runTestGL(GLCapabilities caps, boolean forceFFPEmu) throws InterruptedException { GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test"); - glWindow.addGLEventListener(new GearsES1()); + final GearsES1 demo = new GearsES1(); + demo.setForceFFPEmu(forceFFPEmu, forceFFPEmu, false, false); + glWindow.addGLEventListener(demo); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); + glWindow.addGLEventListener(snap); Animator animator = new Animator(glWindow); QuitAdapter quitAdapter = new QuitAdapter(); @@ -95,6 +101,7 @@ public class TestGearsES1NEWT extends UITestCase { glWindow.setVisible(true); animator.setUpdateFPSFrames(1, null); animator.start(); + snap.setMakeSnapshot(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()