not!an!exit said:
Just to repeat my question from the already quoted thread: Why would you want to execute loadModel using the GameTastQueueManager, anyway? We do not alter any scenes here, right?
Loading models normally results in many many calls to the renderer like creating various RenderStates and such and loading Textures and much more.
http://www.jmonkeyengine.com/wiki/doku.php?id=what_calls_must_be_made_from_the_opengl_thread
EDIT: new patch:
Index: src/com/jmex/model/util/ModelLoader.java
===================================================================
--- src/com/jmex/model/util/ModelLoader.java (revision 5083)
+++ src/com/jmex/model/util/ModelLoader.java (working copy)
@@ -42,6 +42,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -102,7 +103,7 @@
File directory = new File(preferences.get("StartDirectory", "."));
chooser.setCurrentDirectory(directory);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
- File file = chooser.getSelectedFile();
+ final File file = chooser.getSelectedFile();
if (isValidModelFile(file)) {
// Set it in preferences so we remember next time
preferences.put("StartDirectory", file.getAbsolutePath());
@@ -116,13 +117,6 @@
}
game.start();
- GameTaskQueueManager.getManager().update(new Callable<Object>() {
- public Object call() throws Exception {
- //MouseInput.get().setCursorVisible(true);
- return null;
- }
- });
-
DebugGameState debug = new DebugGameState();
GameStateManager.getInstance().attachChild(debug);
debug.setActive(true);
@@ -138,7 +132,24 @@
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, locator);
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL, locator);
- final Node modelNode = loadModel(file);
+ Node modelNode = null;
+
+ try {
+ Future<Node> future = GameTaskQueueManager.getManager().update(new Callable<Node>() {
+
+ public Node call() throws Exception {
+ return loadModel(file);
+ }
+ });
+ modelNode = future.get();
+ } catch(InterruptedException ex) {
+ ex.printStackTrace();
+ System.exit(1);
+ } catch(ExecutionException ex) {
+ ex.printStackTrace();
+ System.exit(1);
+ } // catch
+
outputElapsed(time);
if (modelNode != null) {
modelNode.updateRenderState();
@@ -222,8 +233,7 @@
throw new UnsupportedOperationException( "Unknown file type: " + file );
}
callable.setFile( file );
- Future<Node> future = GameTaskQueueManager.getManager().update( callable );
- return future.get();
+ return callable.call();
}
private static String extensionOf( String file ) {