/ / Fehler beim Öffnen des Fensters? - Java, OpenGL, Grafik, 3D, LWJGL

Fehler beim Öffnen des Fensters? - Java, OpenGL, Grafik, 3d, lwjgl

Wenn ich ein einfaches Fenster mache, gibt es mir einen Fehler und ich habe keine Ahnung warum! Ich bin auf Linux Mint 64-Bit. (Dell Inspiron 1764)

Hier ist der Fehler:

org.lwjgl.LWJGLException: X Error - disp: 0x7f81187c9a20 serial: 93 error: GLXBadFBConfig request_code: 156 minor_code: 34
at org.lwjgl.opengl.LinuxDisplay.globalErrorHandler(LinuxDisplay.java:321)
at org.lwjgl.opengl.LinuxContextImplementation.nCreate(Native Method)
at org.lwjgl.opengl.LinuxContextImplementation.create(LinuxContextImplementation.java:51)
at org.lwjgl.opengl.ContextGL.<init>(ContextGL.java:132)
at org.lwjgl.opengl.Display.create(Display.java:850)
at org.lwjgl.opengl.Display.create(Display.java:797)
at renderEngine.DisplayManager.createDisplay(DisplayManager.java:27)
at engineTester.MainGameLoop.main(MainGameLoop.java:10)

Exception in thread "main" java.lang.IllegalStateException: Cannot determine close requested state of uncreated window
at org.lwjgl.opengl.Display.isCloseRequested(Display.java:549)
at engineTester.MainGameLoop.main(MainGameLoop.java:14)

Hier ist mein Code:

package engineTester;

import org.lwjgl.opengl.Display;

import renderEngine.DisplayManager;

public class MainGameLoop {

public static void main(String[] args) {
DisplayManager.createDisplay();

while(!Display.isCloseRequested()) {
//game logic
//render
DisplayManager.updateDisplay();
}

DisplayManager.closeDisplay();
}

}

Und dann ist die andere Klasse:

package renderEngine;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;
import org.lwjgl.test.applet.OpenGL;

public class DisplayManager {

private static final int WIDTH = 1000;

private static final int HEIGHT = 700;

private static final int FPS_CAP = 120;

public static void createDisplay() {

ContextAttribs attribs = new ContextAttribs(3,2);
attribs.withForwardCompatible(true);
attribs.withProfileCore(true);

try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create(new PixelFormat(), attribs);
OpenGL opengl = new OpenGL();
GL11.glViewport(0, 0, WIDTH, HEIGHT);
} catch (LWJGLException e) {
e.printStackTrace();
}
}

public static void updateDisplay() {
Display.sync(FPS_CAP);
Display.update();
}

public static void closeDisplay() {

Display.destroy();

}

}

Antworten:

0 für die Antwort № 1

Nachdem ich viel daran gearbeitet hatte, entschied ich mich endlich, Minecrafts Quellcode zu lesen und zu sehen, wie sie ihr OpenGL-Fenster erstellt haben. Ich habe es in meinen Code eingefügt, und jetzt öffnet sich das Fenster perfekt!

Ersetzen Sie, um das Problem zu beheben

Display.create (neues PixelFormat (), Attribut);

mit

Display.create (neues PixelFormat (). WithDepthBits (24));