package com.nucleus.jogl;

import com.nucleus.CoreApp;
import com.nucleus.CoreApp.CoreAppStarter;
import com.nucleus.matrix.j2se.J2SEMatrixEngine;
import com.nucleus.opengl.GLESWrapper.Renderers;
import com.nucleus.renderer.NucleusRenderer;
import com.nucleus.renderer.NucleusRenderer.RenderContextListener;
import com.nucleus.renderer.RendererFactory;
import com.nucleus.texturing.J2SEImageFactory;

/**
 * Base class for an application using {@link NucleusRenderer} through JOGL
 * The purpose of this class is to separate JOGL specific init and startup from shared code.
 * 
 * @author Richard Sahlin
 *
 */
public class NucleusApplication implements CoreAppStarter, RenderContextListener {

    protected JOGLGLES20Window window;
    protected CoreApp coreApp;
    protected int swapInterval = 1;
    protected int windowWidth = 480;
    protected int windowHeight = 800;

    @Override
    public void createCore(Renderers version) {
        window = new JOGLGLES20Window(windowWidth, windowHeight, this, swapInterval);
        window.setGLEVentListener();
        // Setting window to visible will trigger the GLEventListener, on the same or another thread.
        window.setVisible(true);
    }

    @Override
    public void contextCreated(int width, int height) {
        coreApp = new CoreApp(RendererFactory.getRenderer(window.getGLESWrapper(), new J2SEImageFactory(),
                new J2SEMatrixEngine()));
        coreApp.getRenderer().init();
        coreApp.contextCreated(window.getWidth(), window.getHeight());
        window.setCoreApp(coreApp);
    }

    /**
     * Returns the {@link NucleusRenderer} renderer - do NOT call this method before {@link #contextCreated(int, int)}
     * has been called by the renderer.
     * 
     * 
     * @return The renderer, or null if {@link #contextCreated(int, int)} has not been called by the renderer.
     */
    public NucleusRenderer getRenderer() {
        if (coreApp == null) {
            return null;
        }
        return coreApp.getRenderer();
    }

}

@@ -688,16 +688,151 @@
 ener %7B%0A%0A
+    public final static String WINDOW_WIDTH_KEY = %22WINDOW-WIDTH%22;%0A    public final static String WINDOW_HEIGHT_KEY = %22WINDOW-HEIGHT%22;%0A%0A
     prot
@@ -1005,16 +1005,720 @@
 = 800;%0A%0A
+    /**%0A     * Reads arguments from the VM and sets%0A     * %0A     * @param args%0A     */%0A    protected void setProperties(String%5B%5D args) %7B%0A        for (String str : args) %7B%0A%0A            if (str.toUpperCase().startsWith(WINDOW_WIDTH_KEY)) %7B%0A                windowWidth = Integer.parseInt(str.substring(WINDOW_WIDTH_KEY.length() + 1));%0A                System.out.println(WINDOW_WIDTH_KEY + %22 set to %22 + windowWidth);%0A            %7D%0A            if (str.toUpperCase().startsWith(WINDOW_HEIGHT_KEY)) %7B%0A                windowHeight = Integer.parseInt(str.substring(WINDOW_HEIGHT_KEY.length() + 1));%0A                System.out.println(WINDOW_HEIGHT_KEY + %22 set to %22 + windowHeight);%0A            %7D%0A        %7D%0A    %7D%0A%0A
     @Ove

Add support for setting window width and height from command line parameters