| Summary: | emscripten fullscreen issues | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Mark Sibly <blitzmunter> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED ABANDONED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | blitzmunter |
| Version: | don't know | ||
| Hardware: | Other | ||
| OS: | Other | ||
Hello, and sorry if you're getting dozens of copies of this message by email. We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc. Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report. So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues. (please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!) Thanks, --ryan. |
I was having serious problems with emscripten and fullscreen mode - in particular, clicking on the standard 'go fullscreen' button in the standard html page wasn't resizing the canvas properly, or notifying my app that window had been resized. I eventually got it working by tweaking emscriptenevents.c like this... EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData) { /*make sure this is actually our element going fullscreen*/ /* removed by mark! if(SDL_strcmp(fullscreenChangeEvent->id, "SDLFullscreenElement") != 0) return 0; */ SDL_WindowData *window_data = userData; if(fullscreenChangeEvent->isFullscreen) { //added by mark! window_data->windowed_width=window_data->window->w; window_data->windowed_height=window_data->window->h; SDL_bool is_desktop_fullscreen; window_data->window->flags |= window_data->requested_fullscreen_mode; if(!window_data->requested_fullscreen_mode) window_data->window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; /*we didn't reqest fullscreen*/ window_data->requested_fullscreen_mode = 0; is_desktop_fullscreen = (window_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP; /*update size*/ if(window_data->window->flags & SDL_WINDOW_RESIZABLE || is_desktop_fullscreen) { emscripten_set_canvas_size(fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight); SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, fullscreenChangeEvent->screenWidth, fullscreenChangeEvent->screenHeight); } else { /*preserve ratio*/ double w = window_data->window->w; double h = window_data->window->h; double factor = SDL_min(fullscreenChangeEvent->screenWidth / w, fullscreenChangeEvent->screenHeight / h); emscripten_set_element_css_size(NULL, w * factor, h * factor); } } else { /* removed by mark! EM_ASM({ //un-reparent canvas (similar to Module.requestFullscreen) var canvas = Module['canvas']; if(canvas.parentNode.id == "SDLFullscreenElement") { var canvasContainer = canvas.parentNode; canvasContainer.parentNode.insertBefore(canvas, canvasContainer); canvasContainer.parentNode.removeChild(canvasContainer); } }); */ double unscaled_w = window_data->windowed_width / window_data->pixel_ratio; double unscaled_h = window_data->windowed_height / window_data->pixel_ratio; emscripten_set_canvas_size(window_data->windowed_width, window_data->windowed_height); if (!window_data->external_size && window_data->pixel_ratio != 1.0f) { emscripten_set_element_css_size(NULL, unscaled_w, unscaled_h); } SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, unscaled_w, unscaled_h); window_data->window->flags &= ~FULLSCREEN_MASK; } return 0; } Note that I had to comment out code that referenced 'SDLFullscreenElement', and added some code to 'save' the window size before going fullscreen. The latter I think is due to the fact I use SDL_SetWindowSize, and that doesn't seem to update windowed_width/windowed_height anywhere, so when I returned from fullscreen window size was wrong. This is probably not the right way to fix this stuff, but it should be enough for someone who knows what they're doing to fix it properly. I *think* I'm using the latest version of everything - em++ -v says '1.35.0' and the version of SDL I'm using is from a github mirror of hg.libsdl.org/SDL. And sorry about code formatting, this is the first time I've bugzilla'd. Bye! Mark