0
這是我的代碼,並在第10行,我把Display.setInitialBackground(200, 100, 56);
但它只是閃爍的屏幕爲什麼我的背景顏色不會在我的OpenGL顯示中發生變化?
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
public class Window {
public static void createWindow(int width, int height, String title) {
Display.setTitle(title);
Display.setInitialBackground(200, 100, 56);
try {
Display.setDisplayMode(new DisplayMode(width, height));
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
}
public static void render() {
Display.update();
}
public static boolean isCloseRequested() {
return Display.isCloseRequested();
}
public static int getWidth() {
return Display.getWidth();
}
public static int getHeight() {
return Display.getHeight();
}
public static String getTitle() {
return Display.getTitle();
}
}
這是第二類我沒有任何錯誤
public class Main {
public static final int WIDTH = 800;
public static final int HEIGHT = 600;
public static final String TITLE = "Virtual World";
public Main() {
}
public void start() {
run();
}
public void stop() {
}
public void run() {
while(!Window.isCloseRequested()) {
render();
}
}
public void render() {
Window.render();
}
public void cleanUp() {
}
public static void main(String[] args) {
Window.createWindow(WIDTH, HEIGHT, TITLE);
Main game = new Main();
game.start();
}
}