【发布时间】:2015-05-10 03:02:20
【问题描述】:
当我制作一个简单的窗口时,它给了我一个错误,我不知道为什么!我在 Linux Mint 64 位。 (戴尔灵越 1764)
这是错误:
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)
这是我的代码:
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();
}
}
然后另一个类是:
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();
}
}
【问题讨论】:
-
尝试谷歌搜索“GLXBadFBConfig”,有解释。例如:opengl.org/discussion_boards/showthread.php/…
-
我看了这篇文章,但他们不知道如何修复它! :(
-
你的 linux 上是否有 3.2 上下文可用?显示模式应该是您硬件的预定义可用分辨率之一,不确定
标签: java opengl graphics 3d lwjgl