Commits

Michael Ludwig committed 2644799

Move all test applications into ferox-test module, to act as a collection of integration tests. Now src/test/java can be reserved for proper JUnit test cases (not that I have any).

  • Participants
  • Parent commits 1ed09cf

Comments (0)

Files changed (29)

   physics engine to easily add physics simulations to 3D scenes.
 * `ferox-util` - A collection of utilities ranging from java.util.collections
   extensions to profiling and runtime monitoring tools.
+* `ferox-test` - Test applications for the other modules.
   

ferox-physics/pom.xml

             <artifactId>entreri</artifactId>
             <version>${entreri.version}</version>
         </dependency>
-        
-        <dependency>
-            <groupId>com.lhkbob.ferox</groupId>
-            <artifactId>ferox-test</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.lhkbob.ferox</groupId>
-            <artifactId>ferox-scene</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.lhkbob.ferox</groupId>
-            <artifactId>ferox-renderer-lwjgl</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>

ferox-physics/src/test/java/com/ferox/physics/GravityTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.physics;
-
-import com.ferox.math.ColorRGB;
-import com.ferox.math.Matrix4;
-import com.ferox.math.Vector3;
-import com.ferox.physics.collision.CollisionBody;
-import com.ferox.physics.dynamics.Gravity;
-import com.ferox.physics.dynamics.RigidBody;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.resource.VertexBufferObject.StorageMode;
-import com.ferox.scene.AmbientLight;
-import com.ferox.scene.BlinnPhongMaterial;
-import com.ferox.scene.Camera;
-import com.ferox.scene.DiffuseColor;
-import com.ferox.scene.PointLight;
-import com.ferox.scene.Renderable;
-import com.ferox.scene.Transform;
-import com.ferox.util.geom.Geometry;
-import com.lhkbob.entreri.Entity;
-
-public class GravityTest extends PhysicsApplicationStub {
-    private static final StorageMode COMPILE_TYPE = StorageMode.GPU_STATIC;
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        super.init(surface);
-
-        // camera
-        Entity camera = system.addEntity();
-        camera.add(Camera.ID).getData().setSurface(surface)
-              .setZDistances(1.0, 6 * BOUNDS);
-        camera.add(Transform.ID)
-              .getData()
-              .setMatrix(new Matrix4(-1,
-                                     0,
-                                     0,
-                                     0,
-                                     0,
-                                     1,
-                                     0,
-                                     0,
-                                     0,
-                                     0,
-                                     -1,
-                                     .75 * BOUNDS,
-                                     0,
-                                     0,
-                                     0,
-                                     1));
-
-        // shapes
-        Geometry geomShape1 = com.ferox.util.geom.Box.create(2 + 2 * MARGIN, COMPILE_TYPE);
-        com.ferox.physics.collision.Shape physShape1 = new com.ferox.physics.collision.shape.Box(2,
-                                                                                                 2,
-                                                                                                 2);
-
-        Geometry geomShape2 = com.ferox.util.geom.Box.create(2 + 2 * MARGIN, COMPILE_TYPE);
-        com.ferox.physics.collision.Shape physShape2 = new com.ferox.physics.collision.shape.Box(2,
-                                                                                                 2,
-                                                                                                 2);
-
-        //        Geometry geomShape1 = new com.ferox.util.geom.Sphere(1 + MARGIN, 16, COMPILE_TYPE);
-        //        com.ferox.physics.collision.Shape physShape1 = new com.ferox.physics.collision.shape.Sphere(1);
-
-        physShape1.setMargin(MARGIN);
-        physShape2.setMargin(MARGIN);
-
-        // falling down entity
-        Entity e = system.addEntity();
-        e.add(Renderable.ID)
-         .getData()
-         .setVertices(geomShape1.getVertices())
-         .setLocalBounds(geomShape1.getBounds())
-         .setIndices(geomShape1.getPolygonType(), geomShape1.getIndices(),
-                     geomShape1.getIndexOffset(), geomShape1.getIndexCount());
-        e.add(BlinnPhongMaterial.ID).getData().setNormals(geomShape1.getNormals());
-        e.add(DiffuseColor.ID).getData().setColor(new ColorRGB(1.0, 0.0, 0.0));
-        e.add(Transform.ID);
-
-        e.add(CollisionBody.ID)
-         .getData()
-         .setShape(physShape1)
-         .setTransform(new Matrix4(1,
-                                   0,
-                                   0,
-                                   0,
-                                   0,
-                                   1,
-                                   0,
-                                   BOUNDS / 2,
-                                   0,
-                                   0,
-                                   1,
-                                   0,
-                                   0,
-                                   0,
-                                   0,
-                                   1));
-        e.add(RigidBody.ID).getData().setMass(1.0);
-        e.add(Gravity.ID).getData().setGravity(new Vector3(0, -10, 0));
-
-        // falling up entity
-        e = system.addEntity();
-        e.add(Renderable.ID)
-         .getData()
-         .setVertices(geomShape2.getVertices())
-         .setLocalBounds(geomShape2.getBounds())
-         .setIndices(geomShape2.getPolygonType(), geomShape2.getIndices(),
-                     geomShape2.getIndexOffset(), geomShape2.getIndexCount());
-        e.add(BlinnPhongMaterial.ID).getData().setNormals(geomShape2.getNormals());
-        e.add(DiffuseColor.ID).getData().setColor(new ColorRGB(0.0, 1.0, 0.0));
-        e.add(Transform.ID);
-
-        e.add(CollisionBody.ID)
-         .getData()
-         .setShape(physShape2)
-         .setTransform(new Matrix4(1,
-                                   0,
-                                   0,
-                                   0,
-                                   0,
-                                   1,
-                                   0,
-                                   -BOUNDS / 2,
-                                   0,
-                                   0,
-                                   1,
-                                   0,
-                                   0,
-                                   0,
-                                   0,
-                                   1));
-        e.add(RigidBody.ID).getData().setMass(1.0);
-        e.add(Gravity.ID).getData().setGravity(new Vector3(0, 10, 0));
-
-        // ambient light
-        system.addEntity().add(AmbientLight.ID).getData()
-              .setColor(new ColorRGB(0.2, 0.2, 0.2));
-
-        // a point light
-        Entity point = system.addEntity();
-        point.add(PointLight.ID).getData().setColor(new ColorRGB(0.5, 0.5, 0.5));
-        point.add(Transform.ID)
-             .getData()
-             .setMatrix(new Matrix4(1,
-                                    0,
-                                    0,
-                                    BOUNDS / 2,
-                                    0,
-                                    1,
-                                    0,
-                                    BOUNDS / 2,
-                                    0,
-                                    0,
-                                    1,
-                                    BOUNDS / 2,
-                                    0,
-                                    0,
-                                    0,
-                                    1));
-    }
-
-    public static void main(String[] args) throws Exception {
-        new GravityTest().run();
-    }
-}

ferox-physics/src/test/java/com/ferox/physics/PhysicsApplicationStub.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.physics;
-
-import com.ferox.input.KeyEvent.KeyCode;
-import com.ferox.input.logic.Action;
-import com.ferox.input.logic.InputManager;
-import com.ferox.input.logic.InputState;
-import com.ferox.input.logic.Predicates;
-import com.ferox.math.AxisAlignedBox;
-import com.ferox.math.Vector3;
-import com.ferox.math.bounds.QuadTree;
-import com.ferox.physics.collision.CollisionBody;
-import com.ferox.physics.collision.DefaultCollisionAlgorithmProvider;
-import com.ferox.physics.controller.SpatialIndexCollisionController;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.renderer.impl.lwjgl.LwjglFramework;
-import com.ferox.scene.Transform;
-import com.ferox.scene.controller.CameraController;
-import com.ferox.scene.controller.SpatialIndexController;
-import com.ferox.scene.controller.VisibilityController;
-import com.ferox.scene.controller.WorldBoundsController;
-import com.ferox.scene.controller.ffp.FixedFunctionRenderController;
-import com.ferox.scene.controller.light.LightGroupController;
-import com.ferox.util.ApplicationStub;
-import com.lhkbob.entreri.ComponentIterator;
-import com.lhkbob.entreri.Entity;
-import com.lhkbob.entreri.EntitySystem;
-import com.lhkbob.entreri.SimpleController;
-
-public class PhysicsApplicationStub extends ApplicationStub {
-    protected static final int BOUNDS = 100;
-    protected static final double MARGIN = .05;
-
-    protected static final AxisAlignedBox worldBounds = new AxisAlignedBox(new Vector3(-2 * BOUNDS - 1,
-                                                                                       -2 * BOUNDS - 1,
-                                                                                       -2 * BOUNDS - 1),
-                                                                           new Vector3(2 * BOUNDS + 1,
-                                                                                       2 * BOUNDS + 1,
-                                                                                       2 * BOUNDS + 1));
-
-    private boolean paused;
-    private boolean stepOnce;
-
-    protected final EntitySystem system;
-
-    public PhysicsApplicationStub() {
-        super(LwjglFramework.create());
-        system = new EntitySystem();
-    }
-
-    @Override
-    protected void installInputHandlers(InputManager io) {
-        io.on(Predicates.keyPress(KeyCode.SPACE)).trigger(new Action() {
-            @Override
-            public void perform(InputState prev, InputState next) {
-                paused = !paused;
-            }
-        });
-        io.on(Predicates.keyPress(KeyCode.S)).trigger(new Action() {
-            @Override
-            public void perform(InputState prev, InputState next) {
-                stepOnce = true;
-            }
-        });
-    }
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        // physics handling
-        system.getControllerManager()
-              .addController(new com.ferox.physics.controller.ForcesController());
-
-        //        system.getControllerManager().addController(new SpatialIndexCollisionController(new com.ferox.math.bounds.QuadTree<Entity>(worldBounds, 6), new DefaultCollisionAlgorithmProvider()));
-        //        system.getControllerManager().addController(new SpatialIndexCollisionController(new com.ferox.math.bounds.SimpleSpatialIndex<Entity>(), new DefaultCollisionAlgorithmProvider()));
-        system.getControllerManager()
-              .addController(new SpatialIndexCollisionController(new com.ferox.math.bounds.Octree<Entity>(worldBounds,
-                                                                                                          6),
-                                                                 new DefaultCollisionAlgorithmProvider()));
-
-        system.getControllerManager()
-              .addController(new com.ferox.physics.controller.ConstraintSolvingController());
-        system.getControllerManager()
-              .addController(new com.ferox.physics.controller.MotionController());
-
-        system.getControllerManager().addController(new TransformController());
-
-        // rendering
-        system.getControllerManager().addController(new WorldBoundsController());
-        system.getControllerManager().addController(new CameraController());
-        system.getControllerManager()
-              .addController(new SpatialIndexController(new QuadTree<Entity>(worldBounds,
-                                                                             6)));
-        system.getControllerManager().addController(new VisibilityController());
-        system.getControllerManager()
-              .addController(new LightGroupController(worldBounds));
-        system.getControllerManager()
-              .addController(new FixedFunctionRenderController(surface.getFramework()));
-
-        surface.setVSyncEnabled(true);
-    }
-
-    @Override
-    protected void renderFrame(OnscreenSurface surface) {
-        if (!paused || stepOnce) {
-            system.getControllerManager().process(1 / 60.0);
-            stepOnce = false;
-        }
-    }
-
-    private static class TransformController extends SimpleController {
-        @Override
-        public void process(double dt) {
-            CollisionBody cb = getEntitySystem().createDataInstance(CollisionBody.ID);
-            Transform t = getEntitySystem().createDataInstance(Transform.ID);
-
-            ComponentIterator it = new ComponentIterator(getEntitySystem());
-            it.addRequired(cb);
-            it.addRequired(t);
-
-            while (it.next()) {
-                t.setMatrix(cb.getTransform());
-            }
-        }
-    }
-}

ferox-physics/src/test/java/com/ferox/physics/PhysicsTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.physics;
-
-import com.ferox.math.ColorRGB;
-import com.ferox.math.Matrix4;
-import com.ferox.physics.collision.CollisionBody;
-import com.ferox.physics.dynamics.RigidBody;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.resource.VertexBufferObject.StorageMode;
-import com.ferox.scene.AmbientLight;
-import com.ferox.scene.BlinnPhongMaterial;
-import com.ferox.scene.Camera;
-import com.ferox.scene.DiffuseColor;
-import com.ferox.scene.DirectionLight;
-import com.ferox.scene.PointLight;
-import com.ferox.scene.Renderable;
-import com.ferox.scene.Transform;
-import com.ferox.util.geom.Box;
-import com.ferox.util.geom.Geometry;
-import com.lhkbob.entreri.Entity;
-
-public class PhysicsTest extends PhysicsApplicationStub {
-    private static final StorageMode COMPILE_TYPE = StorageMode.GPU_STATIC;
-
-    private static final int NUM_X = 5;
-    private static final int NUM_Y = 5;
-    private static final int NUM_Z = 5;
-    private static final double SCALE_X = 3.0;
-    private static final double SCALE_Y = 2.0;
-    private static final double SCALE_Z = 3.0;
-
-    private static final double RANDOM = 0;
-
-    private static final double START_POS_X = -5;
-    private static final double START_POS_Y = 1 + 2 * MARGIN;
-    private static final double START_POS_Z = -3;
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        super.init(surface);
-
-        // camera
-        Entity camera = system.addEntity();
-        camera.add(Camera.ID).getData().setSurface(surface)
-              .setZDistances(1.0, 6 * BOUNDS);
-        camera.add(Transform.ID)
-              .getData()
-              .setMatrix(new Matrix4(-.707,
-                                     -.577,
-                                     -.707,
-                                     .3 * BOUNDS,
-                                     0,
-                                     .577,
-                                     0,
-                                     .2 * BOUNDS,
-                                     .707,
-                                     -.577,
-                                     -.707,
-                                     .3 * BOUNDS,
-                                     0,
-                                     0,
-                                     0,
-                                     1));
-
-        // shapes
-        Geometry box = Box.create(2 + 2 * MARGIN, COMPILE_TYPE);
-        //        Geometry sphere = Sphere.create(1 + MARGIN, 8, COMPILE_TYPE);
-
-        com.ferox.physics.collision.Shape boxShape = new com.ferox.physics.collision.shape.Box(2,
-                                                                                               2,
-                                                                                               2);
-        //        com.ferox.physics.collision.Shape sphereShape = new com.ferox.physics.collision.shape.Sphere(1);
-        boxShape.setMargin(MARGIN);
-        //        sphereShape.setMargin(MARGIN);
-
-        double startX = START_POS_X - NUM_X / 2.0;
-        double startY = START_POS_Y;
-        double startZ = START_POS_Z - NUM_Z / 2.0;
-
-        double randXLim = RANDOM * (SCALE_X - 2.0) / 2.0;
-        double randYLim = RANDOM * (SCALE_Y - 2.0) / 2.0;
-        double randZLim = RANDOM * (SCALE_Z - 2.0) / 2.0;
-
-        for (int z = 0; z < NUM_Z; z++) {
-            for (int y = 0; y < NUM_Y; y++) {
-                for (int x = 0; x < NUM_X; x++) {
-                    com.ferox.physics.collision.Shape physShape;
-                    Geometry geomShape;
-                    ColorRGB color;
-
-                    physShape = boxShape;
-                    geomShape = box;
-                    color = new ColorRGB(.7, .2, .2);
-
-                    double rx = (Math.random() * randXLim - randXLim / 2);
-                    double ry = (Math.random() * randYLim - randYLim / 2);
-                    double rz = (Math.random() * randZLim - randZLim / 2);
-
-                    Entity e = system.addEntity();
-                    e.add(Renderable.ID)
-                     .getData()
-                     .setVertices(geomShape.getVertices())
-                     .setLocalBounds(geomShape.getBounds())
-                     .setIndices(geomShape.getPolygonType(), geomShape.getIndices(),
-                                 geomShape.getIndexOffset(), geomShape.getIndexCount());
-                    e.add(BlinnPhongMaterial.ID).getData()
-                     .setNormals(geomShape.getNormals());
-                    e.add(DiffuseColor.ID).getData().setColor(color);
-                    e.add(Transform.ID);
-
-                    e.add(CollisionBody.ID)
-                     .getData()
-                     .setShape(physShape)
-                     .setTransform(new Matrix4(1,
-                                               0,
-                                               0,
-                                               (SCALE_X + 2 * MARGIN) * x + rx + startX,
-                                               0,
-                                               1,
-                                               0,
-                                               (SCALE_Y + 2 * MARGIN + (y > NUM_Y / 2 ? 1 : 0)) * y + ry + startY,
-                                               0,
-                                               0,
-                                               1,
-                                               (SCALE_Z + 2 * MARGIN) * z + rz + startZ,
-                                               0,
-                                               0,
-                                               0,
-                                               1));
-                    e.add(RigidBody.ID).getData().setMass(1.0);
-                }
-            }
-        }
-
-        // some walls
-        Geometry bottomWall = Box.create(BOUNDS + 2 * MARGIN, COMPILE_TYPE);
-        Entity wall = system.addEntity();
-        wall.add(Renderable.ID)
-            .getData()
-            .setVertices(bottomWall.getVertices())
-            .setLocalBounds(bottomWall.getBounds())
-            .setIndices(bottomWall.getPolygonType(), bottomWall.getIndices(),
-                        bottomWall.getIndexOffset(), bottomWall.getIndexCount());
-        wall.add(BlinnPhongMaterial.ID).getData().setNormals(bottomWall.getNormals());
-        wall.add(DiffuseColor.ID).getData().setColor(new ColorRGB(0.5, 0.5, 0.5));
-        wall.add(Transform.ID);
-
-        wall.add(CollisionBody.ID)
-            .getData()
-            .setShape(new com.ferox.physics.collision.shape.Box(BOUNDS, BOUNDS, BOUNDS))
-            .setTransform(new Matrix4(1,
-                                      0,
-                                      0,
-                                      0,
-                                      0,
-                                      1,
-                                      0,
-                                      -BOUNDS / 2,
-                                      0,
-                                      0,
-                                      1,
-                                      0,
-                                      0,
-                                      0,
-                                      0,
-                                      1));
-
-        // ambient light
-        system.addEntity().add(AmbientLight.ID).getData()
-              .setColor(new ColorRGB(0.2, 0.2, 0.2));
-
-        // a point light
-        Entity point = system.addEntity();
-        point.add(PointLight.ID).getData().setColor(new ColorRGB(0.5, 0.5, 0.5));
-        point.add(Transform.ID)
-             .getData()
-             .setMatrix(new Matrix4(1,
-                                    0,
-                                    0,
-                                    BOUNDS / 2,
-                                    0,
-                                    1,
-                                    0,
-                                    BOUNDS / 2,
-                                    0,
-                                    0,
-                                    1,
-                                    BOUNDS / 2,
-                                    0,
-                                    0,
-                                    0,
-                                    1));
-
-        // a directed light, which casts shadows
-        Entity inf = system.addEntity();
-        inf.add(DirectionLight.ID).getData().setColor(new ColorRGB(1, 1, 1));
-        inf.add(Transform.ID);
-    }
-
-    public static void main(String[] args) {
-        new PhysicsTest().run();
-    }
-}

ferox-physics/src/test/resources/ferox-gl.tga

Removed
Old image

ferox-renderer/ferox-renderer-jogl/pom.xml

             <artifactId>ferox-renderer-impl</artifactId>
             <version>${project.version}</version>
         </dependency>
-        
-        <dependency>
-            <groupId>com.lhkbob.ferox</groupId>
-            <artifactId>ferox-test</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>

ferox-renderer/ferox-renderer-jogl/src/test/java/com/ferox/renderer/impl/jogl/FixedFunctionRenderTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.renderer.impl.jogl;
-
-import com.ferox.input.logic.InputManager;
-import com.ferox.math.Matrix4;
-import com.ferox.math.Vector3;
-import com.ferox.math.Vector4;
-import com.ferox.math.bounds.Frustum;
-import com.ferox.renderer.Context;
-import com.ferox.renderer.FixedFunctionRenderer;
-import com.ferox.renderer.FixedFunctionRenderer.TexCoord;
-import com.ferox.renderer.FixedFunctionRenderer.TexCoordSource;
-import com.ferox.renderer.HardwareAccessLayer;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.renderer.Renderer.DrawStyle;
-import com.ferox.renderer.Surface;
-import com.ferox.renderer.Task;
-import com.ferox.resource.BufferData;
-import com.ferox.resource.Mipmap;
-import com.ferox.resource.Texture;
-import com.ferox.resource.Texture.Filter;
-import com.ferox.resource.Texture.Target;
-import com.ferox.resource.TextureFormat;
-import com.ferox.resource.VertexBufferObject.StorageMode;
-import com.ferox.util.ApplicationStub;
-import com.ferox.util.geom.Geometry;
-import com.ferox.util.geom.Sphere;
-
-public class FixedFunctionRenderTest extends ApplicationStub {
-    private FixedFunctionPass pass;
-
-    public FixedFunctionRenderTest() {
-        super(JoglFramework.create());
-    }
-
-    @Override
-    protected void installInputHandlers(InputManager io) {}
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        pass = new FixedFunctionPass(surface);
-    }
-
-    @Override
-    protected void renderFrame(OnscreenSurface surface) {
-        surface.getFramework().queue(pass);
-    }
-
-    private static class FixedFunctionPass implements Task<Void> {
-        final Geometry shape;
-
-        final Texture volume;
-
-        final Frustum f;
-
-        boolean statusChecked;
-        final Surface surface;
-
-        public FixedFunctionPass(Surface surface) {
-            this.surface = surface;
-
-            shape = Sphere.create(2f, 32, StorageMode.GPU_STATIC);
-
-            f = new Frustum(60f,
-                            surface.getWidth() / (float) surface.getHeight(),
-                            1f,
-                            100f);
-            f.setOrientation(new Vector3(0f, 3f, 10f), new Vector3(0f, 0f, -1f),
-                             new Vector3(0f, 1f, 0f));
-
-            int width = 256;
-            int height = 256;
-            int depth = 256;
-
-            byte[] volumeBuffer = new byte[width * height * depth * 4];
-            for (int z = 0; z < depth; z++) {
-                for (int y = 0; y < height; y++) {
-                    for (int x = 0; x < width; x++) {
-                        int index = z * width * height * 4 + y * width * 4 + x * 4;
-
-                        volumeBuffer[index] = (byte) (z / (float) depth * 256);
-                        volumeBuffer[index + 1] = (byte) (y / (float) height * 256);
-                        volumeBuffer[index + 2] = (byte) (x / (float) width * 256);
-                        volumeBuffer[index + 3] = (byte) 127;
-                    }
-                }
-            }
-
-            Mipmap data = new Mipmap(new BufferData(volumeBuffer),
-                                     width,
-                                     height,
-                                     depth,
-                                     TextureFormat.RGBA);
-            volume = new Texture(Target.T_3D, data);
-            volume.setFilter(Filter.NEAREST);
-        }
-
-        @Override
-        public Void run(HardwareAccessLayer access) {
-            Context context = access.setActiveSurface(surface);
-            if (context == null) {
-                return null;
-            }
-
-            FixedFunctionRenderer g = context.getFixedFunctionRenderer();
-            if (g != null) {
-                g.clear(true, true, true, new Vector4(.2f, .2f, .2f, 1f), 1, 0);
-
-                g.setDrawStyle(DrawStyle.SOLID);
-
-                g.setVertices(shape.getVertices());
-                g.setNormals(shape.getNormals());
-                g.setTextureCoordinates(0, shape.getTextureCoordinates());
-
-                g.setTexture(0, volume);
-                g.setTextureCoordGeneration(0, TexCoord.R, TexCoordSource.OBJECT);
-
-                g.setProjectionMatrix(f.getProjectionMatrix());
-
-                Matrix4 t = new Matrix4();
-                int rendered = 0;
-                for (int i = 0; i < 10000; i++) {
-                    t.setIdentity();
-                    t.set(0, 3, (float) Math.random() * 100 - 50);
-                    t.set(1, 3, (float) Math.random() * 100 - 50);
-                    t.set(2, 3, (float) Math.random() * 100 - 50);
-
-                    g.setModelViewMatrix(f.getViewMatrix().mul(t, t));
-
-                    if (shape.getIndices() != null) {
-                        rendered += g.render(shape.getPolygonType(), shape.getIndices(),
-                                             shape.getIndexOffset(),
-                                             shape.getIndexCount());
-                    } else {
-                        rendered += g.render(shape.getPolygonType(),
-                                             shape.getIndexOffset(),
-                                             shape.getIndexCount());
-                    }
-                }
-
-                if (!statusChecked) {
-                    statusChecked = true;
-
-                    System.out.println("Rendered count: " + rendered);
-
-                    System.out.println("\nvertices status: " + surface.getFramework()
-                                                                      .getStatus(shape.getVertices()
-                                                                                      .getData()));
-                    System.out.println("\nnormals status: " + surface.getFramework()
-                                                                     .getStatus(shape.getNormals()
-                                                                                     .getData()));
-                    System.out.println("\ntexcoords status: " + surface.getFramework()
-                                                                       .getStatus(shape.getTextureCoordinates()
-                                                                                       .getData()));
-
-                    System.out.println("\ntexture status: " + surface.getFramework()
-                                                                     .getStatus(volume) + " " + surface.getFramework()
-                                                                                                       .getStatusMessage(volume));
-                }
-            }
-
-            return null;
-        }
-    }
-
-    public static void main(String[] args) {
-        new FixedFunctionRenderTest().run();
-    }
-}

