Setting new AppSettings on the fly causes crash

Hello,



I’ve been using bit old nighlty (july or august, I’m not sure) and almost everything was working fine, there was only some flickering when using alpha treshold on transparent textures. So I updated to the latest nighlies and the flickering is gone, great. But I can’t change settings on the fly anymore.



Well I can, it works unless I try to change multisampling value. Then I get null pointer exception in lwjgl. I did not want to post my code here, so I took the basic blue cube example.



[java]public class JMETest extends SimpleApplication {



public static void main(String[] args){

JMETest app = new JMETest();

app.start(); // start the game

}



@Override

public void simpleInitApp() {

Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin

Geometry geom = new Geometry(“Box”, b); // create cube geometry from the shape

Material mat = new Material(assetManager,

“Common/MatDefs/Misc/Unshaded.j3md”); // create a simple material

mat.setColor(“Color”, ColorRGBA.Blue); // set color of material to blue

geom.setMaterial(mat); // set the cube’s material

rootNode.attachChild(geom); // make the cube appear in the scene

AppSettings newSettings = new AppSettings(true);

newSettings.setRenderer(AppSettings.LWJGL_OPENGL2);

newSettings.setResolution(1024, 768);

newSettings.setBitsPerPixel(32);

newSettings.setFullscreen(false);

newSettings.setFrameRate(100);

newSettings.setVSync(true);

newSettings.setSamples(4);

setSettings(newSettings);

restart();

}

}[/java]



After running this I get:



SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at org.lwjgl.opengl.GL11.glGetInteger(GL11.java:1363)

at com.jme3.renderer.lwjgl.LwjglRenderer.invalidateState(LwjglRenderer.java:396)

at com.jme3.renderer.lwjgl.LwjglRenderer.resetGLObjects(LwjglRenderer.java:404)

at com.jme3.system.lwjgl.LwjglDisplay.createContext(LwjglDisplay.java:104)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:177)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)

at java.lang.Thread.run(Thread.java:722)





If I change it to newSettings.setSamples(1) everything is fine…

The issue is that that when you start the app, there are checks to determine which sample values are supported so that the display doesn’t crash on boot, the same does not happen when you restart the display which is why you have the crash.

I added an issue in the tracker for this:

http://code.google.com/p/jmonkeyengine/issues/detail?id=550

That’s not it, my GPU (GTX460) supports even 16 samples. I can start the app with 16 samples just fine, but once it’s running I can change the value to 1 only or this crash happens…


  • it worked with that older nightly build



    (fixed typo)

OK, I updated the issue to reflect this.

Thanks :slight_smile:

Should be fixed in SVN

It really works, thanks :slight_smile: