From f8459dfd65a3b8aa0457c45516ace2db51d2845f Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Sun, 19 Oct 2014 00:38:36 -0700 Subject: allow -geometry to specify fullscreen or windowed modes, like PrBoom This allows strings like "640x480w" to cause the engine to run in a window, while strings like "1280x800f" cause the engine to run in fullscreen mode. This is inspired by the behavior of the PrBoom -geometry parameter. --- src/i_video.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/i_video.c b/src/i_video.c index b410a096..b7175db3 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1691,21 +1691,33 @@ void I_GraphicsCheckCommandLine(void) //! // @category video - // @arg + // @arg [wf] // - // Specify the screen mode (when running fullscreen) or the window - // dimensions (when running in windowed mode). + // Specify the dimensions of the window or fullscreen mode. An + // optional letter of w or f appended to the dimensions selects + // windowed or fullscreen mode. i = M_CheckParmWithArgs("-geometry", 1); if (i > 0) { - int w, h; + int w, h, s; + char f; - if (sscanf(myargv[i + 1], "%ix%i", &w, &h) == 2) + s = sscanf(myargv[i + 1], "%ix%i%1c", &w, &h, &f); + if (s == 2 || s == 3) { screen_width = w; screen_height = h; + + if (s == 3 && f == 'f') + { + fullscreen = true; + } + else if (f == 'w') + { + fullscreen = false; + } } } -- cgit v1.2.3 From d88369c62e20083d42befda7e9ec9e1eac61ba71 Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Sun, 19 Oct 2014 12:48:02 -0700 Subject: i_video: fix an if condition in my previous commit `else if (f == 'w')` doesn't really secure itself against uninitialized memory, it still needs to test that `s == 3`. --- src/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i_video.c b/src/i_video.c index b7175db3..242f3ac5 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1714,7 +1714,7 @@ void I_GraphicsCheckCommandLine(void) { fullscreen = true; } - else if (f == 'w') + else if (s == 3 && f == 'w') { fullscreen = false; } -- cgit v1.2.3