Crashe in camera positioning with lwjgl-1.0b

When I install the latest lwjgl, camera positioning code that worked under lwjgl-0.99 gets a NPE in GL11.GLMatrixMode(5888) according to Eclipse debugger under Mac OS X latest.



I'd hoped that upgrading might get at another problem I reported in this forum; see http://www.jmonkeyengine.com/jmeforum/index.php?topic=3394.0



Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:1737)

at com.jme.renderer.lwjgl.LWJGLCamera.onFrameChange(LWJGLCamera.java:174)

at com.jme.renderer.AbstractCamera.setLocation(AbstractCamera.java:419)

at com.binary.nagumo.views.Frame$ControlPane$CameraPane.actionPerformed(Frame.java:256)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)

at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)

at java.awt.Component.processMouseEvent(Component.java:5554)

at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)

at java.awt.Component.processEvent(Component.java:5319)

at java.awt.Container.processEvent(Container.java:2010)

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

at java.awt.Container.dispatchEventImpl(Container.java:2068)

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

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)

at java.awt.Container.dispatchEventImpl(Container.java:2054)

at java.awt.Window.dispatchEventImpl(Window.java:1774)

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

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

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)

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

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

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

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

45 frames in -1055.919 seconds = -0.042616908 FPS (average)





The exception seems to be caught, printed and ignored somehwere so the app keeps on going



Is JME thought to work under new LWJGL releases?

How should I proceed. I'm a still a noob at JME.

I see that you use a button action to position the camera. With the latest LWJGL this must be in the same thread as the GL context. Therefore, you need to have your button call the GL thread to make the change.

The problem is that lwjgl1.0b has made changes that result in a more strict enforcing of the "only-one-thread-shall-access-opengl" edict.  Thus, anything that might make opengl calls (such as moving your camera) needs to happen inside of the paintGL call.  Yeah, it's a pain, but you can use the new RenderThreadActionQueue and RenderThreadExecutable classes to comply with that restriction.  JMECanvasImplementor has an example of this in it's resizeCanvas method:


    public void resizeCanvas(final int width, final int height) {
        RenderThreadExecutable exe = new RenderThreadExecutable() {
            public void doAction() {
                if (renderer != null)
                    renderer.reinit(width, height);
            }
        };
        RenderThreadActionQueue.addToQueue(exe);
    }



So basically, inside your actionPerformed method, make that RenderThreadExecutable instance and in it's doAction method, set the location of your camera.

Hope that helps!  I know the pain, trust me.

I'll make a seperate post on this utility to explain some of the ins and outs.

Or simply use JMEAction like shown in HelloJMEDesktop (you don't need to use a JMEDesktop to use it that way).

Thanks, Joshua.



Tried your resizeCanvas example. NPE's gone now. But my actions aren't being drained from the queue. Eclipse show's they're there but the queue isn't being drained. Must be anothe change somewhere I'm missing.



PS: jme.util isn't in any of the jars; at least none of those provided by CVS update. I copied the jme.util dir into my source tree to make this work.

If it's not being drained, you probably aren't using cvs jme (the fact that you copied in source seems to confirm that.)  The drain occurs in LWJGLCanvas, which was updated in cvs yesterday.