java - 未找到 LWJGLException?
问题描述
所以,我第一次尝试使用 LWJGL。我正在使用 LWJGL 版本 2.9.1,因为这是我正在关注的教程中使用的。我使用以下引用的库设置了我的 Eclipse 项目:lwjgl_util.jar、lwjgl.jar 和 slick-util.jar。我还为 Windows 链接了所有必要的本机 .dll 文件。导致错误的文件包含以下代码:
package render;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;
public class DisplayManager {
private static final int WIDTH = 1280;
private static final int HEIGHT = 720;
private static final int FPS_CAP = 120;
public static void createDisplay() {
ContextAttribs attribs = new ContextAttribs(3, 2);
attribs.withForwardCompatible(true);
attribs.withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create(new PixelFormat(), attribs);
} catch (LWJGLException e) {
e.printStackTrace();
}
// tell opengl where to render game (use whole display)
GL11.glViewport(0, 0, WIDTH, HEIGHT);
}
public static void updateDisplay() {
Display.sync(FPS_CAP); // ensures buttery smooth fps
Display.update();
}
public static void closeDisplay() {
Display.destroy();
}
}
我在下面使用这个类:
package engineTester;
import org.lwjgl.opengl.Display;
import render.DisplayManager;
public class MainGameLoop {
public static void main(String[] args) {
// TODO Auto-generated method stub
DisplayManager.createDisplay();
// enter game loop until someone clicks the top right x button
while (!Display.isCloseRequested()) {
// game logic and rendering
DisplayManager.updateDisplay();
}
DisplayManager.closeDisplay();
}
}
当我尝试运行上述文件时,出现以下异常:
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
at engineTester.MainGameLoop.main(MainGameLoop.java:12)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 1 more
有人可以解释我做错了什么吗?我按照本教程中的每个步骤设置项目https://www.youtube.com/watch?v=Jdkq-aSFEA0&t=0s。任何帮助深表感谢!
解决方案
推荐阅读
- javascript - 如何自动提交价格过滤器?
- python - 如何使用枚举完成数组中的数组之间的匹配?
- reactjs - 为什么在 this.state 上使用 useState?
- oracle - 无法显示工资超过 1300 的员工
- javascript - 我想在我的数据表中添加 excel 按钮以进行 excel 导出
- ios - 在 URLSession.shared.dataTask 之后,它要么不返回错误,要么不成功
- javascript - 我应该如何修改我的搜索栏代码以同时影响 2 个表,而不仅仅是 1 个?
- python-3.x - 熊猫,如何使用带有多索引数据框的子集删除值?
- scala - 匹配表达式后,for循环不返回列表中的值
- javascript - 如何使模态窗口的标题固定在顶部