-
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
[Fix] #20600 : Calling GLFW.setWindowSize with the screen size leads to browser error #20699
[Fix] #20600 : Calling GLFW.setWindowSize with the screen size leads to browser error #20699
Conversation
Can you add something to the ChangeLog about this. |
I added the ChangeLog entry as you suggested. Let me know if the language needs to be tweaked. Thank you |
@@ -981,14 +981,9 @@ var LibraryGLFW = { | |||
if (!win) return; | |||
|
|||
if (GLFW.active.id == win.id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the Browser.exitFullscreen();
thing... should explictly setting the windows size also not exit fullscreen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good question. SDL does not do it. glut does it. In my opinion SDL is right. When Browser.requestFullscreen
is called, a fullscreenchange
listener is put in place to detect exiting full screen (the user pressing ESC, or whatever key triggers that).
Calling Browser.exitFullscreen();
might trigger an error for the same reason that Browser.requestFullscreen
can (if the code calls glfwSetWindowSize
while in fullscreen mode but not from a user triggered event).
I believe the proper way for the client code to handle this is to set a Module.onFullScreen
callback which gets called whenever the browser goes in/out of fullscreen and then call glfwSetWindowSize
.
I actually used this technique in my code this morning:
EM_ASM(
{
RAYLIB = {}; // used to store width/height before fullscreen
const cb = Module.requestFullscreen;
Module.requestFullscreen = (pointerLock, resize) => {
const canvas = document.getElementById('canvas');
RAYLIB.screenWidth = canvas.clientWidth;
RAYLIB.screenHeight = canvas.clientHeight;
cb(pointerLock, resize);
};
Module.onFullscreen = Module.cwrap('FullscreenCallback', null, ['boolean']); // called by emscripten
});
void FullscreenCallback(bool isFullscreen) {
if(isFullscreen) {
// ...
}
else {
glfwSetWindowSize(EM_ASM_INT(return RAYLIB.screenWidth;), EM_ASM_INT(return RAYLIB.screenHeight;));
}
}
That being said, if you prefer to leave it, I believe the chances of getting an error are lower and probably have less consequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think being consistent with SDL and glut makes more sense.
Not being lucky with failing tests this morning :(
|
As pointed out in the discussion about this issue, it is very odd that
glfwSetWindowSize
automatically triggers a fullscreen when the size parameters happen to be the exact size of the screen. When invoking it via code, this triggers the error in browsers because it is not a user event.If the client code wants to go fullscreen, it should simply call
Module.requestFullscreen
which is made available to theModule
when theBrowser
library is initialized.Neither
library_sdl.js
norlibrary_glut.js
implement such a behavior.