Uhm ok, can be shared between different contexes… though with a little more trouble than I thought by the looks of it (platform specific methods).
FYI, if you haven't noticed already, this code is now in CVS.
After updating, I get a NullPointerException in LWJGLZBufferState.enableDepthTest.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.jme.scene.state.lwjgl.LWJGLZBufferState.enableDepthTest(LWJGLZBufferState.java:107)
at com.jme.scene.state.lwjgl.LWJGLZBufferState.apply(LWJGLZBufferState.java:67)
at com.jme.renderer.lwjgl.LWJGLRenderer.clearZBuffer(LWJGLRenderer.java:444)
at com.jme.renderer.lwjgl.LWJGLRenderer.clearBuffers(LWJGLRenderer.java:480)
at factory.SharedCanvasImpl.doRender(SharedCanvasImpl.java:163)
at com.jmex.awt.lwjgl.LWJGLCanvas.paintGL(LWJGLCanvas.java:98)
at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:295)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:630)
at java.awt.Component.dispatchEventImpl(Component.java:4031)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
The ZBufferStateRecord instance passed to the method is null. Do I have to call additional setup code due to the new state management?
Thanks in advance...
Hmm, looks like you are running in a canvas. Please see reply#3 in this very thread (http://www.jmonkeyengine.com/jmeforum/index.php?topic=4049.msg32357#msg32357) Are you following that?
I have a custom CanvasImplementor, and I am setting it up as described (ok, I added an enableStatistics call):
public void doSetup() {
DisplaySystem display = DisplaySystem.getDisplaySystem();
renderer = new LWJGLRenderer(width, height);
renderer.setHeadless(true);
renderer.enableStatistics(true);
display.setRenderer(renderer);
display.getCurrentContext().setupRecords(renderer);
[...]
but it gives me:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(LWJGLRenderer.java:507)
at editor.swingStuff.CanvasImplementor.doRender(CanvasImplementor.java:135)
at com.jmex.awt.lwjgl.LWJGLCanvas.paintGL(LWJGLCanvas.java:98)
at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:295)
[...]
Apparently, Renderer.defaultStateList[RenderState.RS_COLORMASK_STATE] is null... Any ideas?
A call to display.updateStates(renderer) in my CanvasImplementor's doSetup() fixed it - is this the "good way" of solving the problem?
Yes, that's part of the simple implementations as well.