Initial merge of Emscripten port!

With this commit, you can compile SDL2 with Emscripten
( http://emscripten.org/ ), and make your SDL-based C/C++ program
into a web app.

This port was due to the efforts of several people, including: Charlie Birks,
Sathyanarayanan Gunasekaran, Jukka Jyl?nki, Alon Zakai, Edward Rudd,
Bruce Mitchener, and Martin Gerhardy. (Thanks, everyone!)
This commit is contained in:
Ryan C. Gordon 2014-12-18 00:19:52 -05:00
parent a228b67d88
commit fe40a17224
61 changed files with 4047 additions and 600 deletions

View file

@ -24,6 +24,10 @@
#include <signal.h>
#endif
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#endif
#include "SDL.h"
#include "SDL_audio.h"
@ -75,6 +79,13 @@ poked(int sig)
done = 1;
}
void
loop()
{
if(done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING))
emscripten_cancel_main_loop();
}
int
main(int argc, char *argv[])
{
@ -131,8 +142,13 @@ main(int argc, char *argv[])
/* Let the audio run */
SDL_PauseAudio(0);
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
SDL_Delay(1000);
#endif
/* Clean up on signal */
SDL_CloseAudio();