视频驱动程序不支持 OpenGL

2022-01-12 00:00:00 java libgdx

当我使用这段代码时:

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class Main {
   public static void main(String[] args) {
      LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
      cfg.title = "MtxJungleGameMenu";
      cfg.useGL20 = false;
      cfg.width = 800;
      cfg.height = 480;
      new LwjglApplication(new MainStarter(), cfg);
   }
}

我遇到这样的异常:

线程LWJGL 应用程序"com.badlogic.gdx.utils.GdxRuntimeException 中的异常:com.badlogic.gdx.utils.GdxRuntimeException:视频驱动程序不支持 OpenGL.

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: OpenGL is not supported by the video driver.

有什么帮助吗?

推荐答案

把这段代码System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true");

Put this code System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true");

在我的情况下问题解决了.这将允许 libgdx 以软件 openGL 模式运行.

Problem solved in my case.. this will allow libgdx to run as software openGL mode.

您的代码将如下所示.

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

public class Main {
   public static void main(String[] args) {
      LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
      System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true");
      cfg.title = "MtxJungleGameMenu";
      cfg.useGL20 = false;
      cfg.width = 800;
      cfg.height = 480;
      new LwjglApplication(new MainStarter(), cfg);
   }
}

相关文章