When I tried to execute some code in the opengl thread, and wait for it to finish in the way suggested in the wiki, I found it never returned… So I put together a small testcase:
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import com.jme.util.GameTaskQueueManager;
import com.jmex.editors.swing.settings.GameSettingsPanel;
import com.jmex.game.StandardGame;
public class TestTest {
public static void main(String[] args) throws Exception {
// Create a new StandardGame, which will run opengl from it's own thread
StandardGame game = new StandardGame("Gamey");
// Ask user for settings
GameSettingsPanel.prompt(game.getSettings());
// game.getSettings().setFullscreen(false);
game.start();
Future<Object> future = GameTaskQueueManager.getManager().update(
new Callable<Object>() {
public Object call() throws Exception {
System.out.println("returning");
return null;
}
});
System.out.println("waiting");
future.get();
System.out.println("resuming");
}
}
This should print "waiting", "returning" and "resuming" but it never gets to "resuming". A quick fix is to change "return null" to "return 1" or something, but this might not be very obvious. My guess is that most users would just go ":?"
Is this a bug in GameTaskQueueManager or just a slight mistake in the wiki?
Oh, and I seem to have misplaced my copy of FengStandardGame.java, could anyone send me a new copy? :D