移动/调整大小期间 opengl 窗口冻结

发布于 2024-12-09 10:43:56 字数 763 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Smile简单爱 2024-12-16 10:43:56

嘿,尝试在单独的线程中创建渲染部分(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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文