移动/调整大小期间 opengl 窗口冻结
我正在使用 LWJGL 开发游戏。移动窗口时(计划将来添加调整大小代码),渲染循环冻结。我希望它在移动时继续以某种方式运行。 LWJGL 不包括 glutMainLoop。
Display属于OpenGL,而不是Java。
相关代码:
regular = new DisplayMode(800,600);
GL11.glClearColor(0.47f,0.55f,1.0f, 0.0f);
GL11.glClearDepth(1.0f);
try {
Display.setDisplayMode(regular);
Display.setTitle("Game Name");
Display.setIcon(loadIcon("resources/icon.png"));
Display.create();
seedresult= new Random(seed);
} catch (LWJGLException e) {
e.printStackTrace();
}
while (!Display.isCloseRequested()) {
Display.sync(60);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
//render objects
Display.update();}
System.exit(0);
I'm developing a game using LWJGL. While moving the window, (plan to add resize code in the future), the rendering loop freezes. I would like it to continue running in some fashion while moving. LWJGL does not include glutMainLoop.
The Display belongs to OpenGL, not Java.
Relevant code:
regular = new DisplayMode(800,600);
GL11.glClearColor(0.47f,0.55f,1.0f, 0.0f);
GL11.glClearDepth(1.0f);
try {
Display.setDisplayMode(regular);
Display.setTitle("Game Name");
Display.setIcon(loadIcon("resources/icon.png"));
Display.create();
seedresult= new Random(seed);
} catch (LWJGLException e) {
e.printStackTrace();
}
while (!Display.isCloseRequested()) {
Display.sync(60);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
//render objects
Display.update();}
System.exit(0);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿,尝试在单独的线程中创建渲染部分(Opengl 初始化和更新/渲染)。
我的意思是为您的渲染创建一个新线程,而不是使用主线程。
作为参考,你可以查看这个维基(最后一个例子)
http://lwjgl.org/wiki/index.php?title=Basic_LWJGL_Applet
Hey Try creating the rendering part(Opengl init and update/render) in a separate thread.
I mean create a new thread for you rendering other than using Main thread.
for reference you can check this wiki (last example)
http://lwjgl.org/wiki/index.php?title=Basic_LWJGL_Applet