/webgl2-wasm-sdl-sokol-sprite

🚀 Minimal sprite rendering example written in C with SDL2 for windowing, sokol_gfx for graphics API using WebGL2/GLES3, stb_image for loading image, compiled in WebAssembly with Emscripten

Primary LanguageCMIT LicenseMIT

webgl2-wasm-sdl-sokol-sprite

Minimal sprite rendering example written in C with SDL2 for windowing, sokol_gfx for graphics API using WebGL2/GLES3, stb_image for loading image, compiled in WebAssembly with Emscripten.

Step by step

  1. Clone the repositories sokol and stb in the deps folder
git clone https://github.com/floooh/sokol deps/sokol
git clone https://github.com/nothings/stb deps/stb

# else init/update submodules
git submodule update --init
  1. Add an image (sky.png) in assets directory
  2. Compile and build with the following command (need Emscripten installed):
emcc sprite.c -o sprite.html -Ideps/sokol -Ideps/stb --preload-file assets -s EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s USE_WEBGL2=1 -s USE_SDL=2
  1. Launch a web server from the output folder
  2. Open sprite.hml page from web server

Dependencies

  • sdl2 (builtin in Emscripten)
  • sokol (#02b1dae)
  • stb (#f4a71b1)