edubart / sokol_gp

Minimal modern efficient cross platform 2D graphics painter in C
MIT No Attribution
450 stars 24 forks source link

Add Emscripten sample builds #6

Closed RobLoach closed 2 years ago

RobLoach commented 2 years ago

This adds definitions for building for the web. You will need emcc installed. Also need to run a web server that supports .wasm file requests.

make platform=web

Screenshot at 2022-04-16 17-54-48

Caveat

sample-effect's doesn't work since load_image() loads an image using stbi_load(). File system loading has to be switched to use sokol_fetch.h instead of through straight up file system.

edubart commented 2 years ago

Seems to work for me with emcc, thanks, merged!

I have also improved it to make sample effects to work and added to github pages. So you can view the demos on github in the following links:

Primitives sample - https://edubart.github.io/sokol_gp/sample-primitives.html Blending modes sample - https://edubart.github.io/sokol_gp/sample-blend.html Frame buffer sample - https://edubart.github.io/sokol_gp/sample-framebuffer.html Rectangle sample - https://edubart.github.io/sokol_gp/sample-rectangle.html Effect sample - https://edubart.github.io/sokol_gp/sample-effect.html SDF sample - https://edubart.github.io/sokol_gp/sample-sdf.html