libgdx can't start desktop project on ubuntu

so, I just created libgdx project for desktop and imported it (gradle) to eclipse. When I launch it this error pops up:

Exception in thread "LWJGL Application" java.lang.ExceptionInInitializerError
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setVSync(LwjglGraphics.java:446)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:118)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.lwjgl.opengl.LinuxDisplay.getAvailableDisplayModes(LinuxDisplay.java:954)
at org.lwjgl.opengl.LinuxDisplay.init(LinuxDisplay.java:738)
at org.lwjgl.opengl.Display.<clinit>(Display.java:138)
... 2 more
AL lib: (EE) alc_cleanup: 1 device not closed

I can't figure out what's happening. Project's created for android and launched in android studio working properly.

Upvotes: 5

Views: 2479

Answers (3)

gvlasov
gvlasov

Reputation: 20015

This error disappeared for me after I switched from the default lwjgl backend (that is for some reason still used in the tool to generate a LibGDX project) to lwjgl3 backend. This is how you do it for a project freshly generated with gdx-setup.jar (doc):

In build.gradle change

compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"

to

compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"

In DesktopLauncher class, change

LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new Game(), config);

to

Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
new Lwjgl3Application(new Game(), config);

and modify imports to

import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;

so basically just add 3 after lwjgl in those two places.

Upvotes: 1

Saeed Masoumi
Saeed Masoumi

Reputation: 8916

This is a known issue, try to install xorg-xrandr.

Also, I fixed this issue by installing bumblebee.

Upvotes: 6

Barodapride
Barodapride

Reputation: 3723

You need to install the xorg-xrandr package, see

http://badlogicgames.com/forum/viewtopic.php?f=11&t=18801

Upvotes: 9

Related Questions