I am getting a NullPointerException when attempting to use getPickRay
public void GetTouched(float x, float y)
{
Ray ResultsRay = ds.getPickRay(new Vector2f(x,y), true, null);
...
}
ds is the DisplaySystem I previously used .createCanvas on in order to get the canvas I am clicking on.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glLoadIdentity(GL11.java:1849)
at com.jme.renderer.lwjgl.LWJGLCamera.doFrameChange(LWJGLCamera.java:232)
at com.jme.renderer.lwjgl.LWJGLCamera.getModelViewMatrix(LWJGLCamera.java:272)
at com.jme.renderer.AbstractCamera.checkViewProjection(AbstractCamera.java:1004)
at com.jme.renderer.AbstractCamera.getWorldCoordinates(AbstractCamera.java:956)
at com.jme.system.DisplaySystem.getWorldCoordinates(DisplaySystem.java:754)
at com.jme.system.DisplaySystem.getPickRay(DisplaySystem.java:789)
Whenever I see a GL error the first question I ask - was what I did thread-safe? Was the code executed in GL thread? You might want to double-check that
Whenever I see a GL error the first question I ask - was what I did thread-safe? Was the code executed in GL thread? You might want to double-check that
Just to be absolutely sure I removed the thread repainting the canvas, and set simpleUpdate to not run any code during the time GetTouched was running. I still get the same error. Is there a part of jme that is constantly accessing the part throwing my error - or is it possible this is not a thread-safe issue?
Edit:
I moved all my functions etc to using a StandardGame and they work fine now. Either there is a weird threading issue with the canvas implementation that I am not seeing, or the way canvas is implemented in jme is buggy.
I saw the example moshad posted in this thread recently, and thought I’d take 5 minutes and hack a quick test into it - to see if it was just something wrong with my code. It is still possible I messed up in the way I implemented it, but here is a working example of the problem:
Even though I am now using StandardGame and it works fine, I would still like to know if I am doing something improperly, or if it really is a problem in the jme code.