-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
No glutReshapeFunc() callback on browser window resizing #7133
Comments
The problem appears to be updateResizeListeners is never called on browser window resize. For comparison, when resizing the window with an SDL sample, updateResizeListeners is called via this stack: updateResizeListeners (hello_triangle.js:5795) There's no _Emscripten_HandleResize nor _emscripten_set_canvas_size in the GLUT sample, so browser resize events never make it to updateResizeListeners. |
Would a reasonable fix here involve adding
And then do the appropriate stuff in GLUT.onResize (which does not exist yet). |
Here is a proposed fix which adds an onResize handler to GLUT. It fixes the issue in my initial tests, but I'll do some more testing around it. Wondering if anyone sees an issue with this general approach? The core of the fix:
|
Needs to handle fullscreen properly, working on that. |
After a couple of testing iterations, I think I have a GLUT-side fix for this. The fix is to add a resize event listener and call _glutReshapeWindow on resize. Resize events due to entering/exiting fullscreen have to be excluded, and this is done two ways. On entering fullscreen, fullscreen document state is checked and the resize event listener is removed. On exiting fullscreen, the resize event listener is restored. If this seems like a reasonable solution I can put together a pull request. |
@erik-larsen Sounds good to open a pull request, we can discuss details there. Can see if the tests pass there, too. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
In the test hello_world_gles.c,
the callback registered to glutReshapeFunc() is not being called when the browser window is resized, even when using html which stretches the canvas to cover the browser window ('soft fullscreen').
Here's a live example of the problem (try resizing the browser window):
https://erik-larsen.github.io/emscripten-glut-resizable/hello_world_gles.html
And here's a fix:
https://erik-larsen.github.io/emscripten-glut-resizable/hello_world_gles_resizable.html
The fix detects canvas size changes on redraws and explicitly calls glutReshapeWindow(). This doesn't seem ideal though, as the canvas size check has to be done on every frame, plus this seems like something the GLUT implementation should handle under the hood. As well, the SDL2 implementation does send resize window callbacks under similar circumstances.
I put together a repository for this issue and the workaround fix here:
https://github.com/erik-larsen/emscripten-glut-resizable
-Erik
The text was updated successfully, but these errors were encountered: