🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
4.2 KiB

  1. Native Client
  2. ================================================================================
  3. Requirements:
  4. * Native Client SDK (https://developer.chrome.com/native-client),
  5. (tested with Pepper version 33 or higher).
  6. The SDL backend for Chrome's Native Client has been tested only with the PNaCl
  7. toolchain, which generates binaries designed to run on ARM and x86_32/64
  8. platforms. This does not mean it won't work with the other toolchains!
  9. ================================================================================
  10. Building SDL for NaCl
  11. ================================================================================
  12. Set up the right environment variables (see naclbuild.sh), then configure SDL with:
  13. configure --host=pnacl --prefix some/install/destination
  14. Then "make".
  15. As an example of how to create a deployable app a Makefile project is provided
  16. in test/nacl/Makefile, which includes some monkey patching of the common.mk file
  17. provided by NaCl, without which linking properly to SDL won't work (the search
  18. path can't be modified externally, so the linker won't find SDL's binaries unless
  19. you dump them into the SDK path, which is inconvenient).
  20. Also provided in test/nacl is the required support file, such as index.html,
  21. manifest.json, etc.
  22. SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
  23. This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
  24. hiding the asynchronous nature of the browser behind the scenes...which is not the
  25. same as making it disappear!
  26. ================================================================================
  27. Running tests
  28. ================================================================================
  29. Due to the nature of NaCl programs, building and running SDL tests is not as
  30. straightforward as one would hope. The script naclbuild.sh in build-scripts
  31. automates the process and should serve as a guide for users of SDL trying to build
  32. their own applications.
  33. Basic usage:
  34. ./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
  35. This will build testgles2.c by default.
  36. If you want to build a different test, for example testrendercopyex.c:
  37. SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
  38. Once the build finishes, you have to serve the contents with a web server (the
  39. script will give you instructions on how to do that with Python).
  40. ================================================================================
  41. RWops and nacl_io
  42. ================================================================================
  43. SDL_RWops work transparently with nacl_io. Two functions control the mount points:
  44. int mount(const char* source, const char* target,
  45. const char* filesystemtype,
  46. unsigned long mountflags, const void *data);
  47. int umount(const char *target);
  48. For convenience, SDL will by default mount an httpfs tree at / before calling
  49. the app's main function. Such setting can be overridden by calling:
  50. umount("/");
  51. And then mounting a different filesystem at /
  52. It's important to consider that the asynchronous nature of file operations on a
  53. browser is hidden from the application, effectively providing the developer with
  54. a set of blocking file operations just like you get in a regular desktop
  55. environment, which eases the job of porting to Native Client, but also introduces
  56. a set of challenges of its own, in particular when big file sizes and slow
  57. connections are involved.
  58. For more information on how nacl_io and mount points work, see:
  59. https://developer.chrome.com/native-client/devguide/coding/nacl_io
  60. https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
  61. To be able to save into the directory "/save/" (like backup of game) :
  62. mount("", "/save", "html5fs", 0, "type=PERSISTENT");
  63. And add to manifest.json :
  64. "permissions": [
  65. "unlimitedStorage"
  66. ]
  67. ================================================================================
  68. TODO - Known Issues
  69. ================================================================================
  70. * Testing of all systems with a real application (something other than SDL's tests)
  71. * Key events don't seem to work properly