commit 075ca5a7617457cb189fcd5ba071dc38b9067582
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Tue May 31 23:27:44 2016 +0100
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Tue May 31 23:27:44 2016 +0100
video: Add a back door for non-desktop fullscreen.
There are some circumstances where it may be useful to be able to
specify plain SDL_WINDOW_FULLSCREEN rather than the "desktop window"
variant. Examples are for embedded devices. Implement this as two
new separate config file variables, but default them to 0x0 to mean
"use SDL_WINDOW_FULLSCREEN_DESKTOP".
---
src/i_video.c | 36 ++++++++++++++++++++++++++++++++----
src/m_config.c | 15 +++++++++++++++
src/setup/display.c | 6 ++++--
3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/src/i_video.c b/src/i_video.c
index 345f775d..7c986023 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -112,6 +112,10 @@ int diskicon_readbytes = 0;
int window_width = SCREENWIDTH * 2;
int window_height = SCREENHEIGHT_4_3 * 2;
+// Fullscreen mode, 0x0 for SDL_WINDOW_FULLSCREEN_DESKTOP.
+
+int fullscreen_width = 0, fullscreen_height = 0;
+
// Run in full screen mode? (int type for config code)
int fullscreen = true;
@@ -370,12 +374,21 @@ static void I_ToggleFullScreen(void)
{
unsigned int flags = 0;
+ // TODO: Consider implementing fullscreen toggle for SDL_WINDOW_FULLSCREEN
+ // (mode-changing) setup. This is hard because we have to shut down and
+ // restart again.
+ if (fullscreen_width != 0 || fullscreen_height != 0)
+ {
+ return;
+ }
+
fullscreen = !fullscreen;
if (fullscreen)
{
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
+
SDL_SetWindowFullscreen(screen, flags);
if (!fullscreen)
@@ -1005,6 +1018,7 @@ static void SetWindowPositionVars(void)
static void SetVideoMode(void)
{
byte *doompal;
+ int w, h;
int flags = 0;
doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE);
@@ -1026,6 +1040,9 @@ static void SetVideoMode(void)
screen = NULL;
}
+ w = window_width;
+ h = window_height;
+
// In windowed mode, the window can be resized while the game is
// running.
flags = SDL_WINDOW_RESIZABLE;
@@ -1036,9 +1053,18 @@ static void SetVideoMode(void)
if (fullscreen)
{
- // This flags means "Never change the screen resolution! Instead,
- // draw to the entire screen by scaling the texture appropriately".
- flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ if (fullscreen_width == 0 && fullscreen_height == 0)
+ {
+ // This flags means "Never change the screen resolution! Instead,
+ // draw to the entire screen by scaling the texture appropriately".
+ flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ }
+ else
+ {
+ w = fullscreen_width;
+ h = fullscreen_height;
+ flags |= SDL_WINDOW_FULLSCREEN;
+ }
}
// Create window and renderer contexts. We set the window title
@@ -1047,7 +1073,7 @@ static void SetVideoMode(void)
screen = SDL_CreateWindow(NULL,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
- window_width, window_height, flags);
+ w, h, flags);
if (screen == NULL)
{
@@ -1215,6 +1241,8 @@ void I_BindVideoVariables(void)
M_BindIntVariable("fullscreen", &fullscreen);
M_BindIntVariable("aspect_ratio_correct", &aspect_ratio_correct);
M_BindIntVariable("startup_delay", &startup_delay);
+ M_BindIntVariable("fullscreen_width", &fullscreen_width);
+ M_BindIntVariable("fullscreen_height", &fullscreen_height);
M_BindIntVariable("window_width", &window_width);
M_BindIntVariable("window_height", &window_height);
M_BindIntVariable("grabmouse", &grabmouse);
diff --git a/src/m_config.c b/src/m_config.c
index f82f8c50..3d52c085 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -731,6 +731,21 @@ static default_t extra_defaults_list[] =
CONFIG_VARIABLE_INT(window_height),
+ //!
+ // Width for screen mode when running fullscreen.
+ // If this and fullscreen_height are both set to zero, we run
+ // fullscreen as a desktop window that covers the entire screen,
+ // rather than ever switching screen modes. It should usually
+ // be unnecessary to set this value.
+ //
+ CONFIG_VARIABLE_INT(fullscreen_width),
+
+ //!
+ // Height for screen mode when running fullscreen.
+ // See documentation for fullscreen_width.
+ //
+ CONFIG_VARIABLE_INT(fullscreen_height),
+
//!
// If this is non-zero, the mouse will be "grabbed" when running
// in windowed mode so that it can be used as an input device.
diff --git a/src/setup/display.c b/src/setup/display.c
index ade4a7da..95807e99 100644
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -71,8 +71,8 @@ static char *video_driver = "";
static char *window_position = "";
static int aspect_ratio_correct = 1;
static int fullscreen = 1;
-static int window_width = 640;
-static int window_height = 480;
+static int fullscreen_width = 0, fullscreen_height = 0;
+static int window_width = 640, window_height = 480;
static int startup_delay = 1000;
static int usegamma = 0;
@@ -341,6 +341,8 @@ void BindDisplayVariables(void)
{
M_BindIntVariable("aspect_ratio_correct", &aspect_ratio_correct);
M_BindIntVariable("fullscreen", &fullscreen);
+ M_BindIntVariable("fullscreen_width", &fullscreen_width);
+ M_BindIntVariable("fullscreen_height", &fullscreen_height);
M_BindIntVariable("window_width", &window_width);
M_BindIntVariable("window_height", &window_height);
M_BindIntVariable("startup_delay", &startup_delay);