Game only runs once (Lwjgl versus exit versus JVM)

Anything libgdx related goes here!

Game only runs once (Lwjgl versus exit versus JVM)

Postby ibraim » Wed Jul 18, 2012 5:36 pm

Hello to all!
I'm using Libgdx with clojure and I simply cannot test my game in the REPL without fuss.
By default, a LwjglApplication calls System.exit, which kills the entire JVM. The solution is to pass a LwjglApplicationConfiguration with forceExit as false. This works as expected (the JVM is still alive) but a new problem arises: now, I cannot (on the same JVM) run my game a second time (e.g.: new LwjglApplication( ....) fails). The stacktrace is:

Code: Select all
br.ibraim.mq.desktop.core=> java.lang.NullPointerException
        at org.lwjgl.opengl.GL11.glViewport(GL11.java:3207)
        at com.badlogic.gdx.backends.lwjgl.LwjglGL10.glViewport(LwjglGL10.java:480)
        at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setDisplayMode(LwjglGraphics.java:337)
        at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:154)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:143)
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:135)


I guess the "culprit" is the Display.destroy on LwjglApplication.java, line 220.
Now the question: how can I work around this issue? Having to restart the JVM every single time I need to test a change in my game is a big no-no for me.
Any ideas?
ibraim
 
Posts: 1
Joined: Wed Jul 18, 2012 5:24 pm

Re: Game only runs once (Lwjgl versus exit versus JVM)

Postby mzechner » Thu Jul 19, 2012 12:21 pm

That's more of a Lwjgl thing really. Lwjgl was not meant to be run multiple times in the same VM. From my experimentation it seems that it's also not cleaning up internal state very well.

One solution would be to use LwjglCanvas in a JFrame, not sure how disposing and recreating that JFrame/LwjglCanvas would behave though :/

Also, kudos for trying libgdx with Clojure, i'd be totally interested in how that works out for you.
mzechner
Site Admin
 
Posts: 4875
Joined: Sat Jul 10, 2010 3:50 pm


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 15 guests