opengl window freezing during move/resize

自作多情 提交于 2019-12-23 12:37:27

问题


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);

回答1:


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



来源:https://stackoverflow.com/questions/7730513/opengl-window-freezing-during-move-resize

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!