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

@@ -14,8 +14,19 @@
/* Sample program: Draw a Chess Board by using SDL_CreateSoftwareRenderer API */
#include <stdlib.h>
#include <stdio.h>
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#endif
#include "SDL.h"
SDL_Window *window;
SDL_Renderer *renderer;
int done;
void
DrawChessBoard(SDL_Renderer * renderer)
{
@@ -44,12 +55,33 @@ DrawChessBoard(SDL_Renderer * renderer)
}
}
void
loop()
{
SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
done = 1;
return;
}
if(e.key.keysym.sym == SDLK_ESCAPE) {
done = 1;
return;
}
}
DrawChessBoard(renderer);
/* Got everything on rendering surface,
now Update the drawing image on window screen */
SDL_UpdateWindowSurface(window);
}
int
main(int argc, char *argv[])
{
SDL_Window *window;
SDL_Surface *surface;
SDL_Renderer *renderer;
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
@@ -83,24 +115,14 @@ main(int argc, char *argv[])
/* Draw the Image on rendering surface */
while(1)
{
SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT)
break;
if(e.key.keysym.sym == SDLK_ESCAPE)
break;
}
DrawChessBoard(renderer);
/* Got everything on rendering surface,
now Update the drawing image on window screen */
SDL_UpdateWindowSurface(window);
done = 0;
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done) {
loop();
}
#endif
return 0;
}