Why won't eclipse show lwjgl imports in the “quick fix” menu?

拈花ヽ惹草 提交于 2019-12-12 03:04:10

问题


I have tried everything mentioned in this question with no success.

I have also tried deleting the entire workspace and letting eclipse generate a new one, and setting access restrictions.

Deleting my installation of eclipse manually and deleting the eclipse folder in my user folder (windows 10), then reinstalling a fresh download of eclipse didn't work.

eclipse will clean imports just fine. i could import something general, like an entire class, and eclipse will make more specific imports by shortcut or when i save and quit.

The problem is the quick fix menu on mouseover, which does not offer any import suggestions. (it will for java classes such as random from java.util though)


回答1:


I think the problem is your missconception of the LWJGL library, or Java itself. Other than C++, in Java functions and variables HAVE to be in the scope of a class. This also includes static functions from OpenGL/LWJGL. Due to that restriction, LWJGL was implemented version-based. That means, all static variables and methods are contained in classes representing the version number the feature was implemented.

For example: glGetVertexArrays was introduced in OpenGL 3.0, which means, that you can find it in the GL30 class.

The advantage is, that it is possible to create backwards compatible software by only importing certain classes. e.g. if you want to make something OpenGL 3.3 compatible, you just don't import anything above GL33. The disadvantage is, that you have to either remember all the version numbers and their features, or you look it up in the Khronos Specification, or just guess.

To use LWJGL functions, you can either:

  • Import the class statically using e.g. import static org.lwjgl.opengl.GL30.*;

  • Use the classname e.g. int vao = GL30.glGenVertexArrays();

Note that when pressing [Ctrl]+[Shift]+O all static import ending with * are resolved to indiviual imports.



来源:https://stackoverflow.com/questions/37538162/why-wont-eclipse-show-lwjgl-imports-in-the-quick-fix-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!