Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Mutliple Windows not possible on Emscripten #12512

Open
3 tasks
Temdog007 opened this issue Mar 10, 2025 · 1 comment
Open
3 tasks

Creating Mutliple Windows not possible on Emscripten #12512

Temdog007 opened this issue Mar 10, 2025 · 1 comment

Comments

@Temdog007
Copy link
Contributor

Temdog007 commented Mar 10, 2025

Emscripten builds cannot create multiple windows because the code is written as if there will only be one canvas element in the document. I've looked into the code and believe these tasks needed to fix this issue:

  • Remove Emscripten hints and make them properties Add create window properties to be overrides for hints(emscripten: move hints to window properties #12509 )
  • Register callbacks that don't take an element as a parameter (i.e. emscripten_set_fullscreenchange_callback, emscripten_set_focus_callback, Emscripten_set_pointer_event_callbacks) during initialization. These callbacks should look through all of the canvases in the document and only handle the event for the focused canvas.
  • Update Emscripten_UpdateWindowFramebuffer to store multiple canvases and update the specified canvas based on the window_id of the window. This will only fix the software renderer.

For the opengles2 renderer, there are a few possibilities:

  • Update Emscripten such that a specific canvas can be set as the target canvas. Currently, Emscripten only renders to Module['canvas']
  • Update SDL so that it updates Module['canvas'] to the canvas of the renderer before any render calls.
  • Implement SDL_gpu with WebGL (or WebGPU) and ensure the correct canvas is being rendered to. Then, gpu would be the default renderer for Emscripten builds. If the opengles2 is used, return an error if multiple windows are attempted to be made and suggest using the gpu renderer.
@Semphriss
Copy link
Contributor

Based on my experience with Emscripten and HTML5 canvases, since contexts are bound to their canvas like renderers to their window, I would find it more intuitive if one SDL window == one HTML5 canvas, and disallow (or, if possible, implement in a dedicated function) the dynamic change of which canvas is bound to a window.

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

No branches or pull requests

2 participants