ferox-renderer/ferox-renderer-jogl/src/test/java/com/ferox/renderer/impl/jogl/GlslRenderTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.renderer.impl.jogl;
-
-import java.util.Map;
-import java.util.Map.Entry;
-
-import com.ferox.input.logic.InputManager;
-import com.ferox.math.Vector3;
-import com.ferox.math.Vector4;
-import com.ferox.math.bounds.Frustum;
-import com.ferox.renderer.Context;
-import com.ferox.renderer.Framework;
-import com.ferox.renderer.GlslRenderer;
-import com.ferox.renderer.HardwareAccessLayer;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.renderer.Surface;
-import com.ferox.renderer.Task;
-import com.ferox.resource.BufferData;
-import com.ferox.resource.GlslShader;
-import com.ferox.resource.GlslShader.ShaderType;
-import com.ferox.resource.GlslUniform;
-import com.ferox.resource.Mipmap;
-import com.ferox.resource.Resource.Status;
-import com.ferox.resource.Texture;
-import com.ferox.resource.Texture.Filter;
-import com.ferox.resource.Texture.Target;
-import com.ferox.resource.TextureFormat;
-import com.ferox.util.ApplicationStub;
-import com.ferox.util.geom.Box;
-import com.ferox.util.geom.Geometry;
-
-public class GlslRenderTest extends ApplicationStub {
-    private static final String VERTEX_SHADER = "uniform mat4 projection;" + "uniform mat4 modelview;" + "uniform vec2 transform;" +
-
-    "attribute vec3 vertex;" + "varying vec3 tcs;" +
-
-    "void main() {" + "   tcs = vec3((vertex.x + transform.x) * transform.y, (vertex.y + transform.x) * transform.y, (vertex.z + transform.x) * transform.y);" + "   gl_Position = projection * modelview * vec4(vertex, 1.0);" + "}";
-    private static final String FRAGMENT_SHADER = "uniform vec4 color;" + "uniform sampler3D texture;" +
-
-    "varying vec3 tcs;" +
-
-    "void main() {" + "   gl_FragColor = texture3D(texture, tcs) * color;" + "}";
-
-    private GlslPass pass;
-
-    public GlslRenderTest() {
-        super(JoglFramework.create());
-    }
-
-    @Override
-    protected void installInputHandlers(InputManager io) {}
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        Framework framework = surface.getFramework();
-        pass = new GlslPass(surface);
-        Status status = framework.update(pass.shader);
-        if (status != Status.READY) {
-            System.out.println("Shader: " + status + " " + framework.getStatusMessage(pass.shader));
-            framework.destroy();
-            System.exit(0);
-        }
-    }
-
-    @Override
-    protected void renderFrame(OnscreenSurface surface) {
-        surface.getFramework().queue(pass);
-    }
-
-    public static void main(String[] args) throws Exception {
-        new GlslRenderTest().run();
-    }
-
-    private static class GlslPass implements Task<Void> {
-        final GlslShader shader;
-        final Geometry shape;
-
-        final Texture volume;
-
-        final Frustum f;
-
-        boolean statusChecked;
-        final Surface surface;
-
-        public GlslPass(Surface surface) {
-            this.surface = surface;
-
-            shape = Box.create(4.0);
-            shader = new GlslShader();
-
-            shader.setShader(ShaderType.VERTEX, VERTEX_SHADER);
-            shader.setShader(ShaderType.FRAGMENT, FRAGMENT_SHADER);
-
-            f = new Frustum(60f,
-                            surface.getWidth() / (float) surface.getHeight(),
-                            1f,
-                            100f);
-            f.setOrientation(new Vector3(0f, 3f, 10f), new Vector3(0f, 0f, -1f),
-                             new Vector3(0f, 1f, 0f));
-
-            int width = 256;
-            int height = 256;
-            int depth = 256;
-
-            byte[] volumeBuffer = new byte[width * height * depth * 4];
-            for (int z = 0; z < depth; z++) {
-                for (int y = 0; y < height; y++) {
-                    for (int x = 0; x < width; x++) {
-                        int index = z * width * height * 4 + y * width * 4 + x * 4;
-
-                        volumeBuffer[index] = (byte) (z / (float) depth * 256);
-                        volumeBuffer[index + 1] = (byte) (y / (float) height * 256);
-                        volumeBuffer[index + 2] = (byte) (x / (float) width * 256);
-                        volumeBuffer[index + 3] = (byte) 127;
-                    }
-                }
-            }
-
-            Mipmap data = new Mipmap(new BufferData(volumeBuffer),
-                                     width,
-                                     height,
-                                     depth,
-                                     TextureFormat.RGBA);
-            volume = new Texture(Target.T_3D, data);
-            volume.setFilter(Filter.NEAREST);
-        }
-
-        @Override
-        public Void run(HardwareAccessLayer access) {
-            Context context = access.setActiveSurface(surface);
-            if (context == null) {
-                return null;
-            }
-
-            GlslRenderer g = context.getGlslRenderer();
-            if (g != null) {
-                g.clear(true, true, true, new Vector4(.2f, .2f, .2f, 1f), 1, 0);
-
-                g.setShader(shader);
-                g.bindAttribute("vertex", shape.getVertices());
-
-                g.setUniform("projection", f.getProjectionMatrix());
-                g.setUniform("modelview", f.getViewMatrix());
-
-                g.setUniform("color", new Vector4(1f, 1f, 1f, 1f));
-                g.setUniform("texture", volume);
-
-                g.setUniform("transform", 2f, .25f);
-
-                int rendered = g.render(shape.getPolygonType(), shape.getIndexOffset(),
-                                        shape.getIndexCount());
-
-                if (!statusChecked) {
-                    statusChecked = true;
-
-                    System.out.println("Rendered count: " + rendered);
-
-                    Status shaderStatus = surface.getFramework().getStatus(shader);
-                    String shaderMsg = surface.getFramework().getStatusMessage(shader);
-
-                    System.out.println(shaderStatus + " " + shaderMsg);
-
-                    System.out.println("uniforms:");
-                    Map<String, GlslUniform> uniforms = g.getUniforms();
-                    for (Entry<String, GlslUniform> u : uniforms.entrySet()) {
-                        GlslUniform uniform = u.getValue();
-                        System.out.println(uniform.getName() + " " + uniform.getType() + " " + uniform.getLength());
-                    }
-
-                    System.out.println("\nattributes:");
-                    System.out.println(g.getAttributes());
-
-                    System.out.println("\ntexture status: " + surface.getFramework()
-                                                                     .getStatus(volume) + " " + surface.getFramework()
-                                                                                                       .getStatusMessage(volume));
-                }
-            }
-
-            return null;
-        }
-    }
-}

