开发者

Null Pointer Exception in GLProfile with JOGL 2.0

开发者 https://www.devze.com 2023-03-24 21:50 出处:网络
JOGL 2.0 added a GLProfile parameter to GLCapabilities. For whatever reason, with this simple code: import javax.media.opengl.GLCapabilities;

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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消