diff --git a/xwords4/wasm/Makefile b/xwords4/wasm/Makefile new file mode 100644 index 000000000..1a375dad0 --- /dev/null +++ b/xwords4/wasm/Makefile @@ -0,0 +1,9 @@ + +INPUTS = main.c + +all: main.html + +main.html: ${INPUTS} + emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' $^ -o $@ + + diff --git a/xwords4/wasm/main.c b/xwords4/wasm/main.c new file mode 100644 index 000000000..3746a096b --- /dev/null +++ b/xwords4/wasm/main.c @@ -0,0 +1,42 @@ +// Copyright 2011 The Emscripten Authors. All rights reserved. +// Emscripten is available under two separate licenses, the MIT license and the +// University of Illinois/NCSA Open Source License. Both these licenses can be +// found in the LICENSE file. + +#include +#include +#include +#include +#include +#include + +#ifdef __EMSCRIPTEN__ +#include +#endif + +int main(int argc, char** argv) +{ + SDL_Init(SDL_INIT_VIDEO); + + SDL_Window* window; + SDL_Renderer* renderer; + + SDL_CreateWindowAndRenderer(600, 400, 0, &window, &renderer); + + int result = 0; + + /** + * Set up a white background + */ + SDL_SetRenderDrawColor(renderer, 255, 255, 50, 50); + SDL_RenderClear(renderer); + + /** + * Show what is in the renderer + */ + SDL_RenderPresent(renderer); + + printf("you should see an image.\n"); + + return 0; +}