Juicepress
Posts: 7
Joined: Mon Jan 16, 2017 8:01 pm

libGDX on raspberryPi 3

Mon Jan 16, 2017 8:07 pm

Hello,
for a school project i wanted to program a simple jump´n´run game in libgdx on a desktop windows pc and i wanted to play it on a raspberryPi 3.
Unfortunately my linux/pi knowledge is really bad and every tutorial is outdated or links are broken.
Is it still possible to run a libgdx game on a pi? Is there are simple tutorial or can someone explain it simple?

greetings

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Tue Jan 17, 2017 8:20 am

Actually it is far easier now. See here: viewtopic.php?f=81&t=163604
Let me know if you have any issues with it.

pavul
Posts: 13
Joined: Wed Jan 18, 2017 4:13 am

Re: libGDX on raspberryPi 3

Wed Jan 18, 2017 4:49 pm

that must not be a problem,

you can develop your game and then pass the .jar file of your game to rasp berry, once inside rpi just execute your .jar with java -jar command. that should work, I have been making that without problem.

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Wed Jan 18, 2017 4:57 pm

Jar is going to work only if it has native libraries for destination platform (in this case ARM of RPi). I think that default RPi does not have them - hence my previous post.

Juicepress
Posts: 7
Joined: Mon Jan 16, 2017 8:01 pm

Re: libGDX on raspberryPi 3

Thu Jan 19, 2017 6:44 pm

clicky wrote:Actually it is far easier now. See here: viewtopic.php?f=81&t=163604
Let me know if you have any issues with it.
clicky wrote:Jar is going to work only if it has native libraries for destination platform (in this case ARM of RPi). I think that default RPi does not have them - hence my previous post.
Aight,im gonna try that tomorrow. Thanks you.
pavul wrote:that must not be a problem,

you can develop your game and then pass the .jar file of your game to rasp berry, once inside rpi just execute your .jar with java -jar command. that should work, I have been making that without problem.
Are you sure? Which OS you using? I tried the standard rasbian from noobs(desktop version,newest version) and i get following error :

Code: Select all

Exception in thread "main" com.badlogic.gdc.utils.GdxRuntimeException : Coulnd´t load shared libary 'libdxarm.so for target : Linux, 32-bit

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Fri Jan 20, 2017 8:41 am

@Juicepress that exception you've posted here is exactly why you need ARM version of it. If you switch to version I pre-built and deployed to my repository it *should* work. Any issues let me know. At some point I should make new build with the latest version of LibGDX again. Hopefully this time it is going to be simpler O: )

Juicepress
Posts: 7
Joined: Mon Jan 16, 2017 8:01 pm

Re: libGDX on raspberryPi 3

Fri Jan 20, 2017 6:10 pm

clicky wrote:@Juicepress that exception you've posted here is exactly why you need ARM version of it. If you switch to version I pre-built and deployed to my repository it *should* work. Any issues let me know. At some point I should make new build with the latest version of LibGDX again. Hopefully this time it is going to be simpler O: )
So i just went through ur tutorial and i basically understood the idea behind jogl. U basically replace the lwjgl window with a jogl window right? I also read a bit about gradle but im still a bit confused.
I changed my build.gradle to get jogl but unfortunately i still cant use it. Like the import "import com.badlogic.gdx.backends.jogamp.JoglNewtApplication;" doesnt work for me.

Code: Select all

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "my-gdx-game"
        gdxVersion = '1.9.5'
        roboVMVersion = '2.3.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "http://repository.abstracthorizon.org/maven2/abstracthorizon.snapshot/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-jogamp:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
    }
}

tasks.eclipse.doLast {
    delete ".project"
}

This is my build.gradle atm. Is this because im using the newest version of libgdx? Or i am just stupid haha

I also tried to download ur example project but i cant open it since eclipse doesnt find the project.

Hopefully u can help me. Thanks!

EDIT: I also installed Buildship Gradle Integration 2.0 from eclipse marketplace

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Sat Jan 21, 2017 3:30 pm

There is only one built version at the moment: 1.9.5.rpi-SNAPSHOT

Line:
"Next is for 'allprojects\ext\gdxVersion' to have new value: '1.9.5.rpi-SNAPSHOT'. That's one of the snapshots (currently a build from the source as of week starting on 17th October 2016) of LibGDX with 'bits'(**)."
Hopefully that will get you going.

Juicepress
Posts: 7
Joined: Mon Jan 16, 2017 8:01 pm

Re: libGDX on raspberryPi 3

Sat Jan 21, 2017 8:19 pm

Aight,gradle worked for me. I was able to run gradlew.bat
I just copied ur build.gradle into my own project and and the bat worked without any problems.
Unfortunately im still not able to import

Code: Select all

import com.badlogic.gdx.backends.jogamp.JoglNewtApplication;
:cry:

Sorry for bothering u that much btw..

EDIT: I even managed to get ur example project into eclipse.. Even there it cant import

Code: Select all

import com.badlogic.gdx.backends.jogamp.JoglNewtApplication;

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Mon Jan 23, 2017 5:56 pm

Yeah, that's my fault. Sorry. You need to add:
compile "com.badlogicgames.gdx:gdx-backend-jogamp:$gdxVersion"

next (after? instead?)
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"

in project(":desktop") dependencies section. I'll update original post.
BTW I've followed my instructions and default example as produced by gdx-setup.jar works on my laptop and Eclipse.

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Sat Jan 28, 2017 9:31 am

Look what I've found: https://github.com/natdan/rpi-libgdx-example
That has all the details you would need to run LibGDX on RPi :)

Juicepress
Posts: 7
Joined: Mon Jan 16, 2017 8:01 pm

Re: libGDX on raspberryPi 3

Sat Jan 28, 2017 9:56 pm

I dont know,i literally copied ur project.gradle and the project.gradle from the example u linked. I even got that example u linked in my eclipse but still.. i cant import jogamp.

https://gyazo.com/9d927c7535f03531356608fd7f9b21b4

Code: Select all

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "my-gdx-game"
        gdxVersion = '1.9.5.rpi-SNAPSHOT'
        roboVMVersion = '2.3.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }
  repositories {
        mavenLocal()
        mavenCentral()
        maven { url "http://repository.abstracthorizon.org/maven2/abstracthorizon.snapshot/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}
project(":desktop") {
    apply plugin: "java"


dependencies {
        compile project(":core")

        compile 'org.java-websocket:Java-WebSocket:1.3.0'
        compile 'com.ning:async-http-client:1.9.33'
        compile 'org.slf4j:slf4j-api:1.7.14'
        compile 'org.slf4j:slf4j-simple:1.7.14'


        compile "com.badlogicgames.gdx:gdx-backend-jogamp:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
    }
}
project(":core") {
    apply plugin: "java"


dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
        compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
    }
}
tasks.eclipse.doLast {
    delete ".project"
}
Is there any way to install those libraries manuelly?

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Mon Jan 30, 2017 8:59 am

After amending project.gradle you need to right click on the project(s) (grouped up projects? or repeat for each individually) and select 'Update All' for gradle Eclipse plugin to update class paths.

Alternative is to drop them from Eclipse (delete) and re-import it.

Another idea is to check out example project in separate dir and import it as a new project and see if it works.

Juicepress
Posts: 7
Joined: Mon Jan 16, 2017 8:01 pm

Re: libGDX on raspberryPi 3

Fri Feb 03, 2017 7:02 pm

clicky wrote:After amending project.gradle you need to right click on the project(s) (grouped up projects? or repeat for each individually) and select 'Update All' for gradle Eclipse plugin to update class paths.

Alternative is to drop them from Eclipse (delete) and re-import it.

Another idea is to check out example project in separate dir and import it as a new project and see if it works.

Yea,i refreshed the project. Still not able to import. Gradle is working tho

Made a quick Video! Used the project.gradle from the example Project u linked.
https://www.youtube.com/watch?v=wcKWsWB ... tu.be&hd=1

Dunno where my mistake is :cry:

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Mon Feb 06, 2017 7:16 pm

Hi,
I've watched your video and I think I know where you might have made a mistake:

1. you 'created' LibGDX project over existing sources
2. asked setup program to create eclipse files
3. then you amended build.gradle
4. then you imported it in Eclipse as 'Eclipse project'

Now, there are two bits that cause the issue: you did 2. before 3. Consequence is that setup has created eclipse projects (more importantly .classpath - visible in Eclispe as 'Referenced Libraries') *before* you amended build.gradle.

Second thing is that, then, you imported 'stale' Eclipse project (created before you amended build.gradle) in Eclipse and imported it as 'static' Eclipse project.

There are two different ways to fix it. One is to find a way how to 're-create' eclipse projects from gradle and second is to import project as 'Gradle' project - not 'Eclipse' project.

So, second way may be done like this:

If you use 'Import'/'Gradle (STS)'/'Gradle project', select your 'test' dir, click on Build Model and let Eclipse + Gradle (STS) do the rest. Then you can right click on (desktop?) project, select Gradle (STS)/Refresh All and it will refresh dependencies (visible in Eclipse as 'Gradle Dependencies (persisted)' and you'll be able to use new dependency you have added to build.gradle.

If you insist using 'static' 'Eclipse' project (first way) I propose slightly roundabout way:

Import my example (rpi-libgdx-example) using the way above (as Gradle (STS) project) and when all is in and fine expand that 'Gradle Dependencies' and add all jogl-all and any other needed to your Eclipse project one by one (right click on project, 'Build Path'/'Add External Archives...').

I am sure that there is another way of enticing gradle to 're-build' Eclipse project from build.gradle file, but I never used it, especially not on Windows (which I don't have for last 12 years at least).

Let me know how did it go! :)

frickman
Posts: 3
Joined: Mon Feb 06, 2017 12:27 pm

Re: libGDX on raspberryPi 3

Tue Feb 07, 2017 2:23 am

I'd like to let you know that I managed to run the sample project provided by clicky via gradle


./gradlew :desktop:run

In order to use this you have to fix the main class property
in desktop/build.gradle

Code: Select all

project.ext.mainClassName = "org.ah.libgdx.rpi.desktop.TestDesktopLauncherJogl"
After that you can run it on a rasperry pi, altough it doesn't seem stable for larger libgdx games.

Juicepress
Posts: 7
Joined: Mon Jan 16, 2017 8:01 pm

Re: libGDX on raspberryPi 3

Tue Feb 07, 2017 8:48 am

Ohh,im dumb.
Thanks for explaining me everything. It was the first time i worked with gradle. Its working now! Thanks u so much :mrgreen:

User avatar
clicky
Posts: 501
Joined: Thu Oct 25, 2012 7:34 am

Re: libGDX on raspberryPi 3

Tue Feb 07, 2017 8:57 am

Wonderful! :)

Out of interest can you share what are you doing with LibGDX on RPi? :)

Return to “Java”