Bug using Xith3D and LWJGL

I tried both the May and August release of LWJGL. I’m using the August 19 release of Xith3D and using Java 1.5 Update 5. Sapphire ATI Radeon 9800 Pro on WinXP. It looks like it may be in LWJGL from the GL11 JNI:

public static void glGetInteger(int pname, IntBuffer params) {
	long function_pointer = GLContext.getCapabilities().GL11_glGetIntegerv_pointer;
	BufferChecks.checkFunctionAddress(function_pointer);
	BufferChecks.checkBuffer(params, 16);
	nglGetIntegerv(pname, params, params.position(), function_pointer);
}
private static native void nglGetIntegerv(int pname, IntBuffer params, int params_position, long function_pointer);

 [exec] int1: java.nio.DirectIntBufferU[pos=0 lim=16 cap=16]
 [exec] GL11.GL_MAX_TEXTURE_SIZE: 3379
 [exec] java.lang.NullPointerException
 [exec]     at org.lwjgl.opengl.GL11.glGetInteger(GL11.java:1161)
 [exec]     at com.xith3d.render.lwjgl.CanvasPeerImpl.renderStart(CanvasPeerImpl.java:285)
 [exec]     at com.xith3d.render.lwjgl.CanvasPeerImpl.display(CanvasPeerImpl.java:868)
 [exec]     at com.xith3d.render.lwjgl.CanvasPeerImpl.render(CanvasPeerImpl.java:1035)
 [exec]     at com.xith3d.scenegraph.View.renderOnce(View.java:604)
 [exec]     at com.xith3d.scenegraph.View.renderOnce(View.java:537)
 [exec]     at com.xith3d.scenegraph.View$ViewRunner.run(View.java:1276)
 [exec]     at java.lang.Thread.run(Thread.java:595)
 [exec] Exception in thread "Thread-3" java.lang.Error: java.lang.NullPointerException
 [exec]     at com.xith3d.render.lwjgl.CanvasPeerImpl.display(CanvasPeerImpl.java:987)
 [exec]     at com.xith3d.render.lwjgl.CanvasPeerImpl.render(CanvasPeerImpl.java:1035)
 [exec]     at com.xith3d.scenegraph.View.renderOnce(View.java:604)
 [exec]     at com.xith3d.scenegraph.View.renderOnce(View.java:537)
 [exec]     at com.xith3d.scenegraph.View$ViewRunner.run(View.java:1276)
 [exec]     at java.lang.Thread.run(Thread.java:595)
 [exec] Caused by: java.lang.NullPointerException
 [exec]     at org.lwjgl.opengl.GL11.glGetInteger(GL11.java:1161)
 [exec]     at com.xith3d.render.lwjgl.CanvasPeerImpl.renderStart(CanvasPeerImpl.java:285)
 [exec]     at com.xith3d.render.lwjgl.CanvasPeerImpl.display(CanvasPeerImpl.java:868)
 [exec]     ... 5 more

comes after this code executes…which is from the getting started tutorial…

private void buildBaseSceneGraph()
{
    // Construct the root of the scene graph
    universe = new VirtualUniverse();
    view = new View();
    universe.addView(view);
    locale = new Locale();
    universe.addLocale(locale);
    scene = new BranchGroup();
    locale.addBranchGraph(scene);

    // Create an initial rotation transformation
    Transform3D rotate = new Transform3D();
    rotate.rotXYZ(
        (float) Math.PI/4,
        (float) Math.PI/5,
        (float) Math.PI/2);
    TransformGroup objRotate = new TransformGroup(rotate);

    // Add to rotation object to scene graph
    scene.addChild(objRotate);

    // Create an add an initial cube to the rotation object
    Geometry g = Cube.createCubeViaTriangles(0, 0, 0, 1, true);
    Shape3D sh = new Shape3D(g);
    objRotate.addChild(sh);

    // draw a quad in the lower-left corner
    Shape3D sh4 = new Shape3D(createQuad(), new Appearance());
    scene.addChild(sh4);

    // Compile the scene for the renderer. Not necessary here.
    scene.compile();

    // Now we still need a Canvas for displaying our cube. We use
    // RenderPeer and CanvasPeer, which are an abstraction layer enabling
    // us to use Jogl and LWJGL. We can specify the owner, the dimension,
    // the color depth and fullscreen mode.
    RenderPeer rp;
    if (rendererType == RendererType.JOGL)
        rp = new com.xith3d.render.jogl.RenderPeerImpl();
    else
        rp = new com.xith3d.render.lwjgl.RenderPeerImpl();
    CanvasPeer cp = rp.makeCanvas(null, 640, 480, 32, false);
    Canvas3D canvas = new Canvas3D();
    canvas.set3DPeer(cp);
    view.addCanvas3D(canvas);

    // After adding the canvas to the view component of our scenegraph
    // the only thing remaining is to set back the position of the viewer.
    // We do this by modifying a Transform3D component of view. The first
    // vector is the position of the eye of the viewer. Because the z-axis
    // is pointing towards us we use a positive z value. The value should
    // be large enough to be outside the cube. The next vector specifies
    // the center of view. The third vector specifies the up direction which
    // is the positive y-axis here.
    view.getTransform().lookAt(
        new Vector3f(0, 0, 2.41f), // location of eye
        new Vector3f( 0, 0, 0), // center of view
        new Vector3f( 0, 1, 0)); // vector pointing up
    view.startView();
}

/**
 * QuadArray is used here. Four points are one quad.
 */
public Geometry createQuad()
{
    Point3f[] coords = new Point3f[]
    {
        new Point3f( 0,  0, 0),
        new Point3f(-1,  0, 0),
        new Point3f(-1, -1, 0),
        new Point3f( 0, -1, 0),
    };

    Color3f[] colors = new Color3f[]
    {
        new Color3f(1,0,0),
        new Color3f(1,1,1),
        new Color3f(0,1,0),
        new Color3f(1,1,1)
    };

    QuadArray g = new QuadArray(coords.length, GeometryArray.COORDINATES
        | GeometryArray.COLOR_3);
    g.setCoordinates(0,coords);
    g.setColors(0,colors);

    return g;
}

Do you think the bug is in LWJGL or Xith3D? They have possibly fixed it if it is LWJGL.

Will.

could be anything:

  1. bug with with jni and lwjgl, either caused internally by my graphics card setup or lwjgl
  2. something being passed incorrectly by xith3d
  3. something i’m not doing to load lwjgl correctly where it works with jogl

of course i don’t want to point the finger at myself with #3. i rather point it at poor documentation. :wink:

i could of course improve my debugging skills with a debugger, find out the values being passed around, and find out what the “… 5 more” is.

i’m thinking it could have just been the fact i was using a non-power-of-2 texture. but i think i get the same thing without textures. i’ll double check on it once i get a code reorganization complete to test geometry again…i got sidetracked with trying to get jogl to do true fullscreen.