Related to my problem :
http://www.jmonkeyengine.com/jmeforum/index.php?topic=10391.0
solved by basixs’ suggestion and using his patch commited here :
http://www.jmonkeyengine.com/jmeforum/index.php?topic=9981.0
I create a path for Jme1.0, to fix the destroy context problem.
I hope any developpers have access to the old CVS to eventually commit it.
In Jme1.0, I don’t find any JoglCanvas or SwtCanvas so I just do a patch for JmeCanvas.java :
Index: src/com/jmex/awt/JMECanvas.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/awt/JMECanvas.java,v
retrieving revision 1.3
diff -u -r1.3 JMECanvas.java
--- src/com/jmex/awt/JMECanvas.java 13 Jan 2006 19:40:04 -0000 1.3
+++ src/com/jmex/awt/JMECanvas.java 12 Feb 2009 17:25:22 -0000
@@ -50,4 +50,23 @@
public void setBackground(Color bgColor);
public boolean doUpdateInput();
public void setUpdateInput(boolean doUpdate);
+
+ /**
+ * @param shouldAutoKillGfxContext
+ * true(default) if the GFX Context should be destroyed
+ * as soon as the canvas is removed from it's parent container
+ */
+ void setAutoKillGfxContext( boolean shouldAutoKillGfxContext );
+
+ /**
+ * @return
+ * true(default) if the GFX Context should be destroyed
+ * as soon as the canvas is removed from it's parent container
+ */
+ boolean shouldAutoKillGfxContext();
+
+ /**
+ * Destroy GFX context
+ */
+ void killGfxContext();
}
and LWJGLCanvas.java
Index: src/com/jmex/awt/lwjgl/LWJGLCanvas.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/awt/lwjgl/LWJGLCanvas.java,v
retrieving revision 1.8
diff -u -r1.8 LWJGLCanvas.java
--- src/com/jmex/awt/lwjgl/LWJGLCanvas.java 8 Jan 2008 22:54:12 -0000 1.8
+++ src/com/jmex/awt/lwjgl/LWJGLCanvas.java 12 Feb 2009 17:25:24 -0000
@@ -33,6 +33,7 @@
package com.jmex.awt.lwjgl;
import java.awt.Color;
+import java.awt.Dimension;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -66,6 +67,9 @@
private JMECanvasImplementor impl;
private static final String PAINT_LOCK = "INIT_LOCK";
+
+ private boolean shouldAutoKillContext = true;
+ private boolean glInitialized = false;
private boolean updateInput = false;
@@ -85,6 +89,33 @@
this.impl = impl;
}
+ @Override
+ protected void initGL() {
+ if( glInitialized ){
+ return;
+ }
+ glInitialized = true;
+
+ try {
+ LWJGLDisplaySystem display = (LWJGLDisplaySystem) DisplaySystem
+ .getDisplaySystem();
+ display.switchContext(this);
+
+ // Complete canvas configuration.
+ Dimension size = this.getSize();
+ display.initForCanvas(size.width, size.height);
+
+ impl.doSetup();
+
+ if (display.getMinSamples() != 0
+ && GLContext.getCapabilities().GL_ARB_multisample) {
+ GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);
+ }
+ } catch (Exception e) {
+ logger.log(Level.SEVERE, "Exception in initGL()", e);
+ }
+ }
+
public void paintGL() {
synchronized (PAINT_LOCK) {
try {
@@ -139,4 +170,25 @@
public void setUpdateInput(boolean doUpdate) {
updateInput = doUpdate;
}
+
+ @Override
+ public void removeNotify() {
+ if (shouldAutoKillContext) {
+ glInitialized = false;
+ super.removeNotify();
+ }
+ }
+
+ public void setAutoKillGfxContext( boolean shouldAutoKillGfxContext ) {
+ this.shouldAutoKillContext = shouldAutoKillGfxContext;
+ }
+
+ public boolean shouldAutoKillGfxContext() {
+ return shouldAutoKillContext;
+ }
+
+ public void killGfxContext() {
+ glInitialized = false;
+ super.removeNotify();
+ }
}
I hope you can do it, because it's impossible for me to migrate to Jme2.0 the moment. We have hundred of classes using jme and not enougth time to upgrate them.
Thanks