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> java.lang.NullPointerException
        at org.lwjgl.opengl.GL11.glViewport(
        at com.badlogic.gdx.backends.lwjgl.LwjglGL10.glViewport(
        at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setDisplayMode(
        at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$

I guess the "culprit" is the Display.destroy on, 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?
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.
Site Admin
Posts: 4875
Joined: Sat Jul 10, 2010 3:50 pm

Return to Libgdx

Who is online

Users browsing this forum: No registered users and 14 guests