ferox-renderer/ferox-renderer-jogl/src/test/java/com/ferox/renderer/impl/jogl/SelfDestructTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.renderer.impl.jogl;
-
-import com.ferox.renderer.Framework;
-import com.ferox.renderer.HardwareAccessLayer;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.renderer.OnscreenSurfaceOptions;
-import com.ferox.renderer.Task;
-
-public class SelfDestructTest {
-    public static void main(String[] args) throws Exception {
-        final Framework f = JoglFramework.create();
-        System.out.println("framework created");
-        final OnscreenSurface surface = f.createSurface(new OnscreenSurfaceOptions()
-        //            .setFullscreenMode(new DisplayMode(1024, 768, PixelFormat.RGB_24BIT))
-        .setUndecorated(true).setResizable(false).setWidth(500).setHeight(500));
-
-        System.out.println("surface created");
-        Thread.sleep(5000);
-
-        String result = f.queue(new Task<String>() {
-            @Override
-            public String run(HardwareAccessLayer access) {
-                System.out.println("activating surface");
-                access.setActiveSurface(surface);
-                System.out.println("destroying framework");
-                f.destroy();
-                return "finished";
-            }
-        }).get();
-
-        System.out.println(result);
-    }
-}

ferox-renderer/ferox-renderer-lwjgl/pom.xml

             <artifactId>lwjgl</artifactId>
             <version>2.8.4</version>
         </dependency>
-        
-        <dependency>
-            <groupId>com.lhkbob.ferox</groupId>
-            <artifactId>ferox-test</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>

ferox-renderer/ferox-renderer-lwjgl/src/test/java/com/ferox/renderer/impl/lwjgl/FixedFunctionRenderTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.renderer.impl.lwjgl;
-
-import com.ferox.input.logic.InputManager;
-import com.ferox.math.Matrix4;
-import com.ferox.math.Vector3;
-import com.ferox.math.Vector4;
-import com.ferox.math.bounds.Frustum;
-import com.ferox.renderer.Context;
-import com.ferox.renderer.FixedFunctionRenderer;
-import com.ferox.renderer.FixedFunctionRenderer.TexCoord;
-import com.ferox.renderer.FixedFunctionRenderer.TexCoordSource;
-import com.ferox.renderer.HardwareAccessLayer;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.renderer.Renderer.DrawStyle;
-import com.ferox.renderer.Surface;
-import com.ferox.renderer.Task;
-import com.ferox.resource.BufferData;
-import com.ferox.resource.Mipmap;
-import com.ferox.resource.Texture;
-import com.ferox.resource.Texture.Filter;
-import com.ferox.resource.Texture.Target;
-import com.ferox.resource.TextureFormat;
-import com.ferox.resource.VertexBufferObject.StorageMode;
-import com.ferox.util.ApplicationStub;
-import com.ferox.util.geom.Geometry;
-import com.ferox.util.geom.Sphere;
-
-public class FixedFunctionRenderTest extends ApplicationStub {
-    private FixedFunctionPass pass;
-
-    public FixedFunctionRenderTest() {
-        super(LwjglFramework.create());
-    }
-
-    @Override
-    protected void installInputHandlers(InputManager io) {}
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        pass = new FixedFunctionPass(surface);
-    }
-
-    @Override
-    protected void renderFrame(OnscreenSurface surface) {
-        surface.getFramework().queue(pass);
-    }
-
-    private static class FixedFunctionPass implements Task<Void> {
-        final Geometry shape;
-
-        final Texture volume;
-
-        final Frustum f;
-
-        boolean statusChecked;
-        final Surface surface;
-
-        public FixedFunctionPass(Surface surface) {
-            this.surface = surface;
-
-            shape = Sphere.create(2f, 32, StorageMode.GPU_STATIC);
-
-            f = new Frustum(60f,
-                            surface.getWidth() / (float) surface.getHeight(),
-                            1f,
-                            100f);
-            f.setOrientation(new Vector3(0f, 3f, 10f), new Vector3(0f, 0f, -1f),
-                             new Vector3(0f, 1f, 0f));
-
-            int width = 256;
-            int height = 256;
-            int depth = 256;
-
-            byte[] volumeBuffer = new byte[width * height * depth * 4];
-            for (int z = 0; z < depth; z++) {
-                for (int y = 0; y < height; y++) {
-                    for (int x = 0; x < width; x++) {
-                        int index = z * width * height * 4 + y * width * 4 + x * 4;
-
-                        volumeBuffer[index] = (byte) (z / (float) depth * 256);
-                        volumeBuffer[index + 1] = (byte) (y / (float) height * 256);
-                        volumeBuffer[index + 2] = (byte) (x / (float) width * 256);
-                        volumeBuffer[index + 3] = (byte) 127;
-                    }
-                }
-            }
-
-            Mipmap data = new Mipmap(new BufferData(volumeBuffer),
-                                     width,
-                                     height,
-                                     depth,
-                                     TextureFormat.RGBA);
-            volume = new Texture(Target.T_3D, data);
-            volume.setFilter(Filter.NEAREST);
-        }
-
-        @Override
-        public Void run(HardwareAccessLayer access) {
-            Context context = access.setActiveSurface(surface);
-            if (context == null) {
-                return null;
-            }
-
-            FixedFunctionRenderer g = context.getFixedFunctionRenderer();
-            if (g != null) {
-                g.clear(true, true, true, new Vector4(.2f, .2f, .2f, 1f), 1, 0);
-
-                g.setDrawStyle(DrawStyle.SOLID);
-
-                g.setVertices(shape.getVertices());
-                g.setNormals(shape.getNormals());
-                g.setTextureCoordinates(0, shape.getTextureCoordinates());
-
-                g.setTexture(0, volume);
-                g.setTextureCoordGeneration(0, TexCoord.R, TexCoordSource.OBJECT);
-
-                g.setProjectionMatrix(f.getProjectionMatrix());
-
-                Matrix4 t = new Matrix4();
-                int rendered = 0;
-                for (int i = 0; i < 10000; i++) {
-                    t.setIdentity();
-                    t.set(0, 3, (float) Math.random() * 100 - 50);
-                    t.set(1, 3, (float) Math.random() * 100 - 50);
-                    t.set(2, 3, (float) Math.random() * 100 - 50);
-
-                    g.setModelViewMatrix(f.getViewMatrix().mul(t, t));
-
-                    if (shape.getIndices() != null) {
-                        rendered += g.render(shape.getPolygonType(), shape.getIndices(),
-                                             shape.getIndexOffset(),
-                                             shape.getIndexCount());
-                    } else {
-                        rendered += g.render(shape.getPolygonType(),
-                                             shape.getIndexOffset(),
-                                             shape.getIndexCount());
-                    }
-                }
-
-                if (!statusChecked) {
-                    statusChecked = true;
-
-                    System.out.println("Rendered count: " + rendered);
-
-                    System.out.println("\nvertices status: " + surface.getFramework()
-                                                                      .getStatus(shape.getVertices()
-                                                                                      .getData()));
-                    System.out.println("\nnormals status: " + surface.getFramework()
-                                                                     .getStatus(shape.getNormals()
-                                                                                     .getData()));
-                    System.out.println("\ntexcoords status: " + surface.getFramework()
-                                                                       .getStatus(shape.getTextureCoordinates()
-                                                                                       .getData()));
-
-                    System.out.println("\ntexture status: " + surface.getFramework()
-                                                                     .getStatus(volume) + " " + surface.getFramework()
-                                                                                                       .getStatusMessage(volume));
-                }
-            }
-
-            return null;
-        }
-    }
-
-    public static void main(String[] args) {
-        new FixedFunctionRenderTest().run();
-    }
-}

