SFML community forums

General => Feature requests => Topic started by: jokoon on November 14, 2017, 02:54:01 pm

Title: Making SFML work with web assembly?
Post by: jokoon on November 14, 2017, 02:54:01 pm
Have anybody tried to build SFML to the WASM format? I've seen that wasm allows opengl calls.

It would be really cool to have SFML run in a browser :)
Title: Re: Making SFML work with web assembly?
Post by: stuart88 on July 06, 2018, 03:33:34 pm
Bumping this thread as I'd also like to know if there's much info on turning SFML projects in wasm files.

Cheers!
Title: Re: Making SFML work with web assembly?
Post by: jokoon on July 06, 2018, 06:49:54 pm
I think WASM doesn't really allow OpenGL calls directly, at least not through the C API, but through WebGL calls.

I don't really know how you make JS calls from WASM and vice versa, but obviously that would be painful to adapt SFML to WASM since you would add js code to make WASM work.

I don't think WASM will allow direct C OpenGL calls in the future (but I really wish it could happen), seen how complex it is to map C functions to system/driver calls. Peeking at what glad/glew does is enough to understand that things are not simple, seen the multiple opengl versions, core or compatibility, chip bugs, etc.

So in short, my former question was naive and uninformed, but there might be details I'm not aware about.
Title: Re: Making SFML work with web assembly?
Post by: Maxqia on August 16, 2018, 07:42:04 am
Was looking for this to turn my simple SFML game into a web app and found this.
WebAssembally seems to be designed for Emscripten, a compiler that compiles C++ into Javascript.
From the look of it, it supports OpenGL ES 2.0 and 3.0 with their C API/Libraries.
Someone would probably need to port SFML to the HTML5 C API that Emscripten provides to get it to work on the Web.

Port of SDL2 to Emscripten : https://github.com/emscripten-ports/SDL2 (https://github.com/emscripten-ports/SDL2)
Emscripten API : https://kripken.github.io/emscripten-site/docs/api_reference/html5.h.html (https://kripken.github.io/emscripten-site/docs/api_reference/html5.h.html)
https://kripken.github.io/emscripten-site/docs/porting/multimedia_and_graphics/OpenGL-support.html (https://kripken.github.io/emscripten-site/docs/porting/multimedia_and_graphics/OpenGL-support.html)
Title: Re: Making SFML work with web assembly?
Post by: exoloner on February 05, 2019, 08:21:36 pm
Well this is a really nice great idea, for this reasons:


But the bad points on browsers are : less optimization and worse performance then more CPU requeriments needed, full-screen issues, browser peculiarities.