我在使用 lwjgl 打开显示器时遇到问题。这在我升级到 Windows 10 之前有效。(我之前有 Windows 7)。
这是来自控制台的错误
org.lwjgl.LWJGLException: Pixel format not accelerated
at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat(Native Method)
at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(WindowsPeerInfo.java:52)
at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:247)
at org.lwjgl.opengl.Display.createWindow(Display.java:306)
at org.lwjgl.opengl.Display.create(Display.java:848)
at org.lwjgl.opengl.Display.create(Display.java:797)
at com.asasse.game3d.renderengine.DisplayManager.createDisplay(DisplayManager.java:23)
at com.asasse.game3d.enginetester.MainGameLoop.main(MainGameLoop.java:22)
Exception in thread "main" java.lang.RuntimeException: No OpenGL context found in the current thread.
at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124)
at org.lwjgl.opengl.GL11.glViewport(GL11.java:3261)
at com.asasse.game3d.renderengine.DisplayManager.createDisplay(DisplayManager.java:31)
at com.asasse.game3d.enginetester.MainGameLoop.main(MainGameLoop.java:22)
在这里,如果我的项目中的代码导致错误
final ContextAttribs attribs = new ContextAttribs(3, 1).withForwardCompatible(true);
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create(new PixelFormat(), attribs);
} catch (final LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
宽度为 1280 高度为 720