Commits

John Marsden  committed 36da051

Refactor for move to ECS Test/Debug

  • Participants
  • Parent commits 615806c

Comments (0)

Files changed (12)

File nbactions-Libraries.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+        <action>
+            <actionName>run</actionName>
+            <packagings>
+                <packaging>jar</packaging>
+            </packagings>
+            <goals>
+                <goal>process-classes</goal>
+                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
+            </goals>
+            <properties>
+                <exec.args>-Djava.library.path=/home/jmarsden/Source/Java/GLExamples.git/target/natives -classpath %classpath ${packageClassName}</exec.args>
+                <exec.executable>java</exec.executable>
+            </properties>
+        </action>
+        <action>
+            <actionName>debug</actionName>
+            <packagings>
+                <packaging>jar</packaging>
+            </packagings>
+            <goals>
+                <goal>process-classes</goal>
+                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
+            </goals>
+            <properties>
+                <exec.args>-Djava.library.path=/home/jmarsden/Source/Java/GLExamples.git/target/natives -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Djava.library.path=/home/jmarsden/Source/Java/GLExamples.git/target/natives -classpath %classpath ${packageClassName}</exec.args>
+                <exec.executable>java</exec.executable>
+                <jpda.listen>true</jpda.listen>
+            </properties>
+        </action>
+        <action>
+            <actionName>profile</actionName>
+            <packagings>
+                <packaging>jar</packaging>
+            </packagings>
+            <goals>
+                <goal>process-classes</goal>
+                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
+            </goals>
+            <properties>
+                <exec.args>-Djava.library.path=/home/jmarsden/Source/Java/GLExamples.git/target/natives -classpath %classpath ${packageClassName}</exec.args>
+                <exec.executable>java</exec.executable>
+            </properties>
+        </action>
+        <action>
+            <actionName>run.single.main</actionName>
+            <packagings>
+                <packaging>*</packaging>
+            </packagings>
+            <goals>
+                <goal>process-classes</goal>
+                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
+            </goals>
+            <properties>
+                <exec.args>-Djava.library.path=/home/jmarsden/Source/Java/GLExamples.git/target/natives -classpath %classpath ${packageClassName}</exec.args>
+                <exec.executable>java</exec.executable>
+                <exec.classpathScope>${classPathScope}</exec.classpathScope>
+            </properties>
+        </action>
+        <action>
+            <actionName>debug.single.main</actionName>
+            <packagings>
+                <packaging>*</packaging>
+            </packagings>
+            <goals>
+                <goal>process-classes</goal>
+                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
+            </goals>
+            <properties>
+                <exec.args>-Djava.library.path=/home/jmarsden/Source/Java/GLExamples.git/target/natives -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args>
+                <exec.executable>java</exec.executable>
+                <exec.classpathScope>${classPathScope}</exec.classpathScope>
+                <jpda.listen>true</jpda.listen>
+            </properties>
+        </action>
+        <action>
+            <actionName>profile.single.main</actionName>
+            <packagings>
+                <packaging>*</packaging>
+            </packagings>
+            <goals>
+                <goal>process-classes</goal>
+                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
+            </goals>
+            <properties>
+                <exec.args>-Djava.library.path=/home/jmarsden/Source/Java/GLExamples.git/target/natives -classpath %classpath ${packageClassName}</exec.args>
+                <exec.executable>java</exec.executable>
+                <exec.classpathScope>${classPathScope}</exec.classpathScope>
+            </properties>
+        </action>
+    </actions>

File src/main/java/cc/plural/dev/TestECSBasic.java

 import cc.plural.graphics.Vertex;
 import cc.plural.math.QuickMath;
 import cc.plural.math.Transformation;
-import cc.plural.newprovider.TestApplication;
-import cc.plural.newprovider.TestApplicationConfiguration;
+import cc.plural.test.provider.TestApplication;
+import cc.plural.test.provider.TestApplicationConfiguration;
 import cc.plural.utils.Color;
 import cc.plural.utils.MatrixPrinter;
 import cc.plural.utils.PNGDecoder;

File src/main/java/cc/plural/newprovider/TestApplication.java

