User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

RPi libgdx game development framework

Tue Jun 09, 2015 4:02 pm

libgdx has been demonstrated to work on the Raspberry Pi by several teams [1] [2] and porting efforts.
[1] http://forum.jogamp.org/JOGL-2-0-OpenGL ... 27689.html - Running libgdx using JogAmp JOGL on the raspberry Pi (requires patching libgdx)
[2] http://www.habitualcoder.com/?page_id=257 - Running libgdx using lwjgl on the raspberry Pi. (requires patching lwjgl and libgdx)

I will use this thread to document the effort to merge raspberry pi support into libgdx.
libgdx needs patching to support 32bit GNU/Linux systems,
this would allow the libgdx build servers to provide native librarys that work on the raspberry pi.
[under review] https://github.com/libgdx/libgdx/pull/3196
Last edited by xranby on Tue Jun 09, 2015 4:36 pm, edited 3 times in total.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Tue Jun 09, 2015 4:19 pm

postpunkpl wrote:Clicky, i have experience with libgdx. That is nice solution but can you explain how to make libgdx project at newest gradle based version that works with jogl? I read posts by Xerxes but i think it is very difficult. Can you help me with that?
clicky wrote:Yes and no.

I have very strong interest in writing LibGDX app for RPi and after my initial success following http://www.habitualcoder.com/?page_id=257 I left it aside for better days. I suspect same/similar steps would work with the latest LibGDX as not much has changed in that area (or at least that's my impression).

If you are to pick up that (old!) version of LibGDX you can relatively easily bootstrap it from project I made then. It is somewhere around here: http://svn.abstracthorizon.org/playgrou ... -rpi/libs/
...
My thinking goes as long as Jogl works on RPi and LibGDX supports it - it will work on RPi in one form or another.
The latest version of libgdx with JogAmp JOGL 2.3.1 and RPi1 + RPi2 support is currently available at:
https://github.com/gouessej/libgdx

Compiling the libgdx jars is if not easy at least streamlined, all you need is to have maven installed on a fast linux machine.
The whole process takes 5 minutes to clone the git and 5 minutes to build libgdx.

Code: Select all

git clone https://github.com/gouessej/libgdx
cd libgdx
mvn install
Compiling libgdx for use on RPi 1 & 2 requires one non-intuitive step you will have to compile the libgdx natives to work on a "32bit arm/GNU Linux system" a configuration that libgdx normally do not support as described here: https://github.com/libgdx/libgdx/wiki/B ... rom-source
The easiest way to do this is to run the native jni compilation on the Pi.

Code: Select all

cd libgdx/gdx/jni
ant
the libgdx build will think it is on a 32bit X86 Linux system and try to pass some X86 specific command line flags that do not work when compiling for ARM, you simply have to remove the command line flags and re-run ant. This is a low hanging fruit task to update the libgdx ant build scripts and native loaders to recognize when it is on a 32bit GNU/Linux system like the Pi.

If you use Eclipse to develop your application then you can export your application as a "runnable jar" that you may launch using
java -jar myapp.jar
on the pi.

We are collaborating with the libgdx team to merge our jogl libgdx branch, such a merge will take time because we are adding quite a lot of new classes to libgdx. In order to have libgdx work out of the box we also need to convince libgdx to provide natives for "32bit arm/GNU Linux systems".

If you have further questions on this JogAmp JOGL libgdx port then you are welcome to join the discussion at the JogAmp forum:
http://forum.jogamp.org/JOGL-2-0-OpenGL ... 27689.html
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Tue Jun 09, 2015 4:26 pm

jultan wrote:
xranby wrote:The latest version of libgdx with JogAmp JOGL 2.3.1 and RPi1 + RPi2 support is currently available at:
https://github.com/gouessej/libgdx
Thanks xrandy !
Jogl + libgdx seems a really good idea !!

RPI2 could be a great platform for games building..

Sadly, trying to build your libgdx version, using RPI2, does not seem to work...

maven and jni parts are ok.. But when I tried to build the main package (ant in the main folder), everything failed...
"compile-natives" send warns about armeabi-v7a files missing, "fetch-jogamp" did not find jars (I tried with an alternative url), but "fetch-joal" also, did not find jlayer-1.0.1-libgdx.jar ...

Did someone achieved to build a binary version for RPI2 armeabi-v7a ?

Regards,

Julien
The libgdx have two build systems
one using ant and one using maven

The build that you have successfully compiled using maven should work!

The one using ant is used to produce the "old-style" builds that you find at the end of the libgdx homepage.
http://libgdx.badlogicgames.com/download.html
If you want to perform an old style build then you need to first fetch some parts using ant -f fetch.xml before running ant.

Code: Select all

ant -f fetch.xml
ant
This will download a pre-compiled armeabi-v7a that is intended to work on android, and then compile an old-style build.

When we did the JogAmp JOGL port we initially added support for the old-style builds, but this work has "bit-rotten" and needs to be re-updated before the JogAmp JOGL port supports it again.

The fetch part of the old-style ant build is intended to download files into gdx-backend-jogamp
you need to change the file fetch.xml from using the three old paths
backends/gdx-jogl/ backends/gdx-joal/ backends/ gdx-jogamp/
into using the new single path
backends/gdx-backend-jogamp .
The missing jlayer-1.0.1-libgdx.jar file is now found inside
backends/gdx-backend-lwjgl/libs/jlayer-1.0.1-libgdx.jar
Please file a pull request to http://github.com/gouessej/libgdx if you have time to clean up the old-style ant builds scripts.

When you compile the natives for use on the Raspberry Pi you need to rename the compiled libgdx.so to libgdxarm.so because this is the name that libgdx have been patched [3] to use for 32bit ARM GNU/Linux systems.
[3] https://github.com/libgdx/libgdx/commit ... 9f40e84721
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

clicky
Posts: 226
Joined: Thu Oct 25, 2012 7:34 am

Re: RPi libgdx game development framework

Wed Jun 10, 2015 7:33 am

Great work. BTW is it worth keeping kind of up-to-date pre-compiled binaries somewhere? I understand the transient nature of them, but they do last some time. And if process is established (as you have nicely explained here) then keeping them pre-compiled for everyone could speed up adoption of LibGDX on RPi.

Edit: ... until it finds its way to official LibGDX release.

User avatar
jultan
Posts: 6
Joined: Thu Jun 04, 2015 10:18 am
Location: France
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 8:00 am

Thanks Xerxes !

Sorry. I am not really used to Maven..
And when I saw jogamp things in main build.xml, I thought I had to use it...

I guess, I have to work on the libgdx maven way :
https://github.com/libgdx/libgdx/wiki/Maven-integration

Regards,
Julien
Julien (@jultan)
Digital Weaver

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 8:58 am

jultan wrote:Thanks Xerxes !

Sorry. I am not really used to Maven..
And when I saw jogamp things in main build.xml, I thought I had to use it...

I guess, I have to work on the libgdx maven way :
https://github.com/libgdx/libgdx/wiki/Maven-integration

Regards,
Julien
Some quick notes how to test the gdx-backend-jogamp backend with existing libgdx gradle games/projects:
After running
mvn install
inside the libgdx sourcetree to build and install gdx-backend-jogamp into the local maven repository on your computer.

0. install eclipse and the eclipse gradle integration
https://github.com/libgdx/libgdx/wiki/S ... etBeans%29 - how to setup your development environment
https://github.com/spring-projects/ecli ... on-gradle/ - eclipse-integration-gradle installation instructions
by using this setup you will have a smooth experience using libgdx!
https://github.com/libgdx/libgdx/wiki/I ... end-gradle - Why does LibGDX recommend Gradle

1. edit the build.grade file of the libgdx games/project and make sure that mavenLocal() got added to repositorys like this:

Code: Select all

    repositories {
        mavenCentral()
        mavenLocal()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
2. add the compiled gdx-backend-jogamp and version number to the project desktop dependencies, like this:

Code: Select all

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


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-jogamp:1.5.6-SNAPSHOT"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    }
}
3. Update the desktop DesktopLauncher.java file to use the JogAmp JOGL port, like this:

Code: Select all

package com.mygdx.game.desktop;

import com.badlogic.gdx.backends.jogamp.JoglApplication;
import com.badlogic.gdx.backends.jogamp.JoglApplicationConfiguration;
import com.mygdx.game.RPiGemo;

public class DesktopLauncher {
        public static void main (String[] arg) {
                JoglApplicationConfiguration config = new JoglApplicationConfiguration();
                new JoglApplication(new RPiGemo(), config);
        }
}
4. then build the libgdx grade project as usual, preferably using eclipse.
The project will now run fine on your desktop dev machine.

5. To have the project running on a ARM GNU/Linux system you have to insert you own compiled libgdxarm.so into the gdx-platform-1.6.2-natives-desktop.jar
This will be fixed when ARM GNU/Linux support is merged into libgdx: https://github.com/libgdx/libgdx/pull/3196
The project will then run fine on the RaspberryPi 2
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 9:28 am

clicky wrote:Great work. BTW is it worth keeping kind of up-to-date pre-compiled binaries somewhere? I understand the transient nature of them, but they do last some time. And if process is established (as you have nicely explained here) then keeping them pre-compiled for everyone could speed up adoption of LibGDX on RPi.

Edit: ... until it finds its way to official LibGDX release.
I will keep pushing people to work with the right tools and compile the source code because this is the right internet wisdom to write down.

If you have a libgdx game or project that you want help package for use on the raspberry pi 2 then i may assist you.
The prerequisite for me to help test and package it is that your game/project is published with a public domain or a free software license.

Once you have eclipse and gradle installed its trivial to export a libgdx game/project as a runnable jar that people can easily run on their devices.

We will have tons of pre-compiled binarys once people start publish their libgdx games & applications in the raspberry pi store and forums.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

clicky
Posts: 226
Joined: Thu Oct 25, 2012 7:34 am

Re: RPi libgdx game development framework

Wed Jun 10, 2015 10:32 am

Hm. First disclaimer: By no means I want to discredit what you are doing/have done here! :)

Having clear/clean (cleaner?) build process is quite important and I am not shying away from it. I am quite happy to do it myself and your explanation here seems pretty straight forward.

But it is, kind of, unnecessary for 'ordinary' user. Each one of us who wants to get libgdxarm.so for RPi would need to go through it while it doesn't really change and we'll all end up with exactly same binary (within versions of components used, of course). My understanding is that once it is obtained (or is there anything else in any other libgdx projects?) it can be easily packaged and pushed in temp maven repo under gdx-backend-rpi (gdx-backend-arm32 or similar) and referenced by all.

I do understand your initial idea of 'forcing' us here to go through build process and ensure it is robust enough, but isn't the final artifact (in this case for very specific platform!) the end game? if so - and with all niceties maven (and other build tools using maven repos) provides the end goal? At least until we get the project in original libgdx source tree and built artifact central repo.

When I get time to breath I don't mind pushing it in my public repo for others to use until it is done properly. Nor I don't mind refreshing it when needed. Unless you object it, of course. :)

BTW with danger of attracting your wrath for not being thorough reading all the small details of your how-to - I'll dare to ask the question that just sprang to my mind (hope you don't mind :) ):

Are we going to end up with two separate/different libraries for Pi and Pi 2?

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 10:52 am

clicky wrote:Are we going to end up with two separate/different libraries for Pi and Pi 2?
It depends on the cross compiler.

When cross compiling libgdxarm.so for ARM using Debian or Ubuntu cross compile tool-chains; some ARMv7 intrinsic gets linked in by the compiler, originating from the cross compile tool-chains system library’s, even when you specify the armv6 arch.
The cross compiled native library’s will then crash when the Raspberry Pi 1 ARMv6 CPU encounters linked in ARMv7 instructions.

If you compile the libgdxarm.so native library’s on a Raspbian system then the linked in system parts will be ARMv6 compatible and the library will work on both Raspberry Pi 1 and Raspberry Pi 2.

It will take some extra work to make the cross compiled library's ARMv6 clean when using the ubuntu or debian toolchains.
Most likely: if you use the cross compiler from raspberry pi tools then you will get ARMv6 clean library’s:
https://github.com/raspberrypi/tools/tr ... rm-bcm2708

In some cases it is desirable to have two versions, one generic version that work on all Pi's and one optimized version for the Pi 2.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 12:04 pm

clicky wrote: But it is, kind of, unnecessary for 'ordinary' user. Each one of us who wants to get libgdxarm.so for RPi would need to go through it while it doesn't really change and we'll all end up with exactly same binary (within versions of components used, of course). My understanding is that once it is obtained (or is there anything else in any other libgdx projects?) it can be easily packaged and pushed in temp maven repo under gdx-backend-rpi (gdx-backend-arm32 or similar) and referenced by all.

I do understand your initial idea of 'forcing' us here to go through build process and ensure it is robust enough, but isn't the final artifact (in this case for very specific platform!) the end game? if so - and with all niceties maven (and other build tools using maven repos) provides the end goal? At least until we get the project in original libgdx source tree and built artifact central repo.

When I get time to breath I don't mind pushing it in my public repo for others to use until it is done properly. Nor I don't mind refreshing it when needed. Unless you object it, of course. :)
I have no objections, please go ahead, I am sure some people will enjoy using pre-compiled builds. :) :)

The Apache, Free Software,License used by libgdx explicitly states that you are allowed to redistribute!
https://github.com/libgdx/libgdx/blob/m ... ICENSE#L90

The end game for me is to educate people up to the point that makes them able to collaborate and contribute.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

clicky
Posts: 226
Joined: Thu Oct 25, 2012 7:34 am

Re: RPi libgdx game development framework

Wed Jun 10, 2015 12:23 pm

xranby wrote:The end game for me is to educate people up to the point that makes them able to collaborate and contribute.
I am grateful for that and that is definitively respected.

User avatar
postpunkpl
Posts: 13
Joined: Sat Jun 06, 2015 12:14 pm
Location: Poland

Re: RPi libgdx game development framework

Wed Jun 10, 2015 12:36 pm

Dear Xerxes,

Eveyrything is clear except point no 5:

"5. To have the project running on a ARM GNU/Linux system you have to insert you own compiled libgdxarm.so into the gdx-platform-1.6.2-natives-desktop.jar "

How can i do that? Can you explain it step by step? How to compile libgdxarm.so file and how to insert it to that file? (Where is that file etc)

There is also a lot of erros when i try to run project at Eclipse: (simpliest project generated from gdx-setup)

Exception in thread "main-AWTAnimator#00" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: com.jogamp.opengl.GLException: Caught IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' : #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' : #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error
on thread main-AWTAnimator#00
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:84)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:451)
at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:198)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.jogamp.opengl.GLException: Caught IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' : #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' : #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error
on thread main-AWTAnimator#00
at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1311)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:680)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:77)
... 3 more
Caused by: java.lang.IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' : #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' : #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error

at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:157)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:120)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:73)
at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:15)
at com.badlogic.gdx.backends.jogamp.JoglGraphics.init(JoglGraphics.java:88)
at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:641)
at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:663)
at jogamp.opengl.GLAutoDrawableBase$1.run(GLAutoDrawableBase.java:430)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1275)
... 6 more
AL lib: (EE) alc_cleanup: 1 device not closed

Greetings,
Peter
Greetings,

Peter

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 1:44 pm

postpunkpl wrote: There is also a lot of erros when i try to run project at Eclipse: (simpliest project generated from gdx-setup)
...
Caused by: java.lang.IllegalArgumentException: Error compiling shader: ERROR: 0:1: '' : #version required and missing.
ERROR: 0:1: 'attribute' : syntax error: syntax error
ERROR: 0:1: '' : #version required and missing.
ERROR: 0:7: 'varying' : syntax error: syntax error

at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:157)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:120)
...
This is a regression caused by a patch to add support for GL30 inside the jogl libgdx port.
A workaround is to revert the following block,
https://github.com/gouessej/libgdx/comm ... 8bf85f6R48
the comment inside the old, working, code explains:
- // libgdx uses glDrawElements and glVertexAttribPointer passing buffers
- // these functions are removed in OpenGL core only contexts.
- // libgdx shaders are currently only GLES2 and GL2 compatible.
- // try allocate an GLES2 or GL2 context first
- // before picking a OpenGL core only GL2ES2 context.
the new code requested the highest programmable OpenGL version on your hardware and that is likely GL4 core or GL3 core.
+ GLCapabilities caps = new GLCapabilities(GLProfile.getMaxProgrammable(true));

There is two ways to fix this:
A) It is technically possible to update all GLSL shaders in libgdx to work with both backward compatible and core only OpenGL driver profiles.
http://jogamp.org/wiki/index.php/How_to ... using_JOGL
This quite is hard work.
B) revert the initialization logic in
backends/gdx-backend-jogamp/src/com/badlogic/gdx/backends/jogamp/JoglGraphicsBase.java
to only pick OpenGL ES 2 compatible profiles when using the libgdx GL20 API and
to pick OpenGL ES 3 compatible profiles when using the libgdx GL30 API.
This is easy.

I will reproduce the regression using the SpriteBatch class on my hardware and then fix this using plan B.

:!: note you do not need to fix this to run libgdx on the raspberry pi.
The regression described above only triggers if you run libgdx on a desktop OpenGL system that have removed backward compatible support.
Last edited by xranby on Thu Jun 11, 2015 9:59 am, edited 2 times in total.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
jultan
Posts: 6
Joined: Thu Jun 04, 2015 10:18 am
Location: France
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 2:17 pm

What do we say to the God of Death ??? (which is certainly the god of building an RPI2's libgdx)
Not Today !! ;-)

Done :

Using RPI2 with last firmware and raspian (so : java build 1.8.0-b132)

"mvn install" of jogamp fork
"ant build" native gdx lib
edited pom and gradle files to use jogl dependencies
edited desktop source file to use jogl

and tried

THE GRADLE WAY :

Which does not seem to like my local maven repo

Code: Select all

Execution failed for task ':tasks'.                                                                                                                         
> Could not resolve all dependencies for configuration ':desktop:compile'.                                                                                  
   > Could not find com.badlogicgames.gdx:gdx-backend-jogamp:1.5.6-SNAPSHOT.                                                                                
     Searched in the following locations:                                                                                                                   
         https://repo1.maven.org/maven2/com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT/maven-metadata.xml                                         
....                                                                                                                                                          
     Required by:                                                                                                                                  
         mygame:desktop:1.0  		
Julien (@jultan)
Digital Weaver

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 2:18 pm

postpunkpl wrote:Dear Xerxes,

Eveyrything is clear except point no 5:

"5. To have the project running on a ARM GNU/Linux system you have to insert you own compiled libgdxarm.so into the gdx-platform-1.6.2-natives-desktop.jar "

How can i do that? Can you explain it step by step?
How to compile libgdxarm.so file
How to compile libgdxarm.so file:
I will describe how I cross compile the file using the updated build scripts that i have sent to libgdx for review.
[under review] https://github.com/libgdx/libgdx/pull/3196

0. On my x86_64 development machine i will first install a cross compile toolchain that can cross compile for armhf.

Code: Select all

sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
1. a quick git tutorial i will checkout my libgdx master branch where the ARM 32 linux patch is applied.
I will do this by entering the libgdx src git, add a new remote that matches my github account and fetch all my changes, finally i will checkout xranby/master branch

Code: Select all

cd libgdx
git remote add xranby http://github.com/xranby/libgdx
git fetch xranby
git checkout xranby/master
2. i will enter the gdx/jni directory and perform a single build of libgdxarm.so

Code: Select all

cd gdx/jni
ant -f build-linux32-arm.xml
the compiled lib can then be found in
libgdx/gdx/libs/linux32arm/libgdxarm.so

I can return to the gouessej/master jogamp branch by checking out the master branch

Code: Select all

git checkout master
postpunkpl wrote:and how to insert it to that file? (Where is that file etc)
After you have exported your project as a runnable jar using eclipse:
Export -> Java -> Runnable jar file
Select the Launch configuration that matches your DesktopLauncher
Select the export destination directory and jar file name.
Select Library handling * Package required libraries into generated JAR (one jar)
OR
Library handling * Copy required libraries into a sub-folder next to the generated JAR
Then click on Finnish

now you have two options
A) copy the libgdx/gdx/libs/linux32arm/libgdxarm.so next to the exported jar file
B) open the gdx-platform-1.6.2-natives-desktop.jar that has been bundled inside the exported JAR file or is found in a subfolder next to the exported JAR file.
JAR files are basically .zip files thus you can open a jar file using the gnome Archive Manager and then add the libgdxarm.so to the JAR file (zip)

A is probably the easiest and will work because libgdx will try to load libgdxarm.so from the java.library.path and the launch directory when it fail to find the library inside the jar.
Last edited by xranby on Thu Jun 11, 2015 10:00 am, edited 1 time in total.
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
jultan
Posts: 6
Joined: Thu Jun 04, 2015 10:18 am
Location: France
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 2:26 pm

THE MAVEN WAY

Which does not seem to like some libraries..

Started the project this way :

mvn archetype:generate -DarchetypeGroupId=com.badlogic.gdx -DarchetypeArtifactId=gdx-archetype -DarchetypeVersion=1.2.0 -DgroupId=com.domain.mygame -DartifactId=mygame -Dversion=0.1-SNAPSHOT -Dpackage=com.domain.mygame -DJavaGameClassName=MyGame

Build packaged jars, edited the one with native libs....
added previous libgdx.so as libgdxarmgnueabihf.so, which seems to be required by jvm.

and this time gluegen complained about filetype..
missing an armv7hf version ???


Code: Select all

[email protected] ~ $ java -jar mygame.jar                                                                                     
Java HotSpot(TM) Client VM warning: You have loaded library /tmp/jogamp_0000/file_cache/jln3330818611678675053/jln825924505618707076/libgluegen-rt.so which 
might have disabled stack guard. The VM will try to fix the stack guard now.                                                                                
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.                                           
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln3330818611678675053/jln825924505618707076/libgluegen-rt.so: /tmp/j
ogamp_0000/file_cache/jln3330818611678675053/jln825924505618707076/libgluegen-rt.so: mauvaise classe ELF : ELFCLASS64 (Possible cause: architecture word wid
th mismatch)                                                                                                                                                
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)                                                                                          
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)                                                                         ....                                                              
        at com.domain.mygame.java.MyGameDesktop.main(MyGameDesktop.java:11)  


                                                                            
[email protected] ~$ find /home/pi/build/libgdx | grep gluegen                                                                
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-amd64.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-armv6.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-macosx-universal.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-windows-amd64.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-solaris-amd64.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-solaris-i586.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-armv6hf.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-i586.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-windows-i586.jar
Julien (@jultan)
Digital Weaver

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 2:35 pm

jultan wrote:What do we say to the God of Death ??? (which is certainly the god of building an RPI2's libgdx)
Not Today !! ;-)

Done :

Using RPI2 with last firmware and raspian (so : java build 1.8.0-b132)

"mvn install" of jogamp fork
"ant build" native gdx lib
edited pom and gradle files to use jogl dependencies
edited desktop source file to use jogl

and tried

THE GRADLE WAY :

Which does not seem to like my local maven repo

Code: Select all

Execution failed for task ':tasks'.                                                                                                                         
> Could not resolve all dependencies for configuration ':desktop:compile'.                                                                                  
   > Could not find com.badlogicgames.gdx:gdx-backend-jogamp:1.5.6-SNAPSHOT.                                                                                
     Searched in the following locations:                                                                                                                   
         https://repo1.maven.org/maven2/com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT/maven-metadata.xml                                         
....                                                                                                                                                          
     Required by:                                                                                                                                  
         mygame:desktop:1.0  		
Try check inside your /home/pi/.m2/ directory if your compile of gdx-backend-jogamp is using a different version name.
On my machine it looks like this:

Code: Select all

[email protected]:~/.m2/repository$ find . | grep gdx-backend-jogamp
./com/badlogicgames/gdx/gdx-backend-jogamp
./com/badlogicgames/gdx/gdx-backend-jogamp/maven-metadata-local.xml
./com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT
./com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT/maven-metadata-local.xml
./com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT/gdx-backend-jogamp-1.5.6-SNAPSHOT.jar
./com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT/gdx-backend-jogamp-1.5.6-SNAPSHOT-sources.jar
./com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT/gdx-backend-jogamp-1.5.6-SNAPSHOT.pom
./com/badlogicgames/gdx/gdx-backend-jogamp/1.5.6-SNAPSHOT/_maven.repositories
Double check that you have added mavenLocal() to the repository list.

Its possible that gradle's cache needs to be updated.
if you run grade from command line try
gradle --refresh-dependencies
https://docs.gradle.org/current/usergui ... ne_options

if you run gradle from inside eclipse then right click on the project -> gradle -> update cache
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Wed Jun 10, 2015 2:40 pm

jultan wrote:THE MAVEN WAY

Which does not seem to like some libraries..

Started the project this way :

mvn archetype:generate -DarchetypeGroupId=com.badlogic.gdx -DarchetypeArtifactId=gdx-archetype -DarchetypeVersion=1.2.0 -DgroupId=com.domain.mygame -DartifactId=mygame -Dversion=0.1-SNAPSHOT -Dpackage=com.domain.mygame -DJavaGameClassName=MyGame

Build packaged jars, edited the one with native libs....
added previous libgdx.so as libgdxarmgnueabihf.so, which seems to be required by jvm.

and this time gluegen complained about filetype..
missing an armv7hf version ???


Code: Select all

[email protected] ~ $ java -jar mygame.jar                                                                                     
Java HotSpot(TM) Client VM warning: You have loaded library /tmp/jogamp_0000/file_cache/jln3330818611678675053/jln825924505618707076/libgluegen-rt.so which 
might have disabled stack guard. The VM will try to fix the stack guard now.                                                                                
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.                                           
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/jogamp_0000/file_cache/jln3330818611678675053/jln825924505618707076/libgluegen-rt.so: /tmp/j
ogamp_0000/file_cache/jln3330818611678675053/jln825924505618707076/libgluegen-rt.so: mauvaise classe ELF : ELFCLASS64 (Possible cause: architecture word wid
th mismatch)                                                                                                                                                
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)                                                                                          
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)                                                                         ....                                                              
        at com.domain.mygame.java.MyGameDesktop.main(MyGameDesktop.java:11)  


                                                                            
[email protected] ~$ find /home/pi/build/libgdx | grep gluegen                                                                
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-amd64.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-armv6.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-macosx-universal.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-windows-amd64.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-solaris-amd64.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-solaris-i586.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-armv6hf.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-linux-i586.jar
/home/pi/build/libgdx/backends/gdx-backend-jogamp/libs/gluegen-rt-natives-windows-i586.jar
I think you have used the Eclipse: Library handling: Extract required libraries into generated JAR
This option is dangerous, because it will copy all versions of libgluegen-rt.so from all listed gluegen-rt-natives-*.jar jars above on top of each other and the top most will be used, in your case a 64bit version likely to be used on x86 systems is the only libgluegen-rt.so bundled with your applicaton.

Instead use Eclipse: Library handling: Package required librarys into generated JAR

JogAmp JOGL will use gluegen-rt-natives-linux-armv6hf.jar for both ARMv6 and ARMv7 to stay compatible with both raspberry Pi 1 and 2
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
jultan
Posts: 6
Joined: Thu Jun 04, 2015 10:18 am
Location: France
Contact: Website

Re: RPi libgdx game development framework

Thu Jun 11, 2015 9:44 am

Sorry... I am lost.... :cry:
Between Gouessej's libgdx fork and Xerxes's one (without jogamp ???).

I would be interested in steps between :
"git clone https://github.com/gouessej/libgdx"
and
"gradlew desktop:run" :roll:

(perhaps such informations could be shared on your first post Xerxes, or throug a gist link ?)

Thanks !
Julien
Julien (@jultan)
Digital Weaver

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Thu Jun 11, 2015 10:04 am

jultan wrote:Sorry... I am lost.... :cry:
Between Gouessej's libgdx fork and Xerxes's one (without jogamp ???).

I would be interested in steps between :
"git clone https://github.com/gouessej/libgdx"
and
"gradlew desktop:run" :roll:

(perhaps such informations could be shared on your first post Xerxes, or throug a gist link ?)

Thanks !
Julien
I have updated the post to make it clearer that you need to run git checkout master to return to Juliens master branch.
If you want to be 100% sure you are on Gouessej libgdx master branch then run:

Code: Select all

git remote add gouessej https://github.com/gouessej/libgdx
git fetch gouessej
git checkout gouessej/master
this will also update the sourcetree to include the libgdx 1.6.2 changes that gouessej have published tonight.


I will publish a nice blogpost with easy setup instructions when the the first public maven tree with a pre-compiled gdx-backend-jogamp is available. :roll:
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Mon Jun 15, 2015 10:00 am

I have posted a pre-compiled demo jar of the libgdx-demo-pax-britannica, with notes how i did to build it.
This demo work on a wide varity of system configurations: desktop X86 X86_64 OpenGL 2 Windows, Mac, Linux, Solaris and
"mobile" 32bit ARM GNU/Linux OpenGL ES 2 systems such as Raspberry Pi 1 & 2, AC100, Nokia N9 etc)
available here:
https://github.com/xranby/libgdx-demo-p ... 3-SNAPSHOT

You can try download and run it using:

Code: Select all

wget https://github.com/xranby/libgdx-demo-pax-britannica/releases/download/gdx-backend-jogamp-libgdx-1.6.3-SNAPSHOT/libgdx-demo-pax-britannica-1.6.3-SNAPSHOT.jar
wget https://github.com/xranby/libgdx-demo-pax-britannica/releases/download/gdx-backend-jogamp-libgdx-1.6.3-SNAPSHOT/libgdxarmgnueabihf.so
wget https://github.com/xranby/libgdx-demo-pax-britannica/releases/download/gdx-backend-jogamp-libgdx-1.6.3-SNAPSHOT/libgdxarm.so
java -jar libgdx-demo-pax-britannica-1.6.3-SNAPSHOT.jar
Image

