This is a good feature request, thanks! I've implemented new fields to EmscriptenFullscreenChangeEvent structure that report the pixel sizes of the target element and the pixel size of the whole screen in the event handler. See this pull request: https://github.com/kripken/emscripten/pull/2165 .
Note that the behavior when transitioning to fullscreen differs between Chrome and Firefox. In Firefox, the target element will be strecthed to fill the whole screen, so elementWidth and elementHeight field will report the pixel size of the screen. This can kill your aspect ratio. In Chrome, the target element is not resized at all, but it is simply centered in the screen, adding a black background. I dislike adding a 'default' behavior here in the emscripten html5.h events callbacks, since the way that the application wants to handle fullscreen can differ: - some applications might like to resize the pixel size of the canvas to match the pixel size of the whole screen. You can do that in the event handler via emscripten_get_canvas_size and emscripten_set_canvas_size and examining the new fields in the callback. - some applications might like to keep rendering to a smaller canvas window, upscaling the image to cover the whole screen. This can be done by adjusting the CSS stylesheets of the canvas after going fullscreen. - some applications might want to make a whole <div> fullscreen, which contains the canvas and perhaps some other HTML elements. These complex situations will definitely use a custom fullscreen resizing logic. Therefore I think it's best to avoid defaulting to any logic that might interfere or assume things that users might not want to happen, and instead expose the appropriate fields and C functions so that users can write the logic as they want in the fullscreen change callbacks. Joel, let me know if that PR gives you what you're looking for? Jukka 2014-02-26 5:50 GMT+02:00 Joel Croteau <[email protected]>: > I'm referring to the callbacks from emscripten_set_resize_callback and > emscripten_set_fullscreenchange_callback as declared in > system/include/emscripten/html5.h. Those functions do I believe add > listeners to those events you mentioned. > > > On Tuesday, February 25, 2014 6:26:55 PM UTC-8, msc wrote: >> >> On 2014/02/26 6:23, Joel Croteau wrote: >> >> Is there a good way to get the screen resolution when switching to full >> screen? Calling emscripten_get_canvas_size from either the resize or >> fullscreenchange callbacks seems to return the canvas size from before >> going full screen. >> >> I don't know what resize or fullscreenchange callbacks you are referring >> to. >> >> What I found is that you need to add you application's resize handler >> function to Browser.resizeListeners. These are called (by the default >> Emscripten HTML shell & JS) after the canvas has been resized. >> Canvas.eventListeners are called when the canvas CSS size (clientWidth, >> clientHeight) changes but before the canvas size (width, height) has been >> changed. >> >> I guess emscripten_get_canvas_size returns canvas.width and canvas.height. >> >> Regards >> >> -Mark >> -- >> 注意:この電子メールには、株式会社エイチアイの機密情報が含まれている場合が有ります。正式なメール受信者では無い場合はメール複製、 >> 再配信または情報の使用を固く禁じております。エラー、手違いでこのメールを受け取られましたら削除を行い配信者にご連絡をお願いいたし ます. >> >> NOTE: This electronic mail message may contain confidential and >> privileged information from HI Corporation. If you are not the intended >> recipient, any disclosure, photocopying, distribution or use of the >> contents of the received information is prohibited. If you have received >> this e-mail in error, please notify the sender immediately and permanently >> delete this message and all related copies. >> > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
