Skip to content
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

Add key shortcut to toggle fullscreen/windowed mode #178

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

satoshinm
Copy link
Contributor

Allows toggling fullscreen in-game using "F11". Uses glfwSetWindowMonitor() which is new in glfw 3.2.x, so this PR also includes an update to glfw from 3.1.2 to 3.2.1 (copied from https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip + merged in satoshinm/NetCraft@7e34bdd)

By default, FULLSCREEN mode would use the highest resolution supported
by the monitor. For example, 5120x2880 on 5K displays, however,
according to [1], the NSHighResolutionCapable key is needed to do this.

Since HiDPI is overkill, and complicates application packaging
requirements, instead use the scaled-down resolution. Finding this is
somewhat complicated, requiring creating a window and comparing vs
glfwGetFramebufferSize(), detailed in [2], but getting the scaling
factor is already implemented in Craft in get_scale_factor(). This
function requires a window to get the scale factor of, so create it in
g->window, get the scale factor, then destroy it and recreate with the
smaller window size.

[1] http://www.glfw.org/docs/latest/group__window.html#ga5c336fddf2cbb5b92f65f10fb6043344
[2] http://stackoverflow.com/questions/25230841/how-to-find-display-scaling-factor-on-retina-4k-displays
@satoshinm
Copy link
Contributor Author

Sorry for the size of the diff, but without updating glfw, implementing fullscreen toggle would be much less straightforward (without glfwSetWindowMonitor, the way to do it is destroy and recreate the window...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant