summaryrefslogtreecommitdiffstats
path: root/maven/trivial-test
diff options
context:
space:
mode:
authorMark Raynsford <[email protected]>2012-06-27 20:35:44 +0000
committerMark Raynsford <[email protected]>2012-06-27 20:35:44 +0000
commit2365d7278bc5a64b4ff7856fd01d75214ea0f555 (patch)
tree496738f7120887bc2125e75cf503a9bb2c8e2219 /maven/trivial-test
parent1d1b473d08612d01d274642113ea37a7052daceb (diff)
Added trivial test
Diffstat (limited to 'maven/trivial-test')
-rw-r--r--maven/trivial-test/README.txt31
-rw-r--r--maven/trivial-test/pom.xml50
-rw-r--r--maven/trivial-test/src/test/java/com/io7m/example/jogl_mvn_test_2/TestJOGL.java107
3 files changed, 188 insertions, 0 deletions
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:
+
+<settings>
+ <profiles>
+ <profile>
+ <id>jogamp</id>
+ <activation>
+ <!-- Change this to false, if you don't like to have it on by default -->
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>jogamp-remote</id>
+ <name>jogamp test mirror</name>
+ <url>http://www.jogamp.org/deployment/maven/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
+ </profile>
+ </profiles>
+</settings>
+
+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 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.io7m.example</groupId>
+ <artifactId>jogl-mvn-test</artifactId>
+ <version>1.0.0</version>
+ <packaging>jar</packaging>
+
+ <name>jogl-mvn-test</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jogamp.gluegen</groupId>
+ <artifactId>gluegen-rt-main</artifactId>
+ <version>2.0-rc9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jogamp.jogl</groupId>
+ <artifactId>jogl-all-main</artifactId>
+ <version>2.0-rc9</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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);
+ }
+}