docs/README-emscripten.md
author Ryan C. Gordon <icculus@icculus.org>
Mon, 29 Oct 2018 20:00:03 -0400
changeset 12369 68c87b40b434
parent 10958 92d837180433
permissions -rw-r--r--
winmain: Don't use SDL_malloc (or SDL_stack_alloc, which might be malloc).

Otherwise, we are using the allocator before the app can set up its own hooks.

Now we use VirtualAlloc, and WideCharToMultiByte (because SDL_iconv uses
SDL_malloc, too!) to get ready to call into SDL_main.

This also makes console_wmain() call into the same routines as everything
else, so we don't have to deal with those allocations, too. Hopefully we
end up with the same results from GetCommandLine() as we do in wargv.

Fixes Bugzilla #4340.
slouken@10486
     1
Emscripten
slouken@10486
     2
================================================================================
slouken@10486
     3
slouken@10486
     4
Build:
slouken@10486
     5
slouken@10486
     6
    $ mkdir build
slouken@10486
     7
    $ cd build
philipp@10958
     8
    $ emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2"
slouken@10486
     9
    $ emmake make
slouken@10486
    10
slouken@10486
    11
Or with cmake:
slouken@10486
    12
slouken@10486
    13
    $ mkdir build
slouken@10486
    14
    $ cd build
slouken@10486
    15
    $ emcmake cmake ..
slouken@10486
    16
    $ emmake make
slouken@10486
    17
slouken@10486
    18
To build one of the tests:
slouken@10486
    19
slouken@10486
    20
    $ cd test/
slouken@10486
    21
    $ emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
slouken@10486
    22
slouken@10486
    23
Uses GLES2 renderer or software
slouken@10486
    24
slouken@10486
    25
Some other SDL2 libraries can be easily built (assuming SDL2 is installed somewhere):
slouken@10486
    26
slouken@10486
    27
SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/):
slouken@10486
    28
slouken@10486
    29
    $ EMCONFIGURE_JS=1 emconfigure ../configure
slouken@10486
    30
    build as usual...
slouken@10486
    31
slouken@10486
    32
SDL_gfx (http://cms.ferzkopp.net/index.php/software/13-sdl-gfx):
slouken@10486
    33
slouken@10486
    34
    $ EMCONFIGURE_JS=1 emconfigure ../configure --disable-mmx
slouken@10486
    35
    build as usual...