libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
191 stars 40 forks source link

Trine (old humble bundle version) has black screen when in-game #313

Closed pizzadude closed 11 months ago

pizzadude commented 11 months ago

Trine, the old humble bundle version (not the enhanced / enchanted version) has a black screen in game when using libSDL1.2 compat.

This is on Fedora 38 KDE with wayland.

Let me know if you need any more info.

icculus commented 11 months ago

Bunch of notes from me:

To run: I had to apt-get install libglade2-0 libx86-1 on Ubuntu 22.10 to get this to install and run, and also move lib64/libstdc++.so.6 out of the way in the install directory. Then both trine-launcher64 and trine-bin64 both work. I didn't try the 32-bit binaries.

To use sdl12-compat, you have to push the shipped SDL 1.2 out of the way, since it's in the binary's RPATH. Just rename it.

The launcher crashes with sdl12-compat, apparently because they don't call XInitThreads before using GTK+, and then probably init SDL 1.2 after to get a list of video modes, which calls XInitThreads...this causes disaster when Xlib is suddenly in multithread mode but never set up mutexes...note the NULL mutex in pthread_mutex_lock:

#0  ___pthread_mutex_lock (mutex=0x0) at ./nptl/pthread_mutex_lock.c:80
#1  0x00007ffff68d649f in XrmQGetResource (db=0x6da2e0, names=0x7fffffff978c, classes=0x7fffffff9780, pType=0x7fffffff976c, pValue=0x7fffffff9770) at ../../src/Xrm.c:2549
#2  0x00007ffff68b80aa in XGetDefault (dpy=dpy@entry=0x690280, prog=prog@entry=0x7ffff685be61 "Xft", name=name@entry=0x7ffff685d5d4 "antialias") at ../../src/GetDflt.c:231
#3  0x00007ffff680bf3b in get_boolean_default (value=<synthetic pointer>, option=0x7ffff685d5d4 "antialias", dpy=0x690280) at ../../../../src/cairo-xlib-screen.c:98
#4  _cairo_xlib_init_screen_font_options (info=0x88c5a0, dpy=0x690280) at ../../../../src/cairo-xlib-screen.c:146
#5  _cairo_xlib_screen_get_font_options (info=0x88c5a0) at ../../../../src/cairo-xlib-screen.c:455
...

(this stack goes on for 91 more frames, but that's the obvious culprit.)

I do not understand why Xlib doesn't default to thread-safe mode in modern times, but oh well. I assume newer GTK+ releases do, but this its own shipped copy of GTK+ 2.0. In theory we could try to hook in and call it during startup in sdl12-compat...?

The game itself:

The black screen is just the usual OpenGL scaling incompatibility, because it binds FBO zero directly without going through sdl12-compat to do it.

icculus commented 11 months ago

Latest in sdl12-compat revision control should fix your problem, but I'm going to see if I can do something with the launcher before I close this issue.

icculus commented 11 months ago

And...done!

pizzadude commented 11 months ago

Thanks for the fix! :D