LWJGL running in text mode on Raspberry Pi

Started by Momoko_Fan, June 22, 2014, 20:40:15

Previous topic - Next topic

Momoko_Fan

Recently I've been trying to see if LWJGL could run on the Raspberry Pi in text mode. There was previous attempts but they require to have an X server running which consumes a lot of RAM, on a system with only 128 MB of memory this is not a good idea... For most games it is not needed to have X server anyway so if it can without it is actually better.

This is a screenshot of LWJGL Gears test running on top of htop (I executed the app via SSH)




And this is the output:
[root@malina ~]# java -Dorg.lwjgl.librarypath=$PWD -jar mytest.jar 
found mode: 1440 x 900 x 24 @60Hz
found mode: 640 x 480 x 24 @60Hz
found mode: 1024 x 768 x 24 @60Hz
found mode: 1152 x 864 x 24 @60Hz
found mode: 1280 x 544 x 24 @60Hz
found mode: 1280 x 720 x 24 @60Hz
found mode: 800 x 600 x 24 @60Hz
raspi: set mode 1440 x 900 x 24 @60Hz
raspi: create window 1440 x 900 x 24 @60Hz, fs = true
Display Adapter: VideoCore IV HW
Display Version: Jun 18 2014 18:46:58  - 1a6f79b82240693dcdb9347b33ab16f656b5f067 (clean) (release)

GL RENDERER: VideoCore IV HW
GL VENDOR: Broadcom
GL VERSION: OpenGL ES 2.0
GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 1.00

GL_OES_compressed_ETC1_RGB8_texture
GL_OES_compressed_paletted_texture
GL_OES_texture_npot
GL_OES_depth24
GL_OES_vertex_half_float
GL_OES_EGL_image
GL_OES_EGL_image_external
GL_EXT_discard_framebuffer
GL_OES_rgb8_rgba8
GL_OES_depth32
GL_OES_mapbuffer
GL_EXT_texture_format_BGRA8888
GL_APPLE_rgb_422
GL_EXT_debug_marker
1029 frames in 4.997 seconds = 205.92354
1101 frames in 4.999 seconds = 220.24405
1133 frames in 5.0 seconds = 226.6
1135 frames in 4.999 seconds = 227.04541


Unfortunately to make the native library I couldn't really use the existing Linux natives as they required X11 ..  Instead I created a new platform under platform_build for the raspberry pi which does not include X11 and instead depends on the broadcom libraries like libbcm_host.so. You do not need to have a raspberry pi or ARM machine to build the native because it uses the raspberry pi cross compiler available on github.

If there's any interest I can put up the code on github, at the moment though it is missing support for input, cursors, and some other stuff (audio via OpenAL works though).

Momoko_Fan

I looked into implementing input on Raspberry Pi without X11, it turns out there's /dev/input/event*** which expose input devices and are accessible by users in the "input" group on the Raspberry Pi. However, it's a quite low level interface and missing many functions need to support all features in LWJGL. Specifically: absolute mouse coordinates, hardware cursor and scan code to character translation. I found that libSDL2 already implements all of these functions on the Raspberry Pi so what I am planning to do is just copy their code over and implement it according to LWJGL's interfaces.

Once that's covered, the only thing left is joystick support which is already provided on Linux via JInput, it also uses /dev/input/event*** hence no reliance on X11 and should work out-of-the-box on the Raspberry Pi.

spasi

Interesting stuff.

Would you be interested to work on this using the LWJGL 3 codebase? It should be much simpler to create the bindings you need and not have to support pre-existing behavior. Note that the plan is (not implemented yet) to be able to build LWJGL 3 with alternative backends and conditionally include only the bindings required by your application, which should be ideal for Raspberry apps.

Momoko_Fan

Oh that's pretty cool! So far it definitely seems like a step in the right direction, but based on the code it looks alpha stage to me.

In any case, I think I'll apply the LWJGL 3 principles to create the LWJGL 2 Raspberry Pi backend, e.g. have a separate class with all public native methods that interact with the RPI APIs, to ease the porting effort (if any). At least until LWJGL 3 matures, that would have to do.