Skip to content

Browser platform support#848

Open
ololoken wants to merge 60 commits into
UZDoom:trunkfrom
ololoken:emscripten-trunk
Open

Browser platform support#848
ololoken wants to merge 60 commits into
UZDoom:trunkfrom
ololoken:emscripten-trunk

Conversation

@ololoken
Copy link
Copy Markdown

@ololoken ololoken commented Jan 2, 2026

Description

Adds wasm32 platform support. By default works in 32-bit mode with single thread.
Demo: https://turch.in/uzdoom+ashes2063/index.html?lang=en

Right now it's more PoC for discussion than PR ready to merge.

TODOs:

  • Sync FS callback to persist config changes and saves.
  • rendering, shaders and most annoying bugs.
  • fix save game screenshots
  • Network.
  • Make tools work via nodejs to avoid requirement to build them manually.
  • Add module launcher webpage with options to select WADs and PK3s.
  • Build pipeline

Checklist

@uncreativeCultist
Copy link
Copy Markdown

image probably the first person to run myhouse.wad inside of UZDoom on a web browser. good work, would be cool to see this get merged

@RicardoLuis0
Copy link
Copy Markdown
Contributor

TODOs:
Sync FS callback to persist config changes and saves.
Network.
Make tools work via nodejs to avoid requirement to build them manually.
Add module launcher webpage with options to select WADs and PK3s.

it'd probably also need porting to 64-bit wasm before merging as was mentioned in the forum thread, but really, amazing work on this 🎉

@RicardoLuis0 RicardoLuis0 self-requested a review January 2, 2026 18:03
Comment thread CMakeLists.txt Outdated
Comment on lines +197 to +201
#ifdef __EMSCRIPTEN__
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
#else
Copy link
Copy Markdown
Contributor

@RicardoLuis0 RicardoLuis0 Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be done by forcing gles2 on browser, rather than #ifdef-ing the version, that way if GLES3 support is ever added to the opengl3 backend (as a delta touch backport possibly?), webgl2 can be used with full user shader support

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GL context creation is deep in js module guts generated by emscripten. So it's better to set it from "native" code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GL context creation is deep in js module guts generated by emscripten. So it's better to set it from "native" code.

yeah, but the ifdef'd out code already sets 2.0.0 for GLES in the very same function, that's what i'm confused about

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I just didn't want to search SDL_GL_* attribute which is not supported and ruins context creation, later I will try hunt it.

Comment thread src/d_main.cpp Outdated
Comment thread src/rendering/hwrenderer/scene/hw_bsp.cpp Outdated
Comment thread src/common/rendering/gles/gles_shader.cpp
Comment thread src/CMakeLists.txt

# Non-Windows version also needs SDL except native OS X backend
if( NOT APPLE OR NOT OSX_COCOA_BACKEND )
if( NOT APPLE OR NOT OSX_COCOA_BACKEND AND NOT EMSCRIPTEN )
Copy link
Copy Markdown
Contributor

@RicardoLuis0 RicardoLuis0 Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the logic itself might not need it, but it'd be good for parenthesis to be used (since mixing OR and AND)

Comment thread src/common/rendering/r_thread.cpp Outdated
@RicardoLuis0
Copy link
Copy Markdown
Contributor

also this:

https://github.com/UZDoom/UZDoom/blob/trunk/src/common/audio/sound/oalsound.cpp#L639-L643

probably needs an ifdef to check for the emscripten version of openalsoft, or else a bogus warning will be printed

@ololoken
Copy link
Copy Markdown
Author

ololoken commented Jan 3, 2026

also this:

https://github.com/UZDoom/UZDoom/blob/trunk/src/common/audio/sound/oalsound.cpp#L639-L643

probably needs an ifdef to check for the emscripten version of openalsoft, or else a bogus warning will be printed

It's better to check if AL_VENDOR == "Emscripten"

@RicardoLuis0
Copy link
Copy Markdown
Contributor

also this:
https://github.com/UZDoom/UZDoom/blob/trunk/src/common/audio/sound/oalsound.cpp#L639-L643
probably needs an ifdef to check for the emscripten version of openalsoft, or else a bogus warning will be printed

It's better to check if AL_VENDOR == "Emscripten"

image

yeah, just something so that this warning doesn't print

@kcat
Copy link
Copy Markdown
Contributor

kcat commented Jan 3, 2026

yeah, just something so that this warning doesn't print

Certain things won't work without OpenAL Soft features, like sounds that use loop points (which don't cover the whole sound) or use stereo sound for 3D/world sounds, and "area sounds" may not sound correct. Some warning that the audio may sound wrong may be appropriate.

@RicardoLuis0
Copy link
Copy Markdown
Contributor

yeah, just something so that this warning doesn't print

Certain things won't work without OpenAL Soft features, like sounds that use loop points (which don't cover the whole sound) or use stereo sound for 3D/world sounds, and "area sounds" may not sound correct. Some warning that the audio may sound wrong may be appropriate.

afaik emscripten supports a ton of openal features

@RicardoLuis0
Copy link
Copy Markdown
Contributor

yep, loop points, spatial sounds, hrtf, etc
image
https://emscripten.org/docs/porting/Audio.html

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 3, 2026

Thanks for opening this PR! We'll review it soon.

I'm a bot that checks for some common problems. I'll update this comment with anything I find.

Looks like it's your first time contributing!

  • Welcome the community and thank you for your contribution! Please take a moment to familiarize yourself with the resources available in our README.md file.
  • Please take a moment to add your name to the bottom of the CONTRIBUTORS file!

Here are some minor issues, that might need fixing:

  • Head's up, libraries/ZMusic/ is a subtree. Please ensure you're pushing these changes upstream.
  • Head's up, libraries/ZWidget/ is a subtree. Please ensure you're pushing these changes upstream.

@Lunascaped
Copy link
Copy Markdown

not sure if its just me but i get a lot of weird mouse snapping with this, would be cool if it was fixed before merging.

2026-01-03.23-09-44.9MB.mp4

@RicardoLuis0 RicardoLuis0 added this to the longterm milestone Mar 25, 2026
ololoken added 25 commits March 25, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants