More Info Needed On Converting SDL2 To Web? Encripten?

Hi,

The old days long past when people installed games through EXE’s are coming to an end on Windows. Web is the replacement. I don’t know anything about converting an SDL2 C++ cross-platform game to web using something called Enscripten? Where should I get all the information required to learning porting SDL2 desktop to web? Also, SDL2 desktop is hardware accelerated on Windows 10/macOS/Linux - does SDL2 web port use any hardware acceleration like WebGL or it’s straight HTML5? I have alot of questions, but I need to port the new game to web for it to be successful.

Game is below on the fantastic Indie game market Itch.io:
https://slnthero.itch.io/t-crisis-4-110percent-ai-turbo-remix

Please help us out if you can.
Thanks in advance!

Jesse

Everything you need should be at emscripten.org.

Yes, it uses WebGL.

I went through this process last year and found it less painful than I had feared (and I’m using multi-threading, which is relatively new in Emscripten / WebAssembly).

Hi,

Thanks for the response!
I’ll look over that, but might have further questions.

One initial question is would be:
(1) Would it be possible to have one source code for both desktop and web?
(or the modifications necessary for Emscripten to build are not compatible with Windows/macOS/Linux)

Let me know, thanks!

Jesse

Just one other important question:
We use SDL2 with SDL2_Image, SDL2_Mixer, & SDL2_TTF.
Are the three support libraries above fully supported by Emscripten?
Let me know, thanks!

Jesse

Of course. I use the same source code for desktop, mobile and web, but there are a few #ifdefs to handle the differences.

We use SDL2 with SDL2_Image, SDL2_Mixer, & SDL2_TTF.
Are the three support libraries above fully supported by Emscripten?

Of those, I only use SDL2_ttf which is certainly supported (-s USE_SDL_TTF=2). According to the Emscripten documentation there’s also -s USE_SDL_IMAGE=2. SDL2_mixer is included in the Emscripten Ports but it may not be quite as easy as specifying a compiler switch in that case (I prefer to use SDL2 core audio).

I found this example a couple of weeks back, maybe it could help: http://main.lv/writeup/web_assembly_sdl_example.md