Skip to content

Emscripten should make resizable windows fill the page #11949

@icculus

Description

@icculus

Fullscreen and relative mouse mode work here, and as far as I can tell, emsdk's API just calls the same requestPointerLock javascript interfaces behind the scenes that this issue mentions.

SDL reports resize events on the canvas and not the document window (but it listens for window resizes to decide if the canvas has changed; it's complicated). But even if the canvas shrinks because you made the window smaller than the canvas, it'll still pretend it hasn't resized and just scale output appropriately...at least as far as I can tell.

The OP is using a trick I've used myself before: hook into the DOM's window resize events directly, and set the SDL window (that is, the canvas) size based on that. This makes the SDL_Window take the entire browser page and resize dynamically as the user resizes the browser window, and for some games, this is 100% the right thing to do.

But it's not what SDL does by default, and it's not a change we should make at this point. But we should probably either document this or add a hint to make SDL handle this internally (or maybe make SDL_WINDOW_RESIZABLE windows fill the entire browser window and send a resize event on startup?). I'm sure this isn't an uncommon situation with people making web games.

Originally posted by @icculus in #11389 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions