XProger / OpenLara

Classic Tomb Raider open-source engine
http://xproger.info/projects/OpenLara/
BSD 2-Clause "Simplified" License
4.64k stars 360 forks source link

Black screen with SDL2 and Raspberry Pi #419

Open Rydra opened 2 years ago

Rydra commented 2 years ago

I'm trying to get OpenLara working with a Raspberry Pi 3B+ (loaded with Retropie). I've managed to get it working with the released RPi version on this repository. However I'm experiencing controls problems with that version (like rolling always without pressing a button, making the game unplayable). After some research on the issues of this repository, I found out that the rpi platform version should be deprecated in favor of the SDL2 version, so I compiled it and tried to make it work. However, after running it I can hear the music and sounds of the game, but with a complete black screen. I've tried compiling the SDL2 with all the possible compiling lines in build.sh with no success.

Is there any chance on how I can make this work on the Pi? Thanks!

This is the output after running up the SDL2 game:

OpenLara (Apr 18 2022)
Vendor   : (null)
Renderer : (null)
Version  : (null)
cache    : /home/pi/.openlara/
supports :
  variyngs count : 16
  binary shaders : false
  vertex arrays  : false
  depth texture  : false
  shadow sampler : false
  discard frame  : false
  NPOT textures  : false
  3D   textures  : true
  RG   textures  : false
  border color   : false
  max level      : false
  anisotropic    : 0
  float textures : float = false, half = false

shader: cache warm-up...
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
! program: ERROR:CUSTOM-28 (vertex shader, line 1) Incorrect #version
shader: cache is ready
meshes: 13
rooms   : 128 x 128
objects : 512 x 256
sprites : 1 x 1
glyphs  : 1024 x 512
MegaMesh (i:56808 v:10387 a:3, size:446000)
Read Slots...
FPS: 0 DIP: 4 TRI: 40 RT: 0
domis4 commented 2 years ago

this issue seems to be relevant as the compilation (and implicit the game is working), have you tested with latest raspberry pi os and libsdl? The error message does point to some version problems.

https://github.com/XProger/OpenLara/issues/387#issuecomment-1045977902

Rydra commented 2 years ago

@domis4 I use the Retropie OS (which is a variant of Raspbian). Yes, mine it's been fully updated to the last version of the OS. If you need the output of certain commands that could help, please let me know which ones.

Thank you!

vanfanel commented 2 years ago

@Rydra Please use latest stable SDL2, wich is 2.0.20. You have to build SDL2 with KMS/DRM video support. I guess X11 should work too but I will never test that on the Pi.

One thing is for sure: OpenLara works perfectly on the Pi3 and Pi4 using SDL2 2.0.20 on KMS/DRM. Let's try to find out why it doesn't work for you.

This is how I configure libSDL2 for building on a Pi4 in aarch64 mode:


CFLAGS="-march=native -mcpu=native -O2 -ftree-vectorize -pipe -fomit-frame-pointer -DEGL_NO_X11" \
CXXFLAGS="-march=native -mcpu=native -O2 -ftree-vectorize -pipe -fomit-frame-pointer -DEGL_NO_X11" \
./configure --enable-video-kmsdrm --disable-video-x11 --disable-dbus --disable-diskaudio --disable-oss --disable-pulseaudio --disable-video-rpi --disable-dummyaudio --disable-video-dummy --enable-video-opengles --enable-video-opengl --enable-video-vulkan --enable-libudev --disable-esd --disable-ime --disable-fcitx --disable-libsamplerate

Also note that OpenLara on the SDL2 platform can be built for GLES or OpenGL. Both work if you do a MESA build that has GLVND support for OpenGL.

Another problem on your side could be that MESA is an old verson. Never used the MESA version included by default on Raspberry Pi OS.

Rydra commented 2 years ago

@vanfanel thank you very much for your message. I can confirm I had SDL2 version 2.0.10 installed on my retropie (with KMS/DRM support):

SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
Assembly Math   :
Audio drivers   : disk dummy oss alsa(dynamic) pulse(dynamic) sndio(dynamic)
Video drivers   : dummy rpi x11(dynamic) kmsdrm(dynamic) opengl opengl_es1 opengl_es2
X11 libraries   : xcursor xdbe xinerama xinput2 xinput2_multitouch xrandr xscrnsaver xshape xvidmode
Input drivers   : linuxev linuxkd
Using libsamplerate : YES
Using libudev       : YES
Using dbus          : YES
Using ime           : YES
Using ibus          : YES
Using fcitx         : YES
make[1]: Leaving directory '/home/pi/RetroPie-Setup/tmp/build/sdl2/2.0.10+5rpi'
   debian/rules override_dh_auto_build
make[1]: Entering directory '/home/pi/RetroPie-Setup/tmp/build/sdl2/2.0.10+5rpi'

Following your tip, I installed version 2.0.20:

/home/pi/RetroPie-Setup
/home/pi/RetroPie-Setup/tmp/build/sdl2 /home/pi/RetroPie-Setup
(Reading database ... 141600 files and directories currently installed.)
Preparing to unpack libsdl2-2.0-0_2.0.20+5rpi_armhf.deb ...
Unpacking libsdl2-2.0-0:armhf (2.0.20+5rpi) over (2.0.10+5rpi) ...
Preparing to unpack libsdl2-dev_2.0.20+5rpi_armhf.deb ...
Unpacking libsdl2-dev:armhf (2.0.20+5rpi) over (2.0.10+5rpi) ...
Setting up libsdl2-2.0-0:armhf (2.0.20+5rpi) ...
Setting up libsdl2-dev:armhf (2.0.20+5rpi) ...
Processing triggers for libc-bin (2.28-10+rpt2+rpi1) ...
Processing triggers for man-db (2.8.5-2) ...
/home/pi/RetroPie-Setup

However, after installing and after rebooting, I get a startup error on the Retropie and it will throw me to the terminal without starting emulationstation, so I had to roll back to the 2.0.10 version again (which is the one that right now ships within the repositories of Retropie)

Error initializing SDL! No available video device
Renderer failed to initialize!
Window failed to initialize!

About the MESA check, do you have any guidance on how I can check that?

Thank you!

domis4 commented 2 years ago

as the compilation seems to work, but you get an error when trying to launch the application. what is your environment when launching the application? are you by any chance connected via ssh? do you launch the built binary via direct keyboard input while using an hdmi display?

This error seems to be related that you'r *nix distro is not capable of recognizing a display insance.

Rydra commented 2 years ago

@domis4 I launch Openlara from emulationstation with an SH script I made myself. As I mentioned on my post, the RPI release of openlara that is available for download in this repository works and I can play it (though it has issues with the controls).

The SDL initialization error I mentioned happens at boot, not when opening Openlara.

vanfanel commented 2 years ago

@Rydra Have you tried the SDL tests? They are included with the sdl2 sources.

Please confirm that testgles2 works at least.

Please dont old sdl2 versions. Use sdl 2.0.20. If sdl 2.0.20 doesnt work with your distro, that distro is broken.

And dont use fake KMS, only full KMS. Look in config.txt for that.