gpt4 book ai didi

java - "cannot find symbol method getGL()"(现在也是 getGLU())

转载 作者:行者123 更新时间:2023-12-02 08:38:25 25 4
gpt4 key购买 nike

我正在尝试学习如何使用 JoGL,由于某种原因,尽管导入了所有这些内容,我还是收到了此错误:

import javax.media.opengl.*;import javax.media.opengl.glu.*;import com.sun.opengl.util.*;import com.sun.opengl.util.j2d.*;
public void display(javax.media.opengl.GLDrawable gLDrawable)    {      final GL gl = gLDrawable.getGL();    }

nor

public void display(GLDrawable gLDrawable)    {      final GL gl = gLDrawable.getGL();    }

work.

How do I fix this?

(edit: moved the next question up to here... you can edit your question or make a new question if things change with the answers you get)

Okay, that worked for getGL(), but now I'm still having problems with "cannot find symbol method getGLU()"

public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
{
final GL gl = gLDrawable.getGL();
final GLU glu = gLDrawable.getGLU();
}

最佳答案

这是因为 GLDrawable 实际上没有有这样的方法 - 请参阅 here .

这是一个由 GLCanvas 和 GLJPanel 实现的接口(interface),两者都有这样的方法。

我认为你需要做的是传入一个 GLAutoDrawable 并使用它的 getGL 方法。请参阅here .

This wikipedia article有一些示例源代码展示了它是如何完成的。

在回答您进一步询问为什么 final GLU glu = gLDrawable.getGLU(); 不起作用时,您可能正在使用最新的 JSR-231 版本的 API,但是基于较旧的源代码示例构建您自己的代码。

在该规范之前,您通常从以下位置获取 GLU:

final GLU glu = glAutoDrawable.getGLU();

有了它,您现在只需使用:

final GLU glu = new GLU();

参见here有关该特定对象的详细信息。

关于java - "cannot find symbol method getGL()"(现在也是 getGLU()),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/617429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com