opengl窗口在移动/调整大小时冻结 [英] opengl window freezing during move/resize

查看:100
本文介绍了opengl窗口在移动/调整大小时冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用LWJGL开发游戏.在移动窗口时(计划将来添加调整大小的代码),渲染循环将冻结.我希望它在移动时继续以某种方式运行. LWJGL不包含glutMainLoop.

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.

显示器属于OpenGL,而不是Java.

The Display belongs to OpenGL, not 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);

推荐答案

嘿,尝试在单独的线程中创建渲染部件(Opengl初始化和更新/渲染). 我的意思是除了使用主线程以外,还为您创建一个新线程.

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.

作为参考,您可以检查此Wiki(最后一个示例) http://lwjgl.org/wiki/index.php?title=Basic_LWJGL_Applet

for reference you can check this wiki (last example) http://lwjgl.org/wiki/index.php?title=Basic_LWJGL_Applet

这篇关于opengl窗口在移动/调整大小时冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