本文介绍了GLFW的线程设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我开始使用新的Lwjgl 3,它使用GLFW进行显示/鼠标/键盘处理,我真的很喜欢它!然而今天我打了砖头。我有一个简单的渲染动画,但当我拖动屏幕时,它停止渲染,直到我再次放手。 根据: http://www.glfw.org/faq .html 问题是由于窗户引起的。 I started working with the new Lwjgl 3 which uses GLFW for its Display/mouse/keyboard handling and I'm really liking it! However today i hit a brick. I had a simple rendering animation going but when I dragged the screen it stopped rendering until i let go again.According to: http://www.glfw.org/faq.htmlThe problem arises due to windows. 我做过Java之前的多线程事物。但我不确定这种情况下自己的线程是什么。我应该在单独的线程中使用opengl代码和GLFW代码吗?我也很难想出一种解决问题的方法。Ive done multi threaded things before in Java. But im not sure what goes in its own thread for this case. Should I have the opengl code and the GLFW code in seperate threads? I'm also having trouble thinking of a way to word my concerns.推荐答案就我所能找到的唯一真正的限制out是GLFW需要在应用程序的主线程中。这是操作系统事件队列为GLFW所用的地方,也是glfwPollEvents和glfwWaitEvents需要在主线程中的原因。The only real restriction as far as I can find out is that GLFW needs to be in the application's main thread. This is where the OS event queue lives for GLFW and is why glfwPollEvents and glfwWaitEvents need to be in the main thread. OpenGL渲染可以从自己的线程完成。 glfwMakeContextCurrent将OpenGL上下文绑定到进行该调用的线程。如果你的渲染函数在它自己的线程上运行,请确保更新上下文(如演示中所示)。OpenGL rendering can be done from its own thread. glfwMakeContextCurrent ties the OpenGL context to the thread making that call. If your render function runs on it's own thread just make sure to update the context (as shown in the demo). LWJGL论坛主题:[求助] LWJGL3未按预期进行线程化 LWJGL3多线程演示参考了以上链接 这篇关于GLFW的线程设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 06:42