When I make a simple window it gives me an error and I have no idea why! I am on Linux Mint 64 bit. (Dell Inspiron 1764)
Here's the error:
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)
Here's my 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();
}
}
And then the other class is:
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();
}
}
After much work at this, I finally decided to read Minecraft's source code and see how they created their OpenGL window. I put it in my code, and now the window opens perfectly!
To get it working if you have the problem, replace
Display.create(new PixelFormat(), attribs);
with
Display.create(new PixelFormat().withDepthBits(24));