JMECanvas on hidden tab pane

Hi Guys,



I have different modles beign displ;ayed on diferent tabbed pans in Netbeans and in general its working great.



I do have one minor issue though that sometimes when I open a new tabbed pane I get this error:



INFO [com.jme.system.lwjgl.LWJGLDisplaySystem]: LWJGL Display System created.

SEVERE [com.jme.util.GameTask]: Exception

java.lang.NullPointerException

        at com.jme.renderer.lwjgl.LWJGLCamera.doFrameChange(Unknown Source)

        at com.jme.renderer.lwjgl.LWJGLCamera.apply(Unknown Source)

        at com.jme.renderer.lwjgl.LWJGLRenderer.reinit(Unknown Source)

[catch] at com.jmex.awt.JMECanvasImplementor$1.call(Unknown Source)

        at com.jme.util.GameTask.invoke(Unknown Source)

        at com.jme.util.GameTaskQueue.execute(Unknown Source)

        at com.jmex.awt.lwjgl.LWJGLCanvas.paintGL(Unknown Source)

        at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:308)

        at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

        at sun.awt.RepaintArea.paint(RepaintArea.java:224)

        at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:301)

        at java.awt.Component.dispatchEventImpl(Component.java:4489)

        at java.awt.Component.dispatchEvent(Component.java:4243)

        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)

        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)

        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)

        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)



I assume this means its still trying to render the cnavas thats no longer on screen.  How do I stop it from

doing this?



Thanks



JK

I'm pretty new to this myself, but you could try calling  .setActive(false); on your GameState - that would stop it from displaying on that GameState until you set it back to true again.

Hmm… some more information…



Apparently it always happens on opening a second canvas if theres already one on screen.



It never happens otherwise.



So it seems I need to shut that one thats onscreen down.  I'll try your suggestion, thanks.

Well… I have no Game State, this a Swing app 8)



But there must be a control here somewhere  in what I DO have…


just browsing through the documentation the only other methods I can see that might help are



.flush()

.finish()



in your LWJGLRenderer (you should have one of those even if you're displaying on an awt.Canvas I believe?).  I can't say if they'll do anything for you though, since I haven't played with them myself.  Sorry I couldn't be of more help

Nope doesnt help.





I also cant short circuit render  in my panel that contains the canvas because its getting called directly

from the AWT repaint code.

Okay…



The problem is that lwjgl's AWTCanvas.paint() is calling LWJGL.paintGL() in the case of  a second (and later) canvas's creation before its really ready to render.



I'm not convincd this is the RIGHT fix, but adding the following test in LWJGLCamera.doFrameChange() fixes the problem in this case:



 // set view matrix
            RendererRecord matRecord = (RendererRecord) DisplaySystem.getDisplaySystem().getCurrentContext().getRendererRecord();
            if (matRecord == null){
                return;
            }