Swinggui setup(Unknown Source) NPE

This is beginning to make me cry :frowning: I can't for the life of me get it to work. I copy and pasted TestJMEDesktop into a new class and it seems to work, but why not in this one? This isn't the standard class i'd use, but since it wasn't working, i thought I'd go down to the basics to see if i knew what i was doing first of all… apparently not. I can't figure out what the heck is going on. please!!!


import com.jmex.game.StandardGame;
import com.jmex.game.state.GameStateManager;
import com.jmex.editors.swing.settings.GameSettingsPanel;
import com.jmex.game.state.GameStateNode;

import com.jme.system.DisplaySystem;

import com.jme.input.MouseInput;
import com.jme.input.KeyboardLookHandler;

import com.jmex.awt.swingui.JMEDesktop;
import com.jme.input.InputHandler;
import java.util.logging.Level;
import com.jme.renderer.Camera;
import java.util.logging.Logger;
/**
 *
 * @author Paul Warren
 */
public class tmpMaelori {
    protected gsTest gsTest;
   
    private static int CLIENT = 0;
    private static int SERVER = 1;
   
    /** Creates a new instance of tmpMaelori */
    public tmpMaelori() {
    }

    public static void main(String[] args) {
        tmpMaelori app = new tmpMaelori();
        app.theGame(CLIENT); // Start the program
    }
   
    public void theGame (int gametype) {
        StandardGame app;
        if (gametype == CLIENT) {
            app = new StandardGame("Maelori"); // Create Object
            Logger.getLogger(tmpMaelori.class.getName()).setLevel(Level.OFF);
            try {
                if (GameSettingsPanel.prompt(app.getSettings())) {
                    app.start(); // Start the program
                }
            } catch( Exception e) {
                e.printStackTrace();
                System.exit(0);
            }
        }
       
       
       
        // Structure of the nodes is stored in the gsMain class.
        gsTest     = new gsTest("gsTest");
        GameStateManager.getInstance().attachChild(gsTest);
        gsTest.setActive(true);
       
        /*
        tmpCodeTester tmpGS = new tmpCodeTester("tmp Tester", gsTest);
        GameStateManager.getInstance().attachChild(tmpGS);
        tmpGS.setActive(true);
        */
    }
   
   
    public class gsTest extends GameStateNode {
        //private JMEDesktop jmeDesktop;
        private InputHandler input;
        protected DisplaySystem disp;
        public gsTest(String name) {
            super(name);
           
           
            this.init();
        }
       
        public void init() {
            disp = DisplaySystem.getDisplaySystem();
            MouseInput.get().setCursorVisible( true );
           
            input = new InputHandler();
            Camera cam = DisplaySystem.getDisplaySystem().getRenderer().getCamera();
            KeyboardLookHandler lookHandler = new KeyboardLookHandler( cam, 50, 1 );
            // and nest it
            input.addToAttachedHandlers( lookHandler );
           
            final JMEDesktop desktop = new JMEDesktop( "desktop" );
            try {
                desktop.setup(800, 600, false, input );
            } catch(Exception e) {
                e.printStackTrace();
            }
//            final JMEDesktop desktop = new JMEDesktop( "desktop", 800, 600, input );
           
        }
    }
}




on the final line: desktop.setup( ...
I get this:

java.lang.NullPointerException
        at org.lwjgl.opengl.GL11.glHint(GL11.java:1510)
        at com.jme.scene.state.lwjgl.LWJGLTextureState.apply(Unknown Source)
        at com.jmex.awt.swingui.JMEDesktop.setup(Unknown Source)
        at pkgClient.tmpMaelori$gsTest.init(tmpMaelori.java:116)
        at pkgClient.tmpMaelori$gsTest.<init>(tmpMaelori.java:101)
        at pkgClient.tmpMaelori.theGame(tmpMaelori.java:81)
        at pkgClient.tmpMaelori.main(tmpMaelori.java:60)

you are creating the jME-Desktop outside of the openGL thread.



After you call start():

  in standard game a new thread is spawned that handles the rendering, the method returns after that but is in the original thread not the openGL one.

  in one of the classes based of baseGame (standardGame, simpleGame), the thread that calls start() is the thread that handles the rendering, therefore it will only return after the rendering loop has ended (when the program is shutting down…)



in either case to queue something up in the rendering thread use this:

        GameTaskQueueManager.getManager().update( new Callable<Object>() {

            public Object call() throws Exception {

                // Insert Code here...

                return null;
            }
        } );