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.
- Clone the repositories
sokolandstbin thedepsfolder
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- Add an image (sky.png) in
assetsdirectory - 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- Launch a web server from the output folder
- Open
sprite.hmlpage from web server