Well, I have finally figured out what the problem is; I am posting my solution here…
The issue is that the Canvas cannot be removed from the JPanel (at any time it seems); otherwise when the canvas is re-added graphics (mainly textures) become garbled or disappear entirely, or even worse can cause the previous hard error. My solution is to never remove the canvas but rather to set it not visible ( Canvas.setVisible(false) ), however the layout must be re-adjusted if any JPanels are added at the layout position that the canvas is in. Otherwise the Canvas will not behave according to the layout position it has been set at.
Typical scenario of reseting a JPanel set at the center using BorderLayout:
The issue is that the Canvas cannot be removed from the JPanel (at any time it seems); otherwise when the canvas is re-added graphics (mainly textures) become garbled or disappear entirely, or even worse can cause the previous hard error.
I'm running against this problem as well. I'm not in control of if/when the canvas is removed and added again because I'm using the flexdock framework to manage window docking, and it seems when ever I close a window it re-organizes swing components which results in the canvas losing textures. So far, I'm not much a fan of the new canvas implementations.
Alright, did a little research over in the LWJGL cvs browser and extended LWJGLCanvas with a few modifications. The problem is, every time you add the canvas to a container the GL context gets initialized, and every time you remove the canvas the context gets destroyed. This doesn't work for me. I've changed it so the GL context only gets created once, and it doesn't get destroyed until you call cleanup() on the canvas. With this you can freely remove the canvas and add it back without losing anything, not even textures.
Here it is for those who want:
import org.lwjgl.LWJGLException;
import com.jmex.awt.lwjgl.LWJGLCanvas;
/**
* Custom LWJGL canvas implementation to allow full control of when the GL
* context is initialized and destroyed.
*
* @author Andrew Carter
*/
public class CustomLWJGLCanvas extends LWJGLCanvas {
/** */
private static final long serialVersionUID = 6392724324465695651L;