-
Notifications
You must be signed in to change notification settings - Fork 285
/
README_sdl.txt
113 lines (80 loc) · 2.84 KB
/
README_sdl.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
SDL
===
This is an experimental port which uses SDL2 to create the Allegro
window and OpenGL context.
Dependencies
------------
SDL2 is required.
Building
--------
Pass -D ALLEGRO_SDL=on to cmake to enable building for SDL2.
Limitations
-----------
SDL2 requires calling SDL_PumpEvents() from the main thread regularly to
generate events. Currently Allegro5 makes those calls from the timer
subsystem - so as long as you have any timers running things will work
fine. If your Allegro 5 program uses no timers it may get stuck because
no SDL2 events can be received.
Emscripten
----------
One reason the SDL2 port is useful is that it allows running Allegro on
platforms not supported directly by Allegro, such as Emscripten. This is
even more experimental but here are some example steps that will compile
most of the examples for running in a web browser:
1. Make sure to set up the emscripten environment by running the
emsdk_env.sh
or equivalent as provided by emscripten.
2. Create a build folder.
mkdir build_emscripten
cd build_emscripten
If you're going to build a demo, you will need to manually create a file:
mkdir -p demos/speed/data
touch demos/speed/data/nothing.txt
3. Configure CMake, using emcmake.
```
USE_FLAGS=(
-s USE_FREETYPE=1
-s USE_VORBIS=1
-s USE_OGG=1
-s USE_LIBJPEG=1
-s USE_SDL=2
-s USE_LIBPNG=1
-s FULL_ES2=1
-s ASYNCIFY
-s TOTAL_MEMORY=2147418112
-O3
)
# You may need to set this yourself.
EM_CACHE=path-to-emsdk/upstream/emscripten/cache
emcmake cmake .. \
-D CMAKE_BUILD_TYPE=Release \
-D ALLEGRO_SDL=ON \
-D SHARED=OFF \
-D WANT_MONOLITH=ON \
-D WANT_ALLOW_SSE=OFF \
-D WANT_DOCS=OFF \
-D WANT_TESTS=OFF \
-D WANT_OPENAL=OFF \
-D ALLEGRO_WAIT_EVENT_SLEEP=ON \
-D SDL2_INCLUDE_DIR=$EM_CACHE/sysroot/include \
-D CMAKE_C_FLAGS="${USE_FLAGS[*]}" \
-D CMAKE_CXX_FLAGS="${USE_FLAGS[*]}" \
-D CMAKE_EXE_LINKER_FLAGS="${USE_FLAGS[*]} --preload-file data" \
-D CMAKE_EXECUTABLE_SUFFIX_CXX=".html"
```
Emscripten will take care of downloading the dependencies mentioned above via
its ports system.
To compile your own game adjust as necessary. You can use the
lib/liballegro_monolith-static.a library.
4. Compile the library and examples.
make
Since that can take awhile (a lot slower than regular compilation speed), you
may want to compile individual examples, e.g.
make ex_draw_bitmap
Note: If you make any changes to any data/ files, you will need to manually delete the generated .html
file in <build dir>/examples to force emscripten to regenerate the .data file.
5. To run the examples, navigate to the examples folder. At this point it is
easiest to start a local webserver, and then navigate to the examples using a
web browser. E.g. you could use the Python's web server module which prints out
a URL you can open:
python3 -m http.server