문제

I searched so long for a solution to run a simple LWJGL application on my MacBook Pro with Retina display. 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.

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:

Garbage Display Output

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top