【发布时间】:2017-07-15 17:08:24
【问题描述】:
我尝试对我的应用程序进行多线程处理,但是当我尝试从主窗口共享上下文时,程序崩溃了。
[LWJGL]
GLFW_VERSION_UNAVAILABLE
error
Description : WGL: Failed to create OpenGL context
Stacktrace :
org.lwjgl.glfw.GLFW.nglfwCreateWindow(GLFW.java:1361)
org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:1521)
这里是主窗口的创建代码:
GLFWErrorCallback.createPrint(System.err).set();
if (!glfwInit()) {
throw new IllegalStateException("Unable to initialize GLFW");
}
glfwDefaultWindowHints();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
if(fullscreen){
window = glfwCreateWindow(vidmode.width(), vidmode.height(), windowTitle, glfwGetPrimaryMonitor(), NULL);
Var.windowSizeX=vidmode.width();
Var.windowSizeY=vidmode.height();
}else{
window = glfwCreateWindow(windowSizeX, windowSizeY, windowTitle, NULL, NULL);
glfwSetWindowPos(window, (vidmode.width() - windowSizeX) / 2, (vidmode.height() - windowSizeY) / 2);
}
if (window == NULL) {
throw new RuntimeException("Failed to create the GLFW window");
}
glfwMakeContextCurrent(window);
if (vSync) {
glfwSwapInterval(1);
} else {
glfwSwapInterval(0);
}
GL.createCapabilities();
以及我第二个线程中的代码:
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
offsiteWindow = GLFW.glfwCreateWindow(1, 1, "offsite", MemoryUtil.NULL, window);//errors
GLFW.glfwMakeContextCurrent(offsiteWindow);
GL.createCapabilities();
我做错了什么? 版本:稳定的 LWJGL 3.1.3 快照构建 1
【问题讨论】:
标签: multithreading opengl lwjgl glfw