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
sokol
andstb
in thedeps
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
- Add an image (sky.png) in
assets
directory - 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.hml
page from web server