【发布时间】:2016-05-14 13:58:30
【问题描述】:
我正在使用 LWJGL 构建游戏。
但是有一个问题。当我调用 glfwCreateWindow 时,LWJGL 会抛出错误并且不会创建窗口。
这是输出:
[2016-05-14 22:42:04.665] [CubeSystem/INFO] Starting graphics engine...
[LWJGL] GLFW_API_UNAVAILABLE error
Description : WGL: The driver does not appear to support OpenGL
Stacktrace :
org.lwjgl.glfw.GLFW.nglfwCreateWindow(GLFW.java:1168)
org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:1251)
Tmk.MyAdventure.System.CubeSystem.Init(CubeSystem.java:37)
Tmk.MyAdventure.Main.main(Main.java:13)
[2016-05-14 22:42:04.740] [CubeSystem/ERROR] Cannot create window.
我不知道为什么它说驱动程序似乎不支持 OpenGL。
我的电脑可以正常运行 OpenGL 游戏。另外,我将驱动程序更新到最新版本,仍然显示此消息。
当我在 IDE 之外运行时,我收到了相同的消息。
代码如下:
....
public class CubeSystem {
private static Logger l = new Logger("CubeSystem");
private static final int DEFAULT_WIDTH = 640;
private static final int DEFAULT_HEIGHT = 480;
private long window;
public CubeSystem() {
}
public boolean Init() {
l.Info("Starting graphics engine...");
//Configure error stream
GLFWErrorCallback.createPrint(System.err).set();
if(glfwInit() != GL_TRUE) {
l.Err("Cannot initialize GLFW.");
return false;
}
//Configure window
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
window = glfwCreateWindow(DEFAULT_WIDTH, DEFAULT_HEIGHT, "My Adventure", NULL, NULL);
if(window == NULL) {
l.Err("Cannot create window.");
return false;
}
glfwDestroyWindow(window);
glfwTerminate();
glfwSetErrorCallback(null).release();
return true;
}
}
注意:从 Init() 方法开始。
【问题讨论】:
-
您是否正确链接了 LWJGL 本地人?
-
WGL: The driver does not appear to support OpenGL。要么是 LWJGL 中的错误,在这种情况下你可以尝试不同的版本,或者你的计算机不喜欢 GLFW