ferox-renderer/ferox-renderer-lwjgl/src/test/java/com/ferox/renderer/impl/lwjgl/GlslRenderTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.renderer.impl.lwjgl;
-
-import java.util.Map;
-import java.util.Map.Entry;
-
-import com.ferox.input.logic.InputManager;
-import com.ferox.math.Vector3;
-import com.ferox.math.Vector4;
-import com.ferox.math.bounds.Frustum;
-import com.ferox.renderer.Context;
-import com.ferox.renderer.Framework;
-import com.ferox.renderer.GlslRenderer;
-import com.ferox.renderer.HardwareAccessLayer;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.renderer.Surface;
-import com.ferox.renderer.Task;
-import com.ferox.resource.BufferData;
-import com.ferox.resource.GlslShader;
-import com.ferox.resource.GlslShader.ShaderType;
-import com.ferox.resource.GlslUniform;
-import com.ferox.resource.Mipmap;
-import com.ferox.resource.Resource.Status;
-import com.ferox.resource.Texture;
-import com.ferox.resource.Texture.Filter;
-import com.ferox.resource.Texture.Target;
-import com.ferox.resource.TextureFormat;
-import com.ferox.util.ApplicationStub;
-import com.ferox.util.geom.Box;
-import com.ferox.util.geom.Geometry;
-
-public class GlslRenderTest extends ApplicationStub {
-    private static final String VERTEX_SHADER = "uniform mat4 projection;" + "uniform mat4 modelview;" + "uniform vec2 transform;" +
-
-    "attribute vec3 vertex;" + "varying vec3 tcs;" +
-
-    "void main() {" + "   tcs = vec3((vertex.x + transform.x) * transform.y, (vertex.y + transform.x) * transform.y, (vertex.z + transform.x) * transform.y);" + "   gl_Position = projection * modelview * vec4(vertex, 1.0);" + "}";
-    private static final String FRAGMENT_SHADER = "uniform vec4 color;" + "uniform sampler3D texture;" +
-
-    "varying vec3 tcs;" +
-
-    "void main() {" + "   gl_FragColor = texture3D(texture, tcs) * color;" + "}";
-
-    private GlslPass pass;
-
-    public GlslRenderTest() {
-        super(LwjglFramework.create());
-    }
-
-    @Override
-    protected void installInputHandlers(InputManager io) {}
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        Framework framework = surface.getFramework();
-        pass = new GlslPass(surface);
-        Status status = framework.update(pass.shader);
-        if (status != Status.READY) {
-            System.out.println("Shader: " + status + " " + framework.getStatusMessage(pass.shader));
-            framework.destroy();
-            System.exit(0);
-        }
-    }
-
-    @Override
-    protected void renderFrame(OnscreenSurface surface) {
-        surface.getFramework().queue(pass);
-    }
-
-    public static void main(String[] args) throws Exception {
-        new GlslRenderTest().run();
-    }
-
-    private static class GlslPass implements Task<Void> {
-        final GlslShader shader;
-        final Geometry shape;
-
-        final Texture volume;
-
-        final Frustum f;
-
-        boolean statusChecked;
-        final Surface surface;
-
-        public GlslPass(Surface surface) {
-            this.surface = surface;
-
-            shape = Box.create(4.0);
-            shader = new GlslShader();
-
-            shader.setShader(ShaderType.VERTEX, VERTEX_SHADER);
-            shader.setShader(ShaderType.FRAGMENT, FRAGMENT_SHADER);
-
-            f = new Frustum(60f,
-                            surface.getWidth() / (float) surface.getHeight(),
-                            1f,
-                            100f);
-            f.setOrientation(new Vector3(0f, 3f, 10f), new Vector3(0f, 0f, -1f),
-                             new Vector3(0f, 1f, 0f));
-
-            int width = 256;
-            int height = 256;
-            int depth = 256;
-
-            byte[] volumeBuffer = new byte[width * height * depth * 4];
-            for (int z = 0; z < depth; z++) {
-                for (int y = 0; y < height; y++) {
-                    for (int x = 0; x < width; x++) {
-                        int index = z * width * height * 4 + y * width * 4 + x * 4;
-
-                        volumeBuffer[index] = (byte) (z / (float) depth * 256);
-                        volumeBuffer[index + 1] = (byte) (y / (float) height * 256);
-                        volumeBuffer[index + 2] = (byte) (x / (float) width * 256);
-                        volumeBuffer[index + 3] = (byte) 127;
-                    }
-                }
-            }
-
-            Mipmap data = new Mipmap(new BufferData(volumeBuffer),
-                                     width,
-                                     height,
-                                     depth,
-                                     TextureFormat.RGBA);
-            volume = new Texture(Target.T_3D, data);
-            volume.setFilter(Filter.NEAREST);
-        }
-
-        @Override
-        public Void run(HardwareAccessLayer access) {
-            Context context = access.setActiveSurface(surface);
-            if (context == null) {
-                return null;
-            }
-
-            GlslRenderer g = context.getGlslRenderer();
-            if (g != null) {
-                g.clear(true, true, true, new Vector4(.2f, .2f, .2f, 1f), 1, 0);
-
-                g.setShader(shader);
-                g.bindAttribute("vertex", shape.getVertices());
-
-                g.setUniform("projection", f.getProjectionMatrix());
-                g.setUniform("modelview", f.getViewMatrix());
-
-                g.setUniform("color", new Vector4(1f, 1f, 1f, 1f));
-                g.setUniform("texture", volume);
-
-                g.setUniform("transform", 2f, .25f);
-
-                int rendered = g.render(shape.getPolygonType(), shape.getIndexOffset(),
-                                        shape.getIndexCount());
-
-                if (!statusChecked) {
-                    statusChecked = true;
-
-                    System.out.println("Rendered count: " + rendered);
-
-                    Status shaderStatus = surface.getFramework().getStatus(shader);
-                    String shaderMsg = surface.getFramework().getStatusMessage(shader);
-
-                    System.out.println(shaderStatus + " " + shaderMsg);
-
-                    System.out.println("uniforms:");
-                    Map<String, GlslUniform> uniforms = g.getUniforms();
-                    for (Entry<String, GlslUniform> u : uniforms.entrySet()) {
-                        GlslUniform uniform = u.getValue();
-                        System.out.println(uniform.getName() + " " + uniform.getType() + " " + uniform.getLength());
-                    }
-
-                    System.out.println("\nattributes:");
-                    System.out.println(g.getAttributes());
-
-                    System.out.println("\ntexture status: " + surface.getFramework()
-                                                                     .getStatus(volume) + " " + surface.getFramework()
-                                                                                                       .getStatusMessage(volume));
-                }
-            }
-
-            return null;
-        }
-    }
-}

