From 2365d7278bc5a64b4ff7856fd01d75214ea0f555 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Wed, 27 Jun 2012 20:35:44 +0000 Subject: Added trivial test --- maven/trivial-test/README.txt | 31 ++++++ maven/trivial-test/pom.xml | 50 ++++++++++ .../com/io7m/example/jogl_mvn_test_2/TestJOGL.java | 107 +++++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 maven/trivial-test/README.txt create mode 100644 maven/trivial-test/pom.xml create mode 100644 maven/trivial-test/src/test/java/com/io7m/example/jogl_mvn_test_2/TestJOGL.java (limited to 'maven') diff --git a/maven/trivial-test/README.txt b/maven/trivial-test/README.txt new file mode 100644 index 0000000..fdc4b3f --- /dev/null +++ b/maven/trivial-test/README.txt @@ -0,0 +1,31 @@ +First, because the project isn't in the Central Repository yet, Maven +needs to be told to look at http://www.jogamp.org. Edit ~/.m2/settings.xml: + + + + + jogamp + + + true + + + + jogamp-remote + jogamp test mirror + http://www.jogamp.org/deployment/maven/ + default + + + + + + +Then, run: + + $ mvn clean test + +It should download all of the required packages (which may be quite a few +if you've not run Maven before) and then compile and run the included test +program. + diff --git a/maven/trivial-test/pom.xml b/maven/trivial-test/pom.xml new file mode 100644 index 0000000..1300b1c --- /dev/null +++ b/maven/trivial-test/pom.xml @@ -0,0 +1,50 @@ + + 4.0.0 + + com.io7m.example + jogl-mvn-test + 1.0.0 + jar + + jogl-mvn-test + http://maven.apache.org + + + UTF-8 + + + + + junit + junit + 4.10 + test + + + org.jogamp.gluegen + gluegen-rt-main + 2.0-rc9 + + + org.jogamp.jogl + jogl-all-main + 2.0-rc9 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + + + diff --git a/maven/trivial-test/src/test/java/com/io7m/example/jogl_mvn_test_2/TestJOGL.java b/maven/trivial-test/src/test/java/com/io7m/example/jogl_mvn_test_2/TestJOGL.java new file mode 100644 index 0000000..54bfe29 --- /dev/null +++ b/maven/trivial-test/src/test/java/com/io7m/example/jogl_mvn_test_2/TestJOGL.java @@ -0,0 +1,107 @@ +package com.io7m.example.jogl_mvn_test_2; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import org.junit.Test; + +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.FPSAnimator; + +public class TestJOGL +{ + private static GLWindow makeWindow( + final String name) + { + final GLProfile pro = GLProfile.getDefault(); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + window.setSize(640, 480); + window.setVisible(true); + window.setTitle(name); + window.addWindowListener(new WindowAdapter() { + @Override public void windowDestroyNotify( + final WindowEvent e) + { + // System.exit(0); + } + }); + window.addGLEventListener(new GLEventListener() { + int quad_x = (int) (Math.random() * 640); + int quad_y = (int) (Math.random() * 480); + + public void display( + final GLAutoDrawable drawable) + { + System.out.println("thread " + + Thread.currentThread().getId() + + " display"); + + this.quad_x = (this.quad_x + 1) % 640; + this.quad_y = (this.quad_y + 1) % 480; + + final GL2 g2 = drawable.getGL().getGL2(); + g2.glClearColor(0.0f, 0.0f, 0.3f, 1.0f); + g2.glClear(GL.GL_COLOR_BUFFER_BIT); + + g2.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + g2.glLoadIdentity(); + g2.glOrtho(0, 640, 0, 480, 1, 100); + g2.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + g2.glLoadIdentity(); + g2.glTranslated(0, 0, -1); + + g2.glBegin(GL2.GL_QUADS); + { + g2.glVertex2d(this.quad_x, this.quad_y + 10); + g2.glVertex2d(this.quad_x, this.quad_y); + g2.glVertex2d(this.quad_x + 10, this.quad_y); + g2.glVertex2d(this.quad_x + 10, this.quad_y + 10); + } + g2.glEnd(); + } + + public void dispose( + final GLAutoDrawable arg0) + { + // TODO Auto-generated method stub + } + + public void init( + final GLAutoDrawable arg0) + { + // TODO Auto-generated method stub + } + + public void reshape( + final GLAutoDrawable arg0, + final int arg1, + final int arg2, + final int arg3, + final int arg4) + { + // TODO Auto-generated method stub + } + }); + + final FPSAnimator animator = new FPSAnimator(window, 60); + animator.start(); + + return window; + } + + @Test public void go() + throws InterruptedException + { + final GLWindow window0 = TestJOGL.makeWindow("Window 0"); + Thread.sleep(1000); + } +} -- cgit v1.2.3