Skip to content

Commit 35a3614

Browse files
committed
Added some text files from sdl12-compat, edited for sdl2-compat.
0 parents  commit 35a3614

File tree

5 files changed

+534
-0
lines changed

5 files changed

+534
-0
lines changed

BUGS.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
# Reporting bugs
3+
4+
Bugs are now managed in sdl2-compat's GitHub Issues tracker:
5+
6+
https://github.com/libsdl-org/sdl2-compat/issues
7+
8+
You may report bugs there, and search to see if a given issue has already
9+
been reported, discussed, and maybe even fixed.
10+
11+
12+
# Discussion with other humans
13+
14+
You may also find help at the SDL forums:
15+
16+
https://discourse.libsdl.org/
17+
18+
Bug reports are welcome here, but we really appreciate if you use the bug
19+
tracker, as bugs discussed on the forums may be forgotten or missed.
20+

COMPATIBILITY.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Compatibility notes
2+
3+
This is a list of quirks and known-issues for specific games, with possible
4+
workarounds.
5+
6+
## Nothing yet.
7+
8+
Come back later and there might be more notes here.
9+

HOW_TO_TEST_GAMES.md

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Testing games with sdl2-compat
2+
3+
sdl2-compat is here to make sure older games not only work well, but work
4+
_correctly_, and for that, we need an army of testers.
5+
6+
Here's how to test games with sdl2-compat.
7+
8+
9+
## The general idea
10+
11+
- Build [SDL3](https://github.com/libsdl-org/SDL) or find a prebuilt binary.
12+
- Build sdl2-compat (documentation is in README.md)
13+
- Find a game to test.
14+
- Make sure a game uses sdl2-compat instead of classic SDL2.
15+
- See if game works or blows up, report back.
16+
17+
18+
## Find a game to test
19+
20+
Unlike SDL 1.2, where we didn't build the compatibility layer until almost
21+
a decade in and most major projects had already migrated, there are _tons_
22+
of SDL2 games at the time of this writing; almost any Linux game on Steam
23+
in 2022 is using SDL2, not to mention almost any game that is in a Linux
24+
distribution's package manager, etc.
25+
26+
As such, while we kept a spreadsheet for known SDL 1.2 titles, we don't
27+
have an authoritative source of them for SDL2, but they're everywhere
28+
you look!
29+
30+
31+
## Make sure the game works with real SDL2 first!
32+
33+
You'd be surprised how quickly games can bitrot! If it doesn't work with
34+
real SDL2 anymore, it's not a bug if sdl12-compat doesn't work either.
35+
36+
37+
## Force it to use sdl2-compat instead.
38+
39+
Either overwrite the copy of SDL2 that the game uses with sdl2-compat,
40+
or (on Linux) export LD_LIBRARY_PATH to point to your copy, so the system will
41+
favor it when loading libraries.
42+
43+
SDL2 has something called the "Dynamic API" which is some magic inside of
44+
SDL2 itself: you can override the build of SDL2 in use, even if SDL2 is
45+
statically linked to the app!
46+
47+
Just export the environment variable SDL_DYNAMIC_API with the path of your
48+
sdl2-compat library, and it will use sdl2-compat! No LD_LIBRARY_PATH
49+
needed!
50+
51+
52+
## Watch out for setuid/setgid binaries!
53+
54+
On Linux, if you're testing a binary that's setgid to a "games" group (which
55+
we ran into several times with Debian packages), or setuid root or whatever,
56+
then the system will ignore the LD_LIBRARY_PATH variable, as a security
57+
measure. SDL_DYNAMIC_API is not affected by this.
58+
59+
The reason some games are packaged like this is usually because they want to
60+
write to a high score list in a global, shared directory. Often times the
61+
games will just carry on if they fail to do so.
62+
63+
There are several ways to bypass this:
64+
65+
- Use SDL_DYNAMIC_API instead.
66+
- On some distros, you can run `ld.so` directly:
67+
```bash
68+
LD_LIBRARY_PATH=/where/i/can/find/sdl2-compat ld.so /usr/games/mygame
69+
```
70+
- You can remove the setgid bit:
71+
```bash
72+
# (it's `u-s` for the setuid bit)
73+
sudo chmod g-s /usr/games/mygame
74+
```
75+
- You can install sdl2-compat system-wide, so the game uses that
76+
instead of SDL2 by default.
77+
- If you don't have root access at all, you can try to copy the game
78+
somewhere else or install a personal copy, or build from source code,
79+
but these are drastic measures.
80+
81+
Definitely read the next section ("Am I actually running sdl2-compat?") in
82+
these scenarios to make sure you ended up with the right library!
83+
84+
## Am I actually running sdl2-compat?
85+
86+
The easiest way to know is to set some environment variables:
87+
88+
```bash
89+
export SDL2COMPAT_DEBUG_LOGGING=1
90+
```
91+
92+
If this is set, when loading sdl2-compat, it'll write something like this
93+
to stderr (on Linux and Mac, at least)...
94+
95+
```
96+
INFO: sdl2-compat, built on Sep 2 2022 at 11:27:37, talking to SDL3 3.2.0
97+
```
98+
99+
100+
## Steam
101+
102+
If testing a Steam game, you'll want to launch the game outside of the Steam
103+
Client, so that Steam doesn't overwrite files you replaced and so you can
104+
easily control environment variables.
105+
106+
Since you'll be using the Steam Runtime, you don't have to find your own copy
107+
of SDL3, as Steam provides it (!!! FIXME: note to the future: SDL3 is still
108+
in development at the time of this writing, so Steam doesn't provide it _yet_).
109+
110+
On Linux, Steam stores games in ~/.local/share/Steam/steamapps/common, each
111+
in its own usually-well-named subdirectory.
112+
113+
You'll want to add a file named "steam_appid.txt" to the same directory as
114+
the binary, which will encourage Steamworks to _not_ terminate the process
115+
and have the Steam Client relaunch it. This file should just have the appid
116+
for the game in question, which you can find from the store page.
117+
118+
For example, the store page for Braid is:
119+
120+
https://store.steampowered.com/app/26800/Braid/
121+
122+
See that `26800`? That's the appid.
123+
124+
```bash
125+
echo 26800 > steam_appid.txt
126+
```
127+
128+
For Linux, you can make sure that, from the command line, the game still
129+
runs with the Steam Runtime and has the Steam Overlay by launching it with a
130+
little script:
131+
132+
- [steamapp32](https://raw.githubusercontent.com/icculus/twisty-little-utilities/main/steamapp32) for x86 binaries.
133+
- [steamapp64](https://raw.githubusercontent.com/icculus/twisty-little-utilities/main/steamapp64) for x86-64 binaries.
134+
135+
(And make sure you have a 32-bit or 64-bit build of sdl2-compat!)
136+
137+
And then make sure you force it to use _your_ sdl2-compat instead of the
138+
system/Steam Runtime build:
139+
140+
```bash
141+
export LD_LIBRARY_PATH=/where/i/installed/sdl12-compat
142+
```
143+
144+
Putting this all together, you might run [Portal](https://store.steampowered.com/app/400/)
145+
like this:
146+
147+
```bash
148+
cd ~/.local/share/Steam/steamapps/common/Portal
149+
export LD_LIBRARY_PATH=/where/i/installed/sdl2-compat
150+
export SDL2COMPAT_DEBUG_LOGGING=1
151+
echo 400 > steam_appid.txt
152+
steamapp64 ./portal
153+
```
154+
155+
156+
## Windows
157+
158+
Generally, Windows games just ship with an SDL2.dll, and you just need to
159+
overwrite it with an sdl2-compat build, then run as usual.
160+
161+
162+
## macOS, etc.
163+
164+
(write me.)
165+
166+
Most of the Linux advice applies, but you might have to replace the SDL2
167+
in a framework.
168+
169+
170+
## Questions?
171+
172+
If something isn't clear, make a note [here](https://github.com/libsdl-org/sdl2-compat/issues/new)
173+
and we'll update this document.
174+
175+
Thanks!
176+

LICENSE.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Copyright (C) 2022 Sam Lantinga <slouken@libsdl.org>
2+
3+
This software is provided 'as-is', without any express or implied
4+
warranty. In no event will the authors be held liable for any damages
5+
arising from the use of this software.
6+
7+
Permission is granted to anyone to use this software for any purpose,
8+
including commercial applications, and to alter it and redistribute it
9+
freely, subject to the following restrictions:
10+
11+
1. The origin of this software must not be misrepresented; you must not
12+
claim that you wrote the original software. If you use this software
13+
in a product, an acknowledgment in the product documentation would be
14+
appreciated but is not required.
15+
2. Altered source versions must be plainly marked as such, and must not be
16+
misrepresented as being the original software.
17+
3. This notice may not be removed or altered from any source distribution.
18+

0 commit comments

Comments
 (0)