Hi!
I want to display a GUI with and "Start Game" button. What am i trying?
I have a class that extends SimplePhysicsGame, defined like follows:
public class Jogo extends SimplePhysicsGame{
....
private boolean started = false;
private boolean paused = false;
protected void simpleUpdate(){
if (started){
if (KeyBindingManager.getKeyBindingManager().isValidCommand("pause", false))
paused = !paused;
if (paused)
return;
updateGame();
}else{
// draw the gui stuff after the scene
display.getRenderer().draw( guiNode );
}
}
protected void simpleInitGame() {
initializeInterface();
}
private void initializeInterface(){
// do some stuff here
button.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
// this gets executed in swing thread
// alter swing components ony in swing thread!
startGame();
}
} );
}
private void startGame(){
started = true;
// do some start game stuff
}
}
At the startGame method, i call a lot of methods that renders the game for the first time. Inside of one of that methods, i have the following line:
TextureManager.preloadCache(DisplaySystem.getDisplaySystem().getRenderer())
When that line executes i get a java.lang.NullPointerException at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1348).
And if i simple, run the startGame method without calling it by that button (through the GUI), i dont get that exception.
Any ideas?