简体   繁体   English

opengl窗口在移动/调整大小时冻结

[英]opengl window freezing during move/resize

I'm developing a game using LWJGL. 我正在使用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. LWJGL不包含glutMainLoop。

The Display belongs to OpenGL, not Java. Display属于OpenGL,而不是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);

Hey Try creating the rendering part(Opengl init and update/render) in a separate thread. 嘿,尝试在单独的线程中创建渲染部件(Opengl初始化和更新/渲染)。 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 作为参考,您可以检查此Wiki(最后一个示例) http://lwjgl.org/wiki/index.php?title=Basic_LWJGL_Applet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM