diff options
author | Kenneth Russel <[email protected]> | 2009-07-18 23:32:24 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2009-07-18 23:32:24 +0000 |
commit | a33fade58b3cf22b72241767e6615042a5ed22c1 (patch) | |
tree | 0f9700cb59193afbf27fef9481b2a28c2d14938d /src/net/java/joglutils/msg/test/Test.java | |
parent | 190d2e62712a7de5ee8e9a7989157d06b34aedd9 (diff) |
Updates to joglutils workspace to work with JOGL 2 APIs. Cleaned up
build process. Added targets for joglutils.jar and joglutils-demos.jar
as well as javadoc. Deleted build directory from svn.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/joglutils/trunk@103 83d24430-9974-4f80-8418-2cc3294053b9
Diffstat (limited to 'src/net/java/joglutils/msg/test/Test.java')
-rw-r--r-- | src/net/java/joglutils/msg/test/Test.java | 227 |
1 files changed, 114 insertions, 113 deletions
diff --git a/src/net/java/joglutils/msg/test/Test.java b/src/net/java/joglutils/msg/test/Test.java index a782e3e..d54d31b 100644 --- a/src/net/java/joglutils/msg/test/Test.java +++ b/src/net/java/joglutils/msg/test/Test.java @@ -35,116 +35,117 @@ * */ -package net.java.joglutils.msg.test;
-
-import java.awt.Frame;
-import java.awt.event.*;
-import java.io.*;
-
-import javax.media.opengl.*;
-import com.sun.opengl.util.texture.*;
-
-import net.java.joglutils.msg.actions.*;
-import net.java.joglutils.msg.collections.*;
-import net.java.joglutils.msg.math.*;
-import net.java.joglutils.msg.nodes.*;
-
-/** A very basic test of the Minimal Scene Graph library. */
-
-public class Test {
- public static void main(String[] args) {
- Frame frame = new Frame("Minimal Scene Graph (MSG) Test");
- GLCanvas canvas = new GLCanvas();
- canvas.addGLEventListener(new Listener());
- frame.add(canvas);
- frame.setSize(512, 512);
- frame.setVisible(true);
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- new Thread(new Runnable() {
- public void run() {
- System.exit(0);
- }
- }).start();
- }
- });
- }
-
- static class Listener implements GLEventListener {
- private Separator root;
- private GLRenderAction renderAction;
-
- public void init(GLAutoDrawable drawable) {
- root = new Separator();
- PerspectiveCamera cam = new PerspectiveCamera();
- cam.setPosition(new Vec3f(0, 0, 2));
- root.addChild(cam);
- Coordinate3 coordNode = new Coordinate3();
- Vec3fCollection coords = new Vec3fCollection();
- // First triangle
- coords.add(new Vec3f( 1, 1, 0));
- coords.add(new Vec3f(-1, 1, 0));
- coords.add(new Vec3f(-1, -1, 0));
- // Second triangle
- coords.add(new Vec3f( 1, 1, 0));
- coords.add(new Vec3f(-1, -1, 0));
- coords.add(new Vec3f( 1, -1, 0));
- coordNode.setData(coords);
- root.addChild(coordNode);
-
- // Texture coordinates
- TextureCoordinate2 texCoordNode = new TextureCoordinate2();
- Vec2fCollection texCoords = new Vec2fCollection();
- // First triangle
- texCoords.add(new Vec2f( 1, 1));
- texCoords.add(new Vec2f( 0, 1));
- texCoords.add(new Vec2f( 0, 0));
- // Second triangle
- texCoords.add(new Vec2f( 1, 1));
- texCoords.add(new Vec2f( 0, 0));
- texCoords.add(new Vec2f( 1, 0));
- texCoordNode.setData(texCoords);
- root.addChild(texCoordNode);
-
- // Colors
- Color4 colorNode = new Color4();
- Vec4fCollection colors = new Vec4fCollection();
- // First triangle
- colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
- colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
- colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
- // Second triangle
- colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
- colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
- colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f));
- colorNode.setData(colors);
- root.addChild(colorNode);
-
- TriangleSet tris = new TriangleSet();
- tris.setNumTriangles(2);
- root.addChild(tris);
-
- // Testing transforms
- Transform xform = new Transform();
- xform.getTransform().setTranslation(new Vec3f(2, -2, 0));
- // xform.getTransform().setRotation(new Rotf(new Vec3f(0, 1, 0), (float) (-Math.PI / 4)));
- root.addChild(xform);
-
- root.addChild(tris);
-
- GL gl = drawable.getGL();
- gl.glEnable(GL.GL_DEPTH_TEST);
-
- renderAction = new GLRenderAction();
- }
-
- public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- renderAction.apply(root);
- }
-
- public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {}
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
- }
-}
+package net.java.joglutils.msg.test; + +import java.awt.Frame; +import java.awt.event.*; +import java.io.*; + +import javax.media.opengl.*; +import javax.media.opengl.awt.*; +import com.sun.opengl.util.texture.*; + +import net.java.joglutils.msg.actions.*; +import net.java.joglutils.msg.collections.*; +import net.java.joglutils.msg.math.*; +import net.java.joglutils.msg.nodes.*; + +/** A very basic test of the Minimal Scene Graph library. */ + +public class Test { + public static void main(String[] args) { + Frame frame = new Frame("Minimal Scene Graph (MSG) Test"); + GLCanvas canvas = new GLCanvas(); + canvas.addGLEventListener(new Listener()); + frame.add(canvas); + frame.setSize(512, 512); + frame.setVisible(true); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + new Thread(new Runnable() { + public void run() { + System.exit(0); + } + }).start(); + } + }); + } + + static class Listener implements GLEventListener { + private Separator root; + private GLRenderAction renderAction; + + public void init(GLAutoDrawable drawable) { + root = new Separator(); + PerspectiveCamera cam = new PerspectiveCamera(); + cam.setPosition(new Vec3f(0, 0, 2)); + root.addChild(cam); + Coordinate3 coordNode = new Coordinate3(); + Vec3fCollection coords = new Vec3fCollection(); + // First triangle + coords.add(new Vec3f( 1, 1, 0)); + coords.add(new Vec3f(-1, 1, 0)); + coords.add(new Vec3f(-1, -1, 0)); + // Second triangle + coords.add(new Vec3f( 1, 1, 0)); + coords.add(new Vec3f(-1, -1, 0)); + coords.add(new Vec3f( 1, -1, 0)); + coordNode.setData(coords); + root.addChild(coordNode); + + // Texture coordinates + TextureCoordinate2 texCoordNode = new TextureCoordinate2(); + Vec2fCollection texCoords = new Vec2fCollection(); + // First triangle + texCoords.add(new Vec2f( 1, 1)); + texCoords.add(new Vec2f( 0, 1)); + texCoords.add(new Vec2f( 0, 0)); + // Second triangle + texCoords.add(new Vec2f( 1, 1)); + texCoords.add(new Vec2f( 0, 0)); + texCoords.add(new Vec2f( 1, 0)); + texCoordNode.setData(texCoords); + root.addChild(texCoordNode); + + // Colors + Color4 colorNode = new Color4(); + Vec4fCollection colors = new Vec4fCollection(); + // First triangle + colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f)); + colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f)); + colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f)); + // Second triangle + colors.add(new Vec4f(1.0f, 1.0f, 1.0f, 1.0f)); + colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f)); + colors.add(new Vec4f(0.0f, 0.0f, 0.0f, 0.0f)); + colorNode.setData(colors); + root.addChild(colorNode); + + TriangleSet tris = new TriangleSet(); + tris.setNumTriangles(2); + root.addChild(tris); + + // Testing transforms + Transform xform = new Transform(); + xform.getTransform().setTranslation(new Vec3f(2, -2, 0)); + // xform.getTransform().setRotation(new Rotf(new Vec3f(0, 1, 0), (float) (-Math.PI / 4))); + root.addChild(xform); + + root.addChild(tris); + + GL gl = drawable.getGL(); + gl.glEnable(GL.GL_DEPTH_TEST); + + renderAction = new GLRenderAction(); + } + + public void display(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + renderAction.apply(root); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {} + public void dispose(GLAutoDrawable drawable) {} + } +} |