我正在尝试使用 GLU.gluPerspective(),但它给了我静态引用错误

I'm trying to use GLU.gluPerspective(), but it's giving me the static reference error

好的。我是 OpenGL 之类的新手。我正在使用 LWJGL 3 和 JOGL(用于 GLU)并且我的自学过程完全停止了。现在我正在尝试使用 GLU.gluPerspective(80, 4/3, 0.1, 10000); 设置我的 3D 投影,但它给了我 Cannot make a static reference to the non-static method gluPerspective(double, double, double, double) from the type GLU - 我知道这意味着什么,但我不太确定 为什么我明白了。

我 copied/pasted 从 LWJGL 3 的页面中获取示例代码以获取我的大部分代码。为了绘制立方体,我使用了我在网上找到的另一段代码。

代码比较长,大家可以看看at this pastebin link.

上面的一点注意事项,第 158 行到第 174 行使用我的自定义播放器 class 和键盘 class,它们是最小的并且没有任何影响我正在做的事情我在其中的错误。

那么,尽管我实例化了一个新的 Main(),但为什么会给我这个错误?我对 Java 的记忆是不是有点生疏了? (pastebin 代码是 Main.java

如错误信息中所述gluPerspective is not a static method of the class GLU,这意味着你需要一个GLU 对象 调用它:

GLU glu = new GLU();
glu.gluPerspective(80, 4/3, 0.1, 10000);

这在JOGL user guide中也有说明:

To use the GLU, simply instantiate a GLU object via new GLU() at the beginning of your program. The methods on the GLU object may be called at any point when an OpenGL context is current. Because the GLU implementation is not thread-safe, one GLU object should be created for each GLEventListener or other entity performing OpenGL rendering in a given thread.