简体   繁体   English

使用 Eclipse 自动添加 OpenGL 导入

[英]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.*这样的静态导入(这是不好的做法)。

  1. Open the preferences window with Window -> Preferences .使用Window -> Preferences打开首选项窗口。
  2. Go to Java -> Editor -> Content Assist -> Favorites .转到Java -> Editor -> Content Assist -> Favorites
  3. Click New Type... .单击“ New Type...
  4. Enter org.lwjgl.opengl.GL11 .输入org.lwjgl.opengl.GL11
  5. Do steps 3 and 4 for each GL** class.为每个 GL** 类执行第 3 步和第 4 步。
  6. When you now enter something like 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.选择它以添加导入。
  7. Additionally, you can now type something like 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM