-
Notifications
You must be signed in to change notification settings - Fork 13
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
Keystroke to enter fullscreen mode (F11) #9
Comments
Fullscreen tests: https://github.com/kripken/emscripten/blob/master/tests/test_html5_fullscreen.c - likely want "stretch" mode. And the "soft fullscreen" ('canvas maximized in the client area of the page') could be a worthwhile default, removing the other widgets in the default shell, delegating for example console output to the browser debugging console (but important to retain downloading/running/etc progress indicators until the emscripten code executes). However, this demo/test is using emscripten_request_fullscreen(). Is there another API (SDL_SetWindowFullscreen?) working on both native and web? |
Craft does have code to enter fullscreen natively, but it's a compile-time constant: src/config.h:
#define FULLSCREEN 0
src/main.c:
void create_window() {
int window_width = WINDOW_WIDTH;
int window_height = WINDOW_HEIGHT;
GLFWmonitor *monitor = NULL;
if (FULLSCREEN) {
int mode_count;
monitor = glfwGetPrimaryMonitor();
const GLFWvidmode *modes = glfwGetVideoModes(monitor, &mode_count);
window_width = modes[mode_count - 1].width;
window_height = modes[mode_count - 1].height;
}
g->window = glfwCreateWindow(
window_width, window_height, "Craft", monitor, NULL); http://stackoverflow.com/questions/10253283/glfw-toggling-windowed-fullscreen-mode says "As far as I know you would have to close and reopen this window to switch between a window and fullscreen mode.", so could try resetting |
Testing with http://stackoverflow.com/questions/10253283/glfw-toggling-windowed-fullscreen-mode#10675990 has a good tip, using glfwGetDesktopMode() to query for the current resolution and avoid changing it. However, the other comment refers to glfwOpenWindow (and GLFW_FULLSCREEN), which has been replaced with glfwCreateWindow (and window hints). And glfwGetDesktopMode() replaced by glfwGetVideoMode(): http://www.glfw.org/docs/latest/group__monitor.html http://www.glfw.org/docs/latest/group__window.html#ga5c336fddf2cbb5b92f65f10fb6043344
There are 20 video modes returned by glfwGetVideoMode() at least on my system, and Craft picks the last, highest-resolution: 0: 640 x 480 5120x2880 is way too high (high-DPI), /2 = 15: 2560x1440 is more reasonable, and changing it manually works -- the game launches fullscreen and is playable. Now the question becomes, how to choose this automatically? There is no "scale factor" in http://www.glfw.org/docs/latest/structGLFWvidmode.html#details and width/height are all in screen coordinates. glfwGetFramebufferSize can be used to get the size in pixels, not screen coordinates, but it is called on a window. rougier/freetype-gl#91 (comment) says the correct way to fix this could be:
-- Craft has get_scale_factor(), using these glfw calls, but it only operates on an existing window. Create the window naively, then get the scale factor and if not 1, scale it down by said factor? update: did this in 13b538d - works now with |
A handy keyboard shortcut to enter into the fullscreen mode. Should work at least on the web version, ideally also native (similar to clicking the maximize button).
Web fullscreen API: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
The text was updated successfully, but these errors were encountered: