This is beginning to make me cry 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)