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

toggle_fullscreen rather than destroy/create #1665

Open
Beuc opened this Issue Dec 13, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@Beuc
Copy link
Contributor

Beuc commented Dec 13, 2018

Toggling full-screen in renpyweb faces a few difficulties:

  • exiting full-screen may be triggered by the user directly from the browser (by pressing Escape); Ren'Py will get a resize event but will need to detect whether it's still full-screen; typically it cannot cache the full-screen status in renpy.game.preferences.fullscreen.
  • triggering full-screen needs to be linked with a user event, which means it needs to be acted on in the same frame as the user input.
  • apparently no resize events when destroying/recreating the graphic context followed by automatically CSS-stretched HTML canvas, causing the final display to lose its aspect ratio when entering or exiting full-screen.

To help address this it would make sense to rely on pygame_sdl2.display.toggle_fullscreen, either from Ren'Py or by detecting that in pygame_sdl2.display.set_mode (similar to the resize detection).
Unless there's was reason to explicitly destroying and re-creating the graphic context?

@renpytom

This comment has been minimized.

Copy link
Member

renpytom commented Dec 14, 2018

Hm...

My memory is that toggle_fullscreen simply didn't work when it came to DirectX on windows, which is why Ren'Py just recreates the context when switching.

I'm not sure what you mean by "acted on in the same frame as the user input", as Ren'Py doesn't have the context for frames.

In general, shouldn't SDL just be providing Ren'Py with the same information about the fullscreen modes it does on other platforms?

@Beuc

This comment has been minimized.

Copy link
Contributor

Beuc commented Dec 14, 2018

frame -> graphical frame (time slot before giving control back to browser and triggering a screen refresh)

It's not about screen modes, it's about entering/exiting full-screen.
With in particular for this platform, the case where exiting full-screen can be handled by the browser and not by Ren'Py (SDL2 handles it but Ren'Py can't cache the full-screen status since it's not the only one controlling it).

Is the SDL/DirectX bug with full-screen toggle recent?

@renpytom

This comment has been minimized.

Copy link
Member

renpytom commented Dec 14, 2018

No, it's an old one - and I think it's more on the DirectX side than in SDL itself. Ren'Py doesn't take advantage of SDL too much when it's using the DirectX mode - it just gets the window handle and passes it to angle.

I guess it probably makes sense to just wrap SDL_GetWindowDisplayMode and use that to determine if the window is fullscreen or not.

@Beuc

This comment has been minimized.

Copy link
Contributor

Beuc commented Dec 14, 2018

What I mean is: is this destroy/recreate work-around still needed, because it otherwise makes things buggier on the web platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment