简体   繁体   English

Java-LWJGL-OS X Retina支持

[英]Java - LWJGL - OS X Retina Support

I searched so long for a solution to run a simple LWJGL application on my MacBook Pro with Retina display. 我花了很长时间寻找解决方案,以便在配备Retina显示屏的MacBook Pro上运行简单的LWJGL应用程序。 The problem is that the Retina display is flickering. 问题是视网膜显示屏闪烁。 But I just found uninformative hints. 但是我只是发现了一些无用的提示。

Do you know any code solution to handle this? 您知道处理此问题的任何代码解决方案吗? For example changing the viewport or something? 例如更改视口或其他内容?

What have I to add to the following code? 我要在以下代码中添加些什么?

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;

public class MainDisplay {
    final int DISPLAY_WIDTH = 640;
    final int DISPLAY_HEIGHT = 480;

    public void start() {
        try {
            Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT));
            Display.create();
        }
        catch(LWJGLException exception) {
            exception.printStackTrace();
        }

        while(!Display.isCloseRequested()) {
            Display.update();
        }

        Display.destroy();
    }
}

Did you actually try to render anything? 您实际上是否尝试渲染任何东西?

It sounds like the back buffer contains garbage data, and you're not painting anything in that loop. 听起来好像后缓冲区包含垃圾数据,并且您没有在该循环中绘制任何内容。 Every time you invoke the Display.update() it flips the back-buffer, and if you've not painted on it then you get the flickering of garbage data. 每次调用Display.update()它都会翻转后缓冲区,如果您未在其上绘制,则会闪烁出垃圾数据。

Try something like: 尝试类似:

while(!Display.isCloseRequested()) {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glEnd();
    Display.update();
}

Which clears the display before flipping the back-buffer. 在翻转后缓冲区之前,这将清除显示。

In general, if you don't actually display anything then you're at the whims of the graphics driver and memory as to what ends up on the screen. 通常,如果您实际上什么都不显示,那么您会在图形驱动程序和内存方面对屏幕上显示的内容产生异想天开的感觉。 If I used your code, I see the following in the window: 如果我使用了您的代码,则会在窗口中看到以下内容:

垃圾显示输出

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

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