我在使用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
答案 0 :(得分:1)
尝试使用此代码:
ContextAttribs attribs = new ContextAttribs(3,3)
.withForwardCompatible(true)
.withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
Display.create(new PixelFormat(),attribs);
} catch (LWJGLException e) {
e.printStackTrace();
}
我的猜测是你的版本对于某些计算来说太低了,因此抛出了异常。
如果这不起作用,则可能是您的图形驱动程序过时适用于Windows 10.尝试升级您的驱动程序。 (按windows + R
后)键入dxdiag可以看到您的驱动程序