I am very interested to know if someone have access and can test this on a Raspberry Pi system with Eric Anholt's free software Mesa3D + X11 Glamour OpenGL vc4 driver replacement.
http://anholt.livejournal.com/


Troubleshooting on Raspberry Pi:

If you see "* failed to add service - already in use?" this originate from the bcm Raspberry Pi OpenGL ES driver failed to allocate memory.
fix it by runing
sudo raspi-config
inside raspi-config select advanced -> memorysplit and change it to 64Mb or more.

If OpenAL fail to initialize
"AL lib: (EE) ALCplaybackOSS_open: Could not open /dev/dsp: No such file or directory"
this originate from that the libopenal sound library, bundled with JOAL, failed to find your raspberry pi soundcard
then you have two options:
A) load the linux kernel driver
sudo modprobe snd_pcm_oss
B) disable the OpenAL soft oss driver:
edit /etc/openal/alsoft.conf
and make sure that the drivers list contains -oss (it disables the OSS backend that tries to use the non existant dsp file)

Known issue seen on raspberry pi:
The "dispmanx" mousepointer overlay is misaligned with the OpenGL ES dispmanx window when using the closed source Broadcom BCM driver.
It appears that the OpenGL ES dispmanx has an added x+y offset that possibly originate from the over-scan settings in the BCM driver.
http://elinux.org/Raspberry_Pi_VideoCor ... spmanx_.2A
When we create the OpenGL ES dispmanx window we only specify a width and height, there is no offset set by us in the structure passed to EGL.
http://elinux.org/Raspberry_Pi_VideoCore_APIs#EGL
I you have an idea how to use the dispmanx API fix this offset then please tell.

If you have questions then reply to the jogamp forum at: http://forum.jogamp.org/JOGL-2-0-OpenGL ... l#a4034681
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

User avatar
jultan
Posts: 6
Joined: Thu Jun 04, 2015 10:18 am
Location: France
Contact: Website

Re: RPi libgdx game development framework

Fri Jun 19, 2015 1:48 pm

Great !! Thanks Xerxes !

Working great on my raspberry.
Julien (@jultan)
Digital Weaver

clicky
Posts: 226
Joined: Thu Oct 25, 2012 7:34 am

Re: RPi libgdx game development framework

Fri Jun 19, 2015 2:35 pm

I am jealous now guys! I just didn't get around to do it myself!

But, yes - that's great step forward - having alternative(-ish) framework for JavaFX + nice game framework for Java games on RPi!

:)

Thanks Xerxes!

User avatar
xranby
Posts: 538
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: RPi libgdx game development framework

Thu Aug 13, 2015 1:01 am

I made a special armhf build to test the improvements done to jogl 2.3.2-rc

this test build work well from both console and xorg
the misaligned mouse-pointer previously seen using libgdx is fixed using the jogl 2.3.2-rc

you can try this build:

Code: Select all

sudo modprobe snd_pcm_oss
wget http://labb.zafena.se/jogamp/vc4/libgdx-demo-pax-britannica-1.6.3-armhf.jar
java -jar libgdx-demo-pax-britannica-1.6.3-armhf.jar
Image

happy testing
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

clicky
Posts: 226
Joined: Thu Oct 25, 2012 7:34 am

Re: RPi libgdx game development framework

Tue Dec 29, 2015 9:24 am

Hi Xerces,

Just quickly to thank you again. I finally got chance to play with it and got it working on my RPi virtually without any issues.

There are two tiny problems (I can, for now for around) and if you have ideas what to look for/how to fix do them let me know:
- known issue (cannot find thread talking about it here, grrr) with running libgdx without X windows and getting mouse input that doesn't stretch over whole screen (easily fixable in side of my app)
- when running RPi with 'graphical interface' (straight automatic log in to pi user to X windows) input from touch screen (Chalk-Electronic 7" touch screen - http://www.chalk-elec.com/?page_id=1280 ... ry=3094861) input from it lags significantly and piles up. Almost like it is played with specific delay and not as fast as it was input.

Ordinary mouse at the same time works without any issue. And, if I startx on my own and then start libgdx app - everything works without any issue.

Oh, forgot to say that if I try to run libgdx app without X windows - it crashes at mouse input if 'stressed' (I can dig out stack trace but from my memory it said something like timeout after 5 seconds of not being able to process something)...

Even with those - I have found a away to run it without any problems and I am really greteful for your work. Any news from incorporating those natives in LibGDX project?

Return to “Java”