Skip to content

Latest commit

 

History

History
93 lines (65 loc) · 4.04 KB

README-nacl.txt

File metadata and controls

93 lines (65 loc) · 4.04 KB
 
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
================================================================================
Simple DirectMedia Layer for Native Client
================================================================================
Requirements:
* Native Client SDK (https://developer.chrome.com/native-client),
(tested with Pepper version 33 or higher).
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
toolchain, which generates binaries designed to run on ARM and x86_32/64
platforms. This does not mean it won't work with the other toolchains!
================================================================================
Building SDL for NaCl
================================================================================
Set up the right environment variables (see naclbuild.sh), then configure SDL with:
configure --host=pnacl --prefix some/install/destination
Then "make".
As an example of how to create a deployable app a Makefile project is provided
in test/nacl/Makefile, which includes some monkey patching of the common.mk file
provided by NaCl, without which linking properly to SDL won't work (the search
path can't be modified externally, so the linker won't find SDL's binaries unless
you dump them into the SDK path, which is inconvenient).
Also provided in test/nacl is the required support file, such as index.html,
manifest.json, etc.
Jun 8, 2014
Jun 8, 2014
31
32
33
SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
hiding the asynchronous nature of the browser behind the scenes...which is not the
Jun 9, 2014
Jun 9, 2014
34
same as making it disappear!
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
================================================================================
Running tests
================================================================================
Due to the nature of NaCl programs, building and running SDL tests is not as
straightforward as one would hope. The script naclbuild.sh in build-scripts
automates the process and should serve as a guide for users of SDL trying to build
their own applications.
Basic usage:
./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
This will build testgles2.c by default.
If you want to build a different test, for example testrendercopyex.c:
SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
Once the build finishes, you have to serve the contents with a web server (the
script will give you instructions on how to do that with Python).
Jun 8, 2014
Jun 8, 2014
59
================================================================================
Jun 9, 2014
Jun 9, 2014
60
RWops and nacl_io
Jun 8, 2014
Jun 8, 2014
61
62
63
64
65
================================================================================
SDL_RWops work transparently with nacl_io. Two functions are provided to control
mount points:
Jun 8, 2014
Jun 8, 2014
66
67
68
69
int SDL_NaClMount(const char* source, const char* target,
const char* filesystemtype,
unsigned long mountflags, const void *data);
int SDL_NaClUmount(const char *target);
Jun 8, 2014
Jun 8, 2014
70
Jun 8, 2014
Jun 8, 2014
71
For convenience, SDL will by default mount an httpfs tree at / before calling
Jun 9, 2014
Jun 9, 2014
72
the app's main function. Such setting can be overridden by calling:
Jun 8, 2014
Jun 8, 2014
73
74
75
76
77
78
79
80
81
82
83
SDL_NaClUmount("/");
And then mounting a different filesystem at /
It's important to consider that the asynchronous nature of file operations on a
browser is hidden from the application, effectively providing the developer with
a set of blocking file operations just like you get in a regular desktop
environment, which eases the job of porting to Native Client, but also introduces
a set of challenges of its own, in particular when big file sizes and slow
connections are involved.
Jun 8, 2014
Jun 8, 2014
84
85
86
87
88
For more information on how nacl_io and mount points work, see:
https://developer.chrome.com/native-client/devguide/coding/nacl_io
89
90
91
92
================================================================================
TODO - Known Issues
================================================================================
* Testing of all systems with a real application (something other than SDL's tests)