-package cc.plural.newprovider;
-
-/**
- * Copyright (C) 2012 J.W.Marsden <jmarsden@plural.cc>
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-import cc.plural.ecs.runtime.ApplicationInterface;
-import org.lwjgl.Sys;
-
-public class TestApplication {
-
-    long lastFrame;
-    int fps;
-    long lastFPS;
-    boolean pauseFlag;
-    ApplicationInterface applicationInterface;
-    TestApplicationConfiguration applicationConfiguration;
-    TestRenderer renderer;
-
-    public TestApplication(ApplicationInterface applicationInterface, TestApplicationConfiguration applicationConfiguration) {
-        if (applicationInterface == null) {
-            throw new NullPointerException("applicationInterface cannot be null.");
-        }
-        if (applicationConfiguration == null) {
-            throw new NullPointerException("applicationConfiguration cannot be null.");
-        }
-        this.applicationInterface = applicationInterface;
-        this.applicationConfiguration = applicationConfiguration;
-        pauseFlag = false;
-    }
-
-    public void start() {
-        int width = applicationConfiguration.width;
-        int height = applicationConfiguration.height;
-        TestDisplay display = new TestDisplay();
-        display.setTitle(applicationConfiguration.title);
-        display.setResizable(applicationConfiguration.resizable);
-        display.init(width, height);
-
-        renderer = (TestRenderer) display.createRenderer(applicationConfiguration);
-        renderer.backgroundColor = applicationConfiguration.backGroundColor;
-        renderer.init();
-
-        applicationInterface.reSizeCallback(width, height);
-        applicationInterface.init(renderer);
-        applicationInterface.start();
-
-        getDelta();
-        lastFPS = getTime();
-
-        while (!renderer.display.isCloseRequested()) {
-            float delta = getDelta();
-
-            applicationInterface.update(delta);
-
-            if (!renderer.display.isActive()) {
-                if (!pauseFlag) {
-                    applicationInterface.pause();
-                    pauseFlag = true;
-                }
-            } else {
-                if (pauseFlag) {
-                    applicationInterface.resume();
-                    pauseFlag = false;
-                }
-
-                int newWidth = renderer.display.getWidth();
-                int newHeight = renderer.display.getHeight();
-                if (width != newWidth || height != newHeight) {
-                    width = newWidth;
-                    height = newHeight;
-                    this.renderer.display.reSize(width, height);
-                    applicationInterface.reSizeCallback(width, height);
-                }
-                applicationInterface.render(renderer);
-            }
-            renderer.display.update();
-            renderer.display.sync(renderer.frameRate);
-
-            updateFPS();
-        }
-
-        applicationInterface.exit();
-        renderer.display.destroy();
-    }
-
-    /**
-     * Calculate how many milliseconds have passed since last frame.
-     *
-     * @return milliseconds passed since last frame
-     */
-    public float getDelta() {
-
-        long time = getTime();
-        float delta = (float) (time - lastFrame);
-        lastFrame = time;
-        return delta;
-    }
-
-    /**
-     * Get the accurate system time
-     *
-     * @return The system time in milliseconds
-     */
-    public long getTime() {
-        return (Sys.getTime() * 1000) / Sys.getTimerResolution();
-    }
-
-    public void updateFPS() {
-        if (getTime() - lastFPS > 1000) {
-            applicationInterface.fpsUpdateCallback(fps);
-            fps = 0;
-            lastFPS += 1000;
-        }
-        fps++;
-    }
-}

File src/main/java/cc/plural/newprovider/TestApplicationConfiguration.java

-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package cc.plural.newprovider;
-
-import cc.plural.ecs.runtime.ApplicationConfiguration;
-
-/**
- *
- * @author John
- */
-public class TestApplicationConfiguration extends ApplicationConfiguration {
-    
-}

File src/main/java/cc/plural/newprovider/TestDisplay.java

-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package cc.plural.newprovider;
-
-import cc.plural.ecs.provider.LWJGLDisplay;
-import cc.plural.ecs.provider.LWJGLRendererGL15;
-import cc.plural.ecs.provider.LWJGLRendererGL2;
-import cc.plural.ecs.renderer.GLVersion;
-import cc.plural.ecs.renderer.Renderer;
-import cc.plural.ecs.runtime.ApplicationConfiguration;
-
-/**
- *
- * @author John
- */
-public class TestDisplay extends LWJGLDisplay {
-
-    @Override
-    public Renderer createRenderer(ApplicationConfiguration configuration) {
-        if (!displayCreated) {
-            throw new RuntimeException("Must init");
-        }
-        return new TestRenderer(this);
-    }
-    
-}

File src/main/java/cc/plural/newprovider/TestRenderer.java

-package cc.plural.newprovider;
-
-import cc.plural.ecs.engine.GameObject;
-import cc.plural.ecs.provider.LWJGLDisplay;
-import cc.plural.ecs.provider.LWJGLRenderer;
-import cc.plural.ecs.provider.StringLWJGLShader;
-import cc.plural.ecs.renderer.GLSLVersion;
-import static cc.plural.ecs.renderer.GLSLVersion.GLSL430;
-import cc.plural.ecs.renderer.Mesh;
-import cc.plural.ecs.renderer.Shader;
-import cc.plural.ecs.renderer.ShaderDefaults;
-import cc.plural.ecs.renderer.Texture;
-import org.lwjgl.opengl.GL11;
-import cc.plural.math.Matrix4f;
-import cc.plural.utils.MatrixPrinter;
-import org.lwjgl.opengl.Display;
-
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-/**
- *
- * @author John
- */
-public class TestRenderer extends LWJGLRenderer {
-
-    private int projectionMatrixLocation = 0;
-    private int viewMatrixLocation = 0;
-    private int modelMatrixLocation = 0;
-
-    public TestRenderer(LWJGLDisplay display) {
-        super(display);
-    }
-
-    @Override
-    public void init() {
-        GL11.glClearColor(backgroundColor.getRed() / 255F, backgroundColor.getGreen() / 255F, backgroundColor.getBlue() / 255F, 1.0f);
-
-        switch (getGLSLVersion()) {
-            case GLSL110:
-                throw new RuntimeException("Dont Support " + GLSLVersion.GLSL110);
-            case GLSL120:
-                throw new RuntimeException("Dont Support " + GLSLVersion.GLSL120);
-            case GLSL130:
-                if (defaultShader == null) {
-                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_130, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_130);
-                }
-                break;
-            case GLSL140:
-                if (defaultShader == null) {
-                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_140, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_140);
-                }
-                break;
-            case GLSL150:
-                if (defaultShader == null) {
-                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_150, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_150);
-                }
-                break;
-            case GLSL330:
-            case GLSL400:
-            case GLSL410:
-            case GLSL420:
-            case GLSL430:
-                if (defaultShader == null) {
-                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_150, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_150);
-                }
-                break;
-
-            default:
-                if (getGLSLVersion().getVersion() > GLSL430.getVersion()) {
-                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_150, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_150);
-                }
-
-                throw new RuntimeException("Dont Support " + getGLSLVersion());
-        }
-
-        if (!defaultShader.isInitialized()) {
-            defaultShader.init();
-        }
-        if (!defaultShader.isLoaded()) {
-            defaultShader.load();
-        }
-        if (defaultShader.inError()) {
-            throw new RuntimeException("Default Shader No Compile: " + defaultShader.getVertexCompileError() + " " + defaultShader.getFragmentCompileError() + " " + defaultShader.getLinkError());
-        }
-    }
-
-    public StringLWJGLShader createShader(String vertexSource, String fragmentSource) {
-        return new StringLWJGLShader(vertexSource, fragmentSource);
-    }
-
-    public void releaseShader(Shader shader) {
-        shader.release();
-    }
-
-    public StringLWJGLShader createDefaultShader(String vertexSource, String fragmentSource) {
-        if (defaultShader != null) {
-            defaultShader.release();
-        }
-        defaultShader = createShader(vertexSource, fragmentSource);
-        return defaultShader;
-    }
-
-    public StringLWJGLShader getDefaultShader() {
-        return defaultShader;
-    }
-
-    public void completeRender() {
-
-        if (!defaultShader.isLoaded()) {
-            defaultShader.load();
-        }
-
-        if (skipRender) {
-            batch.clear();
-            lock = false;
-            return;
-        }
-
-        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
-
-        Matrix4f ecsProjectionMatrix = new Matrix4f();
-        Matrix4f ecsViewMatrix = new Matrix4f();
-        Matrix4f ecsModelMatrix = Matrix4f.identity();
-
-        projection.load(ecsProjectionMatrix);
-
-        camera.get(ecsViewMatrix);
-
-        for (GameObject go : batch.queue) {
-
-            Shader shader = getDefaultShader();
-            Texture texture = go.geometry.texture;
-            Mesh mesh = go.geometry.mesh;
-
-            System.out.println("Shader:" + shader.getState());
-            System.out.println("Texture:" + texture.toString());
-            System.out.println("Mesh:" + mesh.dumpState());
-
-            ecsModelMatrix.setData(0, 3, 0.1);
-            ecsModelMatrix.setData(1, 3, 0.1);
-
-            texture.enable();
-
-            //shader.enable();
-
-            System.out.println("ECS Othogonal Projection Matrix: \n" + MatrixPrinter.matrix2String(ecsProjectionMatrix));
-            System.out.println("ECS View Matrix: \n" + MatrixPrinter.matrix2String(ecsViewMatrix));
-            System.out.println("ECS Model Matrix: \n" + MatrixPrinter.matrix2String(ecsModelMatrix));
-
-            shader.setUniform(projectionMatrixLocation, ecsProjectionMatrix);
-            shader.setUniform(viewMatrixLocation, ecsViewMatrix);
-            shader.setUniform(modelMatrixLocation, ecsModelMatrix);
-
-            mesh.enable();
-            GL11.glDrawElements(GL11.GL_TRIANGLES, mesh.getIndicesCount(), GL11.GL_UNSIGNED_SHORT, 0);
-            mesh.disable();
-
-            //shader.disable();
-
-            texture.disable();
-        }
-
-        batch.clear();
-        lock = false;
-
-        Display.sync(frameRate);
-        Display.update();
-
-    }
-}

File src/main/java/cc/plural/renderer20/Test20Renderer.java

-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package cc.plural.renderer20;
-
-import cc.plural.dev.TestECSBasic;
-import cc.plural.ecs.engine.Engine;
-import cc.plural.ecs.engine.GameObject;
-import cc.plural.ecs.provider.LWJGLApplication;
-import cc.plural.ecs.provider.LWJGLApplicationConfiguration;
-import cc.plural.ecs.renderer.GLVersion;
-import cc.plural.ecs.renderer.Platform;
-import cc.plural.ecs.renderer.Renderer;
-import cc.plural.ecs.runtime.ApplicationInterface;
-import cc.plural.graphics.Vertex;
-import cc.plural.utils.Color;
-import cc.plural.utils.PNGDecoder;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.util.logging.Level;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.lwjgl.opengl.Display;
-
-/**
- *
- * @author John
- */
-public class Test20Renderer implements ApplicationInterface {
-
-    public static final String TITLE = "GL2.0 Renderer Tester";
-    int width;
-    int height;
-    int fps;
-    boolean paused;
-    Engine engine;
-    Logger logger;
-
-    public static void main(String[] args) {
-        Test20Renderer renderer = new Test20Renderer();
-        LWJGLApplicationConfiguration applicationConfiguration = new LWJGLApplicationConfiguration();
-        applicationConfiguration.title = TITLE;
-        applicationConfiguration.width = 350;
-        applicationConfiguration.height = 350;
-        applicationConfiguration.resizable = true;
-        applicationConfiguration.backGroundColor = Color.SLATE_GRAY;
-        applicationConfiguration.forceGLVersion = GLVersion.GL20;
-
-        LWJGLApplication application = new LWJGLApplication(renderer, applicationConfiguration);
-        application.start();
-    }
-
-    private static ByteBuffer loadIcon(URL url) throws IOException {
-        InputStream inputStream = url.openStream();
-        try {
-            PNGDecoder decoder = new PNGDecoder(inputStream);
-            ByteBuffer bytebuf = ByteBuffer.allocateDirect(decoder.getWidth() * decoder.getHeight() * 4);
-            decoder.decode(bytebuf, decoder.getWidth() * 4, PNGDecoder.Format.RGBA);
-            bytebuf.flip();
-            return bytebuf;
-        } finally {
-            inputStream.close();
-        }
-    }
-
-    public void setIcon(Renderer renderer) {
-        URL icon16 = Object.class.getResource("/icon/icon16.png");
-        URL icon32 = Object.class.getResource("/icon/icon32.png");
-        URL icon128 = Object.class.getResource("/icon/icon128.png");
-        ByteBuffer[] icons = null;
-
-        try {
-            switch (renderer.getPlatform().platform) {
-                case Platform.LINUX:
-                    icons = new ByteBuffer[]{loadIcon(icon32)};
-                    break;
-                case Platform.OSX:
-                    icons = new ByteBuffer[]{loadIcon(icon128)};
-                    break;
-                case Platform.WINDOWS:
-                    icons = new ByteBuffer[]{loadIcon(icon16), loadIcon(icon32)};
-                    break;
-            }
-        } catch (IOException ex) {
-            java.util.logging.Logger.getLogger(TestECSBasic.class.getName()).log(Level.SEVERE, null, ex);
-        }
-        if (icons != null) {
-            Display.setIcon(icons);
-        }
-    }
-
-    public void init(Renderer renderer) {
-        setIcon(renderer);
-        renderer.setFrameRate(60);
-        logger = LogManager.getLogger(TestECSBasic.class);
-        if (logger.isInfoEnabled()) {
-            logger.info("init()");
-        }
-        String rendererDump = renderer.toString();
-        if (logger.isInfoEnabled()) {
-            logger.info(rendererDump);
-        }
-
-        float left = 0;
-        float right = 4;
-        float top = 4;
-        float bottom = 0;
-        float near = 0;
-        float far = 1;
-        renderer.setOrthoProjection(left, right, top, bottom, near, far);
-
-        engine = new Engine();
-        GameObject testObject = engine.createGameObject("Test Game Object");
-
-        testObject.createGeometry();
-        testObject.geometry.texture = renderer.createTexture("/assets/images/grid2.png");
-        testObject.geometry.texture.init();
-        testObject.geometry.texture.load();
-
-        Vertex v0 = new Vertex();
-        v0.setXYZ(0f, 1f, 0);
-        v0.setRGB(1, 0, 0);
-        v0.setST(0, 0);
-        v0.setN(0, 0, 1);
-        Vertex v1 = new Vertex();
-        v1.setXYZ(0f, 0f, 0);
-        v1.setRGB(0, 1, 0);
-        v1.setST(0, 1);
-        v1.setN(0, 0, 1);
-        Vertex v2 = new Vertex();
-        v2.setXYZ(1f, 0f, 0);
-        v2.setRGB(0, 0, 1);
-        v2.setST(1, 1);
-        v2.setN(0, 0, 1);
-        Vertex v3 = new Vertex();
-        v3.setXYZ(1f, 1f, 0);
-        v3.setRGB(1, 1, 1);
-        v3.setST(1, 0);
-        v3.setN(0, 0, 1);
-
-        testObject.geometry.mesh = renderer.createStaticMesh(new Vertex[]{v0, v1, v2, v3}, new short[]{0, 1, 2, 2, 3, 0});
-        testObject.geometry.mesh.init();
-        testObject.geometry.mesh.load();
-
-        testObject.createSpatial();
-        testObject.spatial.setTranslation(2, 1);
-
-        engine.dumpState();
-    }
-
-    public void start() {
-        engine.start();
-    }
-
-    public void update(float delta) {
-        if (!paused) {
-            engine.update(delta);
-        }
-    }
-
-    public void render(Renderer renderer) {
-        engine.render(renderer);
-    }
-
-    public void pause() {
-        paused = true;
-    }
-
-    public void resume() {
-        paused = false;
-    }
-
-    public void exit() {
-    }
-
-    public void reSizeCallback(int width, int height) {
-        this.height = height;
-        this.width = width;
-    }
-
-    public void fpsUpdateCallback(int fps) {
-        if (this.fps != fps) {
-            Display.setTitle(TITLE + " (" + fps + " fps)");
-            this.fps = fps;
-        }
-    }
-}

File src/main/java/cc/plural/test/ecs/TestECSRuntimeApplication.java

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package cc.plural.test.ecs;
+
+import cc.plural.dev.TestECSBasic;
+import cc.plural.ecs.engine.Engine;
+import cc.plural.ecs.engine.GameObject;
+import cc.plural.ecs.renderer.GLVersion;
+import cc.plural.ecs.renderer.Platform;
+import cc.plural.ecs.renderer.Renderer;
+import cc.plural.ecs.runtime.ApplicationInterface;
+import cc.plural.graphics.Vertex;
+import cc.plural.test.provider.TestApplication;
+import cc.plural.test.provider.TestApplicationConfiguration;
+import cc.plural.utils.Color;
+import cc.plural.utils.PNGDecoder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.util.logging.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.lwjgl.opengl.Display;
+
+/**
+ *
+ * @author John
+ */
+public class TestECSRuntimeApplication implements ApplicationInterface {
+
+    public static final String TITLE = "GL2.0 Renderer Tester";
+    int width;
+    int height;
+    int fps;
+    boolean paused;
+    Engine engine;
+    Logger logger;
+
+    public static void main(String[] args) {
+        TestECSRuntimeApplication ecsApplication = new TestECSRuntimeApplication();
+        TestApplicationConfiguration applicationConfiguration = new TestApplicationConfiguration();
+        applicationConfiguration.title = TITLE;
+        applicationConfiguration.width = 350;
+        applicationConfiguration.height = 350;
+        applicationConfiguration.resizable = true;
+        applicationConfiguration.backGroundColor = Color.SLATE_GRAY;
+        applicationConfiguration.forceGLVersion = GLVersion.GL20;
+
+        TestApplication application = new TestApplication(ecsApplication, applicationConfiguration);
+        application.start();
+    }
+
+    private static ByteBuffer loadIcon(URL url) throws IOException {
+        InputStream inputStream = url.openStream();
+        try {
+            PNGDecoder decoder = new PNGDecoder(inputStream);
+            ByteBuffer bytebuf = ByteBuffer.allocateDirect(decoder.getWidth() * decoder.getHeight() * 4);
+            decoder.decode(bytebuf, decoder.getWidth() * 4, PNGDecoder.Format.RGBA);
+            bytebuf.flip();
+            return bytebuf;
+        } finally {
+            inputStream.close();
+        }
+    }
+
+    public void setIcon(Renderer renderer) {
+        URL icon16 = Object.class.getResource("/icon/icon16.png");
+        URL icon32 = Object.class.getResource("/icon/icon32.png");
+        URL icon128 = Object.class.getResource("/icon/icon128.png");
+        ByteBuffer[] icons = null;
+
+        try {
+            switch (renderer.getPlatform().platform) {
+                case Platform.LINUX:
+                    icons = new ByteBuffer[]{loadIcon(icon32)};
+                    break;
+                case Platform.OSX:
+                    icons = new ByteBuffer[]{loadIcon(icon128)};
+                    break;
+                case Platform.WINDOWS:
+                    icons = new ByteBuffer[]{loadIcon(icon16), loadIcon(icon32)};
+                    break;
+            }
+        } catch (IOException ex) {
+            java.util.logging.Logger.getLogger(TestECSBasic.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        if (icons != null) {
+            Display.setIcon(icons);
+        }
+    }
+
+    public void init(Renderer renderer) {
+        setIcon(renderer);
+        renderer.setFrameRate(60);
+        logger = LogManager.getLogger(TestECSBasic.class);
+        if (logger.isInfoEnabled()) {
+            logger.info("init()");
+        }
+        String rendererDump = renderer.toString();
+        if (logger.isInfoEnabled()) {
+            logger.info(rendererDump);
+        }
+
+        float left = 0;
+        float right = 4;
+        float top = 4;
+        float bottom = 0;
+        float near = 0;
+        float far = 1;
+        renderer.setOrthoProjection(left, right, top, bottom, near, far);
+
+        engine = new Engine();
+        GameObject testObject = engine.createGameObject("Test Game Object");
+
+        testObject.createGeometry();
+        testObject.geometry.texture = renderer.createTexture("/assets/images/grid2.png");
+        testObject.geometry.texture.init();
+        testObject.geometry.texture.load();
+
+        Vertex v0 = new Vertex();
+        v0.setXYZ(0f, 1f, 0);
+        v0.setRGB(1, 0, 0);
+        v0.setST(0, 0);
+        v0.setN(0, 0, 1);
+        Vertex v1 = new Vertex();
+        v1.setXYZ(0f, 0f, 0);
+        v1.setRGB(0, 1, 0);
+        v1.setST(0, 1);
+        v1.setN(0, 0, 1);
+        Vertex v2 = new Vertex();
+        v2.setXYZ(1f, 0f, 0);
+        v2.setRGB(0, 0, 1);
+        v2.setST(1, 1);
+        v2.setN(0, 0, 1);
+        Vertex v3 = new Vertex();
+        v3.setXYZ(1f, 1f, 0);
+        v3.setRGB(1, 1, 1);
+        v3.setST(1, 0);
+        v3.setN(0, 0, 1);
+
+        testObject.geometry.mesh = renderer.createStaticMesh(new Vertex[]{v0, v1, v2, v3}, new short[]{0, 1, 2, 2, 3, 0});
+        testObject.geometry.mesh.init();
+        testObject.geometry.mesh.load();
+
+        testObject.createSpatial();
+        testObject.spatial.setTranslation(2, 1);
+
+        engine.dumpState();
+    }
+
+    public void start() {
+        engine.start();
+    }
+
+    public void update(float delta) {
+        if (!paused) {
+            engine.update(delta);
+        }
+    }
+
+    public void render(Renderer renderer) {
+        engine.render(renderer);
+    }
+
+    public void pause() {
+        paused = true;
+    }
+
+    public void resume() {
+        paused = false;
+    }
+
+    public void exit() {
+    }
+
+    public void reSizeCallback(int width, int height) {
+        this.height = height;
+        this.width = width;
+    }
+
+    public void fpsUpdateCallback(int fps) {
+        if (this.fps != fps) {
+            Display.setTitle(TITLE + " (" + fps + " fps)");
+            this.fps = fps;
+        }
+    }
+}

File src/main/java/cc/plural/test/provider/TestApplication.java

+package cc.plural.test.provider;
+
+/**
+ * Copyright (C) 2012 J.W.Marsden <jmarsden@plural.cc>
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import cc.plural.ecs.runtime.ApplicationInterface;
+import org.lwjgl.Sys;
+
+public class TestApplication {
+
+    long lastFrame;
+    int fps;
+    long lastFPS;
+    boolean pauseFlag;
+    ApplicationInterface applicationInterface;
+    TestApplicationConfiguration applicationConfiguration;
+    TestRenderer renderer;
+
+    public TestApplication(ApplicationInterface applicationInterface, TestApplicationConfiguration applicationConfiguration) {
+        if (applicationInterface == null) {
+            throw new NullPointerException("applicationInterface cannot be null.");
+        }
+        if (applicationConfiguration == null) {
+            throw new NullPointerException("applicationConfiguration cannot be null.");
+        }
+        this.applicationInterface = applicationInterface;
+        this.applicationConfiguration = applicationConfiguration;
+        pauseFlag = false;
+    }
+
+    public void start() {
+        int width = applicationConfiguration.width;
+        int height = applicationConfiguration.height;
+        TestDisplay display = new TestDisplay();
+        display.setTitle(applicationConfiguration.title);
+        display.setResizable(applicationConfiguration.resizable);
+        display.init(width, height);
+
+        renderer = (TestRenderer) display.createRenderer(applicationConfiguration);
+        renderer.backgroundColor = applicationConfiguration.backGroundColor;
+        renderer.init();
+
+        applicationInterface.reSizeCallback(width, height);
+        applicationInterface.init(renderer);
+        applicationInterface.start();
+
+        getDelta();
+        lastFPS = getTime();
+
+        while (!renderer.display.isCloseRequested()) {
+            float delta = getDelta();
+
+            applicationInterface.update(delta);
+
+            if (!renderer.display.isActive()) {
+                if (!pauseFlag) {
+                    applicationInterface.pause();
+                    pauseFlag = true;
+                }
+            } else {
+                if (pauseFlag) {
+                    applicationInterface.resume();
+                    pauseFlag = false;
+                }
+
+                int newWidth = renderer.display.getWidth();
+                int newHeight = renderer.display.getHeight();
+                if (width != newWidth || height != newHeight) {
+                    width = newWidth;
+                    height = newHeight;
+                    this.renderer.display.reSize(width, height);
+                    applicationInterface.reSizeCallback(width, height);
+                }
+                applicationInterface.render(renderer);
+            }
+            renderer.display.update();
+            renderer.display.sync(renderer.frameRate);
+
+            updateFPS();
+        }
+
+        applicationInterface.exit();
+        renderer.display.destroy();
+    }
+
+    /**
+     * Calculate how many milliseconds have passed since last frame.
+     *
+     * @return milliseconds passed since last frame
+     */
+    public float getDelta() {
+
+        long time = getTime();
+        float delta = (float) (time - lastFrame);
+        lastFrame = time;
+        return delta;
+    }
+
+    /**
+     * Get the accurate system time
+     *
+     * @return The system time in milliseconds
+     */
+    public long getTime() {
+        return (Sys.getTime() * 1000) / Sys.getTimerResolution();
+    }
+
+    public void updateFPS() {
+        if (getTime() - lastFPS > 1000) {
+            applicationInterface.fpsUpdateCallback(fps);
+            fps = 0;
+            lastFPS += 1000;
+        }
+        fps++;
+    }
+}

File src/main/java/cc/plural/test/provider/TestApplicationConfiguration.java

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package cc.plural.test.provider;
+
+import cc.plural.ecs.runtime.ApplicationConfiguration;
+
+/**
+ *
+ * @author John
+ */
+public class TestApplicationConfiguration extends ApplicationConfiguration {
+    
+}

File src/main/java/cc/plural/test/provider/TestDisplay.java

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package cc.plural.test.provider;
+
+import cc.plural.ecs.provider.LWJGLDisplay;
+import cc.plural.ecs.provider.LWJGLRendererGL15;
+import cc.plural.ecs.provider.LWJGLRendererGL2;
+import cc.plural.ecs.renderer.GLVersion;
+import cc.plural.ecs.renderer.Renderer;
+import cc.plural.ecs.runtime.ApplicationConfiguration;
+
+/**
+ *
+ * @author John
+ */
+public class TestDisplay extends LWJGLDisplay {
+
+    @Override
+    public Renderer createRenderer(ApplicationConfiguration configuration) {
+        if (!displayCreated) {
+            throw new RuntimeException("Must init");
+        }
+        return new TestRenderer(this);
+    }
+    
+}

File src/main/java/cc/plural/test/provider/TestRenderer.java

+package cc.plural.test.provider;
+
+import cc.plural.ecs.engine.GameObject;
+import cc.plural.ecs.provider.LWJGLDisplay;
+import cc.plural.ecs.provider.LWJGLRenderer;
+import cc.plural.ecs.provider.StringLWJGLShader;
+import cc.plural.ecs.renderer.GLSLVersion;
+import static cc.plural.ecs.renderer.GLSLVersion.GLSL430;
+import cc.plural.ecs.renderer.Mesh;
+import cc.plural.ecs.renderer.Shader;
+import cc.plural.ecs.renderer.ShaderDefaults;
+import cc.plural.ecs.renderer.Texture;
+import org.lwjgl.opengl.GL11;
+import cc.plural.math.Matrix4f;
+import cc.plural.utils.MatrixPrinter;
+import org.lwjgl.opengl.Display;
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+/**
+ *
+ * @author John
+ */
+public class TestRenderer extends LWJGLRenderer {
+
+    private int projectionMatrixLocation = 0;
+    private int viewMatrixLocation = 0;
+    private int modelMatrixLocation = 0;
+
+    public TestRenderer(LWJGLDisplay display) {
+        super(display);
+    }
+
+    @Override
+    public void init() {
+        GL11.glClearColor(backgroundColor.getRed() / 255F, backgroundColor.getGreen() / 255F, backgroundColor.getBlue() / 255F, 1.0f);
+
+        switch (getGLSLVersion()) {
+            case GLSL110:
+                throw new RuntimeException("Dont Support " + GLSLVersion.GLSL110);
+            case GLSL120:
+                throw new RuntimeException("Dont Support " + GLSLVersion.GLSL120);
+            case GLSL130:
+                if (defaultShader == null) {
+                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_130, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_130);
+                }
+                break;
+            case GLSL140:
+                if (defaultShader == null) {
+                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_140, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_140);
+                }
+                break;
+            case GLSL150:
+                if (defaultShader == null) {
+                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_150, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_150);
+                }
+                break;
+            case GLSL330:
+            case GLSL400:
+            case GLSL410:
+            case GLSL420:
+            case GLSL430:
+                if (defaultShader == null) {
+                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_150, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_150);
+                }
+                break;
+
+            default:
+                if (getGLSLVersion().getVersion() > GLSL430.getVersion()) {
+                    createDefaultShader(ShaderDefaults.DEFAULT_VERTEX_SHADER_150, ShaderDefaults.DEFAULT_FRAGMENT_SHADER_150);
+                }
+
+                throw new RuntimeException("Dont Support " + getGLSLVersion());
+        }
+
+        if (!defaultShader.isInitialized()) {
+            defaultShader.init();
+        }
+        if (!defaultShader.isLoaded()) {
+            defaultShader.load();
+        }
+        if (defaultShader.inError()) {
+            throw new RuntimeException("Default Shader No Compile: " + defaultShader.getVertexCompileError() + " " + defaultShader.getFragmentCompileError() + " " + defaultShader.getLinkError());
+        }
+    }
+
+    public StringLWJGLShader createShader(String vertexSource, String fragmentSource) {
+        return new StringLWJGLShader(vertexSource, fragmentSource);
+    }
+
+    public void releaseShader(Shader shader) {
+        shader.release();
+    }
+
+    public StringLWJGLShader createDefaultShader(String vertexSource, String fragmentSource) {
+        if (defaultShader != null) {
+            defaultShader.release();
+        }
+        defaultShader = createShader(vertexSource, fragmentSource);
+        return defaultShader;
+    }
+
+    public StringLWJGLShader getDefaultShader() {
+        return defaultShader;
+    }
+
+    public void completeRender() {
+
+        if (!defaultShader.isLoaded()) {
+            defaultShader.load();
+        }
+
+        if (skipRender) {
+            batch.clear();
+            lock = false;
+            return;
+        }
+
+        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
+
+        Matrix4f ecsProjectionMatrix = new Matrix4f();
+        Matrix4f ecsViewMatrix = new Matrix4f();
+        Matrix4f ecsModelMatrix = Matrix4f.identity();
+
+        projection.load(ecsProjectionMatrix);
+
+        camera.get(ecsViewMatrix);
+
+        for (GameObject go : batch.queue) {
+
+            Shader shader = getDefaultShader();
+            Texture texture = go.geometry.texture;
+            Mesh mesh = go.geometry.mesh;
+
+            System.out.println("Shader:" + shader.getState());
+            System.out.println("Texture:" + texture.toString());
+            System.out.println("Mesh:" + mesh.dumpState());
+
+            ecsModelMatrix.setData(0, 3, 0.1);
+            ecsModelMatrix.setData(1, 3, 0.1);
+
+            texture.enable();
+
+            //shader.enable();
+
+            System.out.println("ECS Othogonal Projection Matrix: \n" + MatrixPrinter.matrix2String(ecsProjectionMatrix));
+            System.out.println("ECS View Matrix: \n" + MatrixPrinter.matrix2String(ecsViewMatrix));
+            System.out.println("ECS Model Matrix: \n" + MatrixPrinter.matrix2String(ecsModelMatrix));
+
+            shader.setUniform(projectionMatrixLocation, ecsProjectionMatrix);
+            shader.setUniform(viewMatrixLocation, ecsViewMatrix);
+            shader.setUniform(modelMatrixLocation, ecsModelMatrix);
+
+            mesh.enable();
+            GL11.glDrawElements(GL11.GL_TRIANGLES, mesh.getIndicesCount(), GL11.GL_UNSIGNED_SHORT, 0);
+            mesh.disable();
+
+            //shader.disable();
+
+            texture.disable();
+        }
+
+        batch.clear();
+        lock = false;
+
+        Display.sync(frameRate);
+        Display.update();
+
+    }
+}