Hi all,
I've imported my ".obj" (the same problem with a ".jme" file) file in canvas.
When i call the screenshot with
It's because your action is being handled in a separate thread. Taking a screenshot needs to be done in the OpenGL thread. You can do this by Using Callable and the GameTaskQueueManager. Here's a sample helper class i wrote that you might use in place of ActionListener for things like this:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme.util.GameTaskQueue;
import com.jme.util.GameTaskQueueManager;
public abstract class ErrorCatchingGLActionListener implements ActionListener {
private static final Logger logger = Logger
.getLogger(ErrorCatchingGLActionListener.class.getName());
public final void actionPerformed(final ActionEvent e) {
Callable<?> exe = new Callable() {
public Object call() {
try {
doGLAction(e);
} catch (Exception ex) {
logger.log(Level.SEVERE,
"Swing Action Error Caught!", ex);
}
return null;
}
};
GameTaskQueueManager.getManager().getQueue(GameTaskQueue.RENDER).enqueue(exe);
}
/**
* Do the actual action.
*
* @param e
* the event param from actionPerformed.
*/
public abstract void doGLAction(ActionEvent e);
}
You can use it like this:
myButton.addActionListener(new ErrorCatchingGLActionListener() {
public void doGLAction(ActionEvent arg0) {
// do some thing in here that you expect to require the gl thread.
}
});
You can do similar things extending DocumentListener,ChangleListener, MouseListener, etc.
WOW…
Tks… it's work fine!!!