ferox-renderer/ferox-renderer-lwjgl/src/test/java/com/ferox/renderer/impl/lwjgl/LightBlendingTest.java

-/*
- * Ferox, a graphics and game library in Java
- *
- * Copyright (c) 2012, Michael Ludwig
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *     Redistributions of source code must retain the above copyright notice,
- *         this list of conditions and the following disclaimer.
- *     Redistributions in binary form must reproduce the above copyright notice,
- *         this list of conditions and the following disclaimer in the
- *         documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.ferox.renderer.impl.lwjgl;
-
-import java.util.concurrent.Future;
-
-import com.ferox.input.logic.InputManager;
-import com.ferox.math.Vector3;
-import com.ferox.math.Vector4;
-import com.ferox.math.bounds.Frustum;
-import com.ferox.renderer.Context;
-import com.ferox.renderer.FixedFunctionRenderer;
-import com.ferox.renderer.HardwareAccessLayer;
-import com.ferox.renderer.OnscreenSurface;
-import com.ferox.renderer.Renderer.BlendFactor;
-import com.ferox.renderer.Renderer.BlendFunction;
-import com.ferox.renderer.Renderer.Comparison;
-import com.ferox.renderer.Task;
-import com.ferox.util.ApplicationStub;
-import com.ferox.util.geom.Box;
-import com.ferox.util.geom.Geometry;
-
-public class LightBlendingTest extends ApplicationStub {
-    private Geometry shape;
-    private Frustum frustum;
-
-    private Future<Void> lastFrame;
-
-    public LightBlendingTest() {
-        super(LwjglFramework.create());
-    }
-
-    @Override
-    protected void installInputHandlers(InputManager io) {}
-
-    @Override
-    protected void init(OnscreenSurface surface) {
-        shape = Box.create(3.0);
-        frustum = new Frustum(60f,
-                              surface.getWidth() / (double) surface.getHeight(),
-                              .1,
-                              100);
-        frustum.setOrientation(new Vector3(0, 2, -5), new Vector3(0, 0, 1),
-                               new Vector3(0, 1, 0));
-    }
-
-    @Override
-    protected void renderFrame(final OnscreenSurface surface) {
-        if (lastFrame != null) {
-            try {
-                lastFrame.get();
-            } catch (Exception e) {
-                throw new RuntimeException("Last frame failed", e);
-            }
-        }
-        lastFrame = surface.getFramework().queue(new Task<Void>() {
-            @Override
-            public Void run(HardwareAccessLayer access) {
-                Context ctx = access.setActiveSurface(surface);
-                FixedFunctionRenderer ffp = ctx.getFixedFunctionRenderer();
-
-                ffp.clear(true, true, true, new Vector4(.4, .4, .4, 1), 1, 0);
-
-                ffp.setLightingEnabled(true);
-                ffp.setMaterial(new Vector4(), new Vector4(.5, .5, .5, 1), new Vector4(),
-                                new Vector4());
-                ffp.setNormals(shape.getNormals());
-                ffp.setVertices(shape.getVertices());
-
-                ffp.setProjectionMatrix(frustum.getProjectionMatrix());
-                ffp.setModelViewMatrix(frustum.getViewMatrix());
-
-                // base light
-                ffp.setLightColor(0, new Vector4(), new Vector4(1, 0, 0, 1),
-                                  new Vector4());
-                ffp.setLightPosition(0, new Vector4(0, 4, -4, 1));
-                ffp.setLightEnabled(0, true);
-                //
-                ffp.setLightColor(1, new Vector4(), new Vector4(0, 1, 0, 1),
-                                  new Vector4());
-                ffp.setLightPosition(1, new Vector4(-4, 4, -4, 1));
-                ffp.setLightEnabled(1, true);
-                //