[英]Adding OpenGL imports automatically with Eclipse
I am new with OpenGL.我是 OpenGL 的新手。 I have just installed LWJGL and created a User Library in Eclipse.我刚刚安装了 LWJGL 并在 Eclipse 中创建了一个用户库。 It is linked to my Project but what Eclipse won't do is to import the needed classes automatically.它链接到我的项目,但 Eclipse 不会自动导入所需的类。 Is there a way to get it work?有没有办法让它工作? I don't like to write (eg) GL30.glMethodName()
every time and I also don't like to make a static import like import static org.lwjgl.opengl.GL30.*
(which is bad practice).我不喜欢每次都写(例如) GL30.glMethodName()
,我也不喜欢像import static org.lwjgl.opengl.GL30.*
这样的静态导入(这是不好的做法)。
Window -> Preferences
.使用Window -> Preferences
打开首选项窗口。Java -> Editor -> Content Assist -> Favorites
.转到Java -> Editor -> Content Assist -> Favorites
。New Type...
.单击“ New Type...
。org.lwjgl.opengl.GL11
.输入org.lwjgl.opengl.GL11
。glGenVertexArrays();
当你现在输入类似glGenVertexArrays();
and hover your mouse over it, there is an option Add static import for 'GL30.glGenVertexArrays'
.并将鼠标悬停在它上面,有一个选项Add static import for 'GL30.glGenVertexArrays'
。 Select it to add the import.选择它以添加导入。glGenVertex
and press Ctrl+Space
to get a popup menu of available methods.此外,您现在可以键入glGenVertex
类的glGenVertex
,然后按Ctrl+Space
以获取可用方法的弹出菜单。 Selecting one of them automatically adds the import.选择其中之一会自动添加导入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.