Stephen Jakiel
Stephen Jakiel

Reputation: 31

Null Pointer Exception in GLProfile with JOGL 2.0

JOGL 2.0 added a GLProfile parameter to GLCapabilities. For whatever reason, with this simple code:

import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;

public class Test {
    public static void main(String[] args){
        GLCanvas canvas = new GLCanvas(new GLCapabilities(GLProfile.getDefault()));
    }
}

I get the following error:

Exception in thread "main" java.lang.NullPointerException
    at javax.media.opengl.GLProfile.getProfileMap(GLProfile.java:1561)
    at javax.media.opengl.GLProfile.get(GLProfile.java:589)
    at javax.media.opengl.GLProfile.getDefault(GLProfile.java:421)
    at javax.media.opengl.GLProfile.getDefault(GLProfile.java:429)
    at com.setcorp.mosey.Test.main(Test.java:7)

So I cannot even create a GLCanvas for use in my JOGL 2.0 application.

Substituting in:

GLCanvas canvas = new GLCanvas(new GLCapabilities(GLProfile.get(GLProfile.GL2)));

or

GLCanvas canvas = new GLCanvas(new GLCapabilities(null));

for line 7 gives me the same error.

I have set the build path to include newt.all.jar, jogl.all.jar, nativewindow.all.jar, and gluegen-rt.jar. I unzipped the dlls from their native jars and set the native library locations respectively in eclipse. I am using the jogl-2.0-b409-20110717-windows-i586 build and running W7, Intel Core 2 Duo T8100 2.10GHz, 2GB RAM, and Nvidia Quadro NVS 140M.

Is there an earlier build that would work for me?

Upvotes: 3

Views: 946

Answers (2)

Munil Mistera
Munil Mistera

Reputation: 1

It would be easier to just create a GLCanvas directly, as you don't seem to intend to use the GLCapabilities-there is a constructor that accepts no parameters.

Upvotes: 0

Pixelapp
Pixelapp

Reputation: 161

Your code seems fine. Just try it with only these jars in your build path (see below). Avoid including other jars when you try it.

  • jogl.all.jar
  • jogl-all-natives-windows-i586.jar
  • gluegen-rt.jar
  • gluegen-rt-natives-windows-i586.jar

Upvotes: 0

Related Questions