开发者

opengl window freezing during move/resize

开发者 https://www.devze.com 2023-04-12 02:27 出处:网络
I\'m developing a game using LWJGL. While movi开发者_高级运维ng the window, (plan to add resize code in the future), the rendering loop freezes. I would like it to continue running in some fashion whi

I'm developing a game using LWJGL. While movi开发者_高级运维ng 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);


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

0

精彩评论

暂无评论...
验证码 换一张
取 消