Skip to content

Commit

Permalink
Remove Exclusive Fullscreen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Dec 23, 2024
1 parent f60a786 commit d4aec2b
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 108 deletions.
2 changes: 1 addition & 1 deletion source_files/edge/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define EDGE_DEFAULT_SCREENWIDTH (1000000) // Super high number to force scaling to native res
#define EDGE_DEFAULT_SCREENHEIGHT (1000000) // Super high number to force scaling to native res
#define EDGE_DEFAULT_SCREENBITS (32)
#define EDGE_DEFAULT_DISPLAYMODE (2)
#define EDGE_DEFAULT_DISPLAYMODE (1)

// Controls (Key/Mouse Buttons)
#define EDGE_DEFAULT_KEY_FIRE (kMouse1 + (kGamepadTriggerRight << 16))
Expand Down
15 changes: 8 additions & 7 deletions source_files/edge/e_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,18 @@ static void SetGlobalVariables(void)
std::string s;

// Screen Resolution Check...
// borderless and fullscreen are synonymous now - Dasho
if (FindArgument("borderless") > 0)
current_window_mode = 2;
current_window_mode = kWindowModeBorderless;
else if (FindArgument("fullscreen") > 0)
current_window_mode = 1;
current_window_mode = kWindowModeBorderless;
else if (FindArgument("windowed") > 0)
current_window_mode = 0;
current_window_mode = kWindowModeWindowed;

s = ArgumentValue("width");
if (!s.empty())
{
if (current_window_mode == 2)
if (current_window_mode == kWindowModeBorderless)
LogWarning("Current display mode set to borderless fullscreen. Provided "
"width of %d will be ignored!\n",
atoi(s.c_str()));
Expand All @@ -366,7 +367,7 @@ static void SetGlobalVariables(void)
s = ArgumentValue("height");
if (!s.empty())
{
if (current_window_mode == 2)
if (current_window_mode == kWindowModeBorderless)
LogWarning("Current display mode set to borderless fullscreen. Provided "
"height of %d will be ignored!\n",
atoi(s.c_str()));
Expand All @@ -377,7 +378,7 @@ static void SetGlobalVariables(void)
p = FindArgument("res");
if (p > 0 && p + 2 < int(program_argument_list.size()) && !ArgumentIsOption(p + 1) && !ArgumentIsOption(p + 2))
{
if (current_window_mode == 2)
if (current_window_mode == kWindowModeBorderless)
LogWarning("Current display mode set to borderless fullscreen. Provided "
"resolution of %dx%d will be ignored!\n",
atoi(program_argument_list[p + 1].c_str()), atoi(program_argument_list[p + 2].c_str()));
Expand Down Expand Up @@ -406,7 +407,7 @@ static void SetGlobalVariables(void)

// If borderless fullscreen mode, override any provided dimensions so
// StartupGraphics will scale to native res
if (current_window_mode == 2)
if (current_window_mode == kWindowModeBorderless)
{
current_screen_width = 100000;
current_screen_height = 100000;
Expand Down
2 changes: 1 addition & 1 deletion source_files/edge/i_ctrl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ void ActiveEventProcess(SDL_Event *sdl_ev)
current_screen_width = sdl_ev->window.data1;
current_screen_height = sdl_ev->window.data2;
current_screen_depth = 24;
current_window_mode = 0;
current_window_mode = kWindowModeWindowed;
DeterminePixelAspect();
}
#endif
Expand Down
55 changes: 5 additions & 50 deletions source_files/edge/i_video.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void DeterminePixelAspect()
// will have square pixels (1:1 aspect).
bool is_crt = (desktop_resolution_width.d_ < desktop_resolution_height.d_ * 7 / 5);

bool is_fullscreen = (current_window_mode > 0);
bool is_fullscreen = (current_window_mode == kWindowModeBorderless);
if (is_fullscreen && current_screen_width == desktop_resolution_width.d_ &&
current_screen_height == desktop_resolution_height.d_ && graphics_shutdown)
is_fullscreen = false;
Expand Down Expand Up @@ -193,30 +193,21 @@ void StartupGraphics(void)
SDL_DisplayMode possible_mode;
SDL_GetDisplayMode(0, i, &possible_mode);

if (possible_mode.w > desktop_resolution_width.d_ || possible_mode.h > desktop_resolution_height.d_)
if (possible_mode.w >= desktop_resolution_width.d_ || possible_mode.h >= desktop_resolution_height.d_)
continue;

DisplayMode test_mode;

test_mode.width = possible_mode.w;
test_mode.height = possible_mode.h;
test_mode.depth = SDL_BITSPERPIXEL(possible_mode.format);
test_mode.window_mode = kWindowModeFullscreen;
test_mode.window_mode = kWindowModeWindowed;

if ((test_mode.width & 15) != 0)
continue;

if (test_mode.depth == 15 || test_mode.depth == 16 || test_mode.depth == 24 || test_mode.depth == 32)
{
AddDisplayResolution(&test_mode);

if (test_mode.width < desktop_resolution_width.d_ && test_mode.height < desktop_resolution_height.d_)
{
DisplayMode win_mode = test_mode;
win_mode.window_mode = kWindowModeWindowed;
AddDisplayResolution(&win_mode);
}
}
}

// If needed, set the default window toggle mode to the largest non-native
Expand All @@ -243,15 +234,6 @@ void StartupGraphics(void)
borderless_mode.height = info.h;
borderless_mode.depth = SDL_BITSPERPIXEL(info.format);

// If needed, also make the default fullscreen toggle mode borderless
if (toggle_fullscreen_window_mode.d_ == kWindowModeInvalid)
{
toggle_fullscreen_window_mode = kWindowModeBorderless;
toggle_fullscreen_width = info.w;
toggle_fullscreen_height = info.h;
toggle_fullscreen_depth = (int)SDL_BITSPERPIXEL(info.format);
}

LogPrint("StartupGraphics: initialisation OK\n");
}

Expand All @@ -271,7 +253,7 @@ static bool InitializeWindow(DisplayMode *mode)
SDL_WINDOW_OPENGL |
(mode->window_mode == kWindowModeBorderless
? (SDL_WINDOW_FULLSCREEN_DESKTOP)
: (mode->window_mode == kWindowModeFullscreen ? SDL_WINDOW_FULLSCREEN : 0)) |
: (0)) |
resizeable);

if (program_window == nullptr)
Expand All @@ -290,20 +272,6 @@ static bool InitializeWindow(DisplayMode *mode)
toggle_windowed_width = mode->width;
toggle_windowed_window_mode = kWindowModeWindowed;
}
else if (mode->window_mode == kWindowModeFullscreen)
{
toggle_fullscreen_depth = mode->depth;
toggle_fullscreen_height = mode->height;
toggle_fullscreen_width = mode->width;
toggle_fullscreen_window_mode = kWindowModeFullscreen;
}
else
{
toggle_fullscreen_depth = borderless_mode.depth;
toggle_fullscreen_height = borderless_mode.height;
toggle_fullscreen_width = borderless_mode.width;
toggle_fullscreen_window_mode = kWindowModeBorderless;
}

if (SDL_GL_CreateContext(program_window) == nullptr)
FatalError("Failed to create OpenGL context.\n");
Expand Down Expand Up @@ -337,7 +305,7 @@ bool SetScreenSize(DisplayMode *mode)
LogPrint("SetScreenSize: trying %dx%d %dbpp (%s)\n", mode->width, mode->height, mode->depth,
mode->window_mode == kWindowModeBorderless
? "borderless"
: (mode->window_mode == kWindowModeFullscreen ? "fullscreen" : "windowed"));
: "windowed");

if (program_window == nullptr)
{
Expand All @@ -353,19 +321,6 @@ bool SetScreenSize(DisplayMode *mode)

LogPrint("SetScreenSize: mode now %dx%d %dbpp\n", mode->width, mode->height, mode->depth);
}
else if (mode->window_mode == kWindowModeFullscreen)
{
SDL_SetWindowFullscreen(program_window, SDL_WINDOW_FULLSCREEN);
SDL_DisplayMode *new_mode = new SDL_DisplayMode;
new_mode->h = mode->height;
new_mode->w = mode->width;
SDL_SetWindowDisplayMode(program_window, new_mode);
SDL_SetWindowSize(program_window, mode->width, mode->height);
delete new_mode;
new_mode = nullptr;

LogPrint("SetScreenSize: mode now %dx%d %dbpp\n", mode->width, mode->height, mode->depth);
}
else /* kWindowModeWindowed */
{
SDL_SetWindowFullscreen(program_window, 0);
Expand Down
2 changes: 1 addition & 1 deletion source_files/edge/i_web.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void WebSyncScreenSize(int width, int height)
current_screen_width = (int)width;
current_screen_height = (int)height;
current_screen_depth = 24;
current_window_mode = 0;
current_window_mode = kWindowModeWindowed;
DeterminePixelAspect();

SoftInitializeResolution();
Expand Down
30 changes: 11 additions & 19 deletions source_files/edge/m_option.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ void OptionMenuDrawer()

if (current_menu == &res_optmenu && current_menu->items[i].routine == OptionMenuChangeResSize)
{
if (new_window_mode.window_mode == 2)
if (new_window_mode.window_mode == kWindowModeBorderless)
{
curry += deltay;
continue;
Expand Down Expand Up @@ -1235,12 +1235,12 @@ static void OptionMenuResOptDrawer(Style *style, int topy, int bottomy, int dy,
float TEXTscale = style->definition_->text_[fontType].scale_;

stbsp_sprintf(tempstring, "%s",
new_window_mode.window_mode == 2
new_window_mode.window_mode == kWindowModeBorderless
? "Borderless Fullscreen"
: (new_window_mode.window_mode == kWindowModeFullscreen ? "Exclusive Fullscreen" : "Windowed"));
: "Windowed");
HUDWriteText(style, fontType, centrex + 15, y, tempstring);

if (new_window_mode.window_mode < 2)
if (new_window_mode.window_mode == kWindowModeWindowed)
{
y += dy;
stbsp_sprintf(tempstring, "%dx%d", new_window_mode.width, new_window_mode.height);
Expand All @@ -1262,11 +1262,10 @@ static void OptionMenuResOptDrawer(Style *style, int topy, int bottomy, int dy,

y += dy;
y += 5;
if (current_window_mode == 2)
if (current_window_mode == kWindowModeBorderless)
stbsp_sprintf(tempstring, "%s", "Borderless Fullscreen");
else
stbsp_sprintf(tempstring, "%d x %d %s", current_screen_width, current_screen_height,
current_window_mode == 1 ? "Exclusive Fullscreen" : "Windowed");
stbsp_sprintf(tempstring, "%d x %d %s", current_screen_width, current_screen_height, "Windowed");

HUDWriteText(style, fontType, 160 - (style->fonts_[fontType]->StringWidth(tempstring) * TEXTscale / 2), y,
tempstring);
Expand Down Expand Up @@ -1375,7 +1374,7 @@ bool OptionMenuResponder(InputEvent *ev, int ch)
do
{
current_menu->pos++;
if (current_menu == &res_optmenu && new_window_mode.window_mode == 2)
if (current_menu == &res_optmenu && new_window_mode.window_mode == kWindowModeBorderless)
{
if (current_menu->pos >= 0 && current_menu->pos < current_menu->item_number)
{
Expand All @@ -1396,7 +1395,7 @@ bool OptionMenuResponder(InputEvent *ev, int ch)
do
{
current_menu->pos++;
if (current_menu == &res_optmenu && new_window_mode.window_mode == 2)
if (current_menu == &res_optmenu && new_window_mode.window_mode == kWindowModeBorderless)
{
if (current_menu->pos >= 0 && current_menu->pos < current_menu->item_number)
{
Expand Down Expand Up @@ -1426,7 +1425,7 @@ bool OptionMenuResponder(InputEvent *ev, int ch)
do
{
current_menu->pos--;
if (current_menu == &res_optmenu && new_window_mode.window_mode == 2)
if (current_menu == &res_optmenu && new_window_mode.window_mode == kWindowModeBorderless)
{
if (current_menu->pos >= 0 && current_menu->pos < current_menu->item_number)
{
Expand All @@ -1447,7 +1446,7 @@ bool OptionMenuResponder(InputEvent *ev, int ch)
do
{
current_menu->pos--;
if (current_menu == &res_optmenu && new_window_mode.window_mode == 2)
if (current_menu == &res_optmenu && new_window_mode.window_mode == kWindowModeBorderless)
{
if (current_menu->pos >= 0 && current_menu->pos < current_menu->item_number)
{
Expand Down Expand Up @@ -2132,14 +2131,7 @@ static void OptionMenuionSetResolution(int key_pressed, ConsoleVariable *console
{
if (ChangeResolution(&new_window_mode))
{
if (new_window_mode.window_mode > kWindowModeWindowed)
{
toggle_fullscreen_depth = new_window_mode.depth;
toggle_fullscreen_height = new_window_mode.height;
toggle_fullscreen_width = new_window_mode.width;
toggle_fullscreen_window_mode = new_window_mode.window_mode;
}
else
if (new_window_mode.window_mode == kWindowModeWindowed)
{
toggle_windowed_depth = new_window_mode.depth;
toggle_windowed_height = new_window_mode.height;
Expand Down
34 changes: 12 additions & 22 deletions source_files/edge/r_modes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@
int current_screen_width;
int current_screen_height;
int current_screen_depth;
int current_window_mode;
WindowMode current_window_mode;

DisplayMode borderless_mode;
EDGE_DEFINE_CONSOLE_VARIABLE(toggle_fullscreen_width, "0", kConsoleVariableFlagArchive)
EDGE_DEFINE_CONSOLE_VARIABLE(toggle_fullscreen_height, "0", kConsoleVariableFlagArchive)
EDGE_DEFINE_CONSOLE_VARIABLE(toggle_fullscreen_depth, "0", kConsoleVariableFlagArchive)
EDGE_DEFINE_CONSOLE_VARIABLE(toggle_fullscreen_window_mode, "-1", kConsoleVariableFlagArchive)
EDGE_DEFINE_CONSOLE_VARIABLE(toggle_windowed_width, "0", kConsoleVariableFlagArchive)
EDGE_DEFINE_CONSOLE_VARIABLE(toggle_windowed_height, "0", kConsoleVariableFlagArchive)
EDGE_DEFINE_CONSOLE_VARIABLE(toggle_windowed_depth, "0", kConsoleVariableFlagArchive)
Expand Down Expand Up @@ -135,7 +131,7 @@ void DumpResolutionList(void)
LogPrint(" %4dx%4d @ %02d %s", cur->width, cur->height, cur->depth,
cur->window_mode == kWindowModeBorderless
? "BL"
: (cur->window_mode == kWindowModeFullscreen ? "FS " : "win"));
: "win");
}

LogPrint("\n");
Expand All @@ -160,17 +156,17 @@ bool IncrementResolution(DisplayMode *mode, int what, int dir)
if (what == kIncrementWindowMode)
{
if (dir == 1)
window_mode = (window_mode + 1) % 3;
window_mode = (window_mode + 1) % 2;
else
{
if (window_mode > 0)
if (window_mode == kWindowModeBorderless)
window_mode--;
else
window_mode = 2;
window_mode = kWindowModeBorderless;
}
}

if (window_mode == 2)
if (window_mode == kWindowModeBorderless)
{
mode->width = borderless_mode.width;
mode->height = borderless_mode.height;
Expand Down Expand Up @@ -239,10 +235,10 @@ void ToggleFullscreen(void)
}
else
{
toggle.depth = toggle_fullscreen_depth.d_;
toggle.height = toggle_fullscreen_height.d_;
toggle.width = toggle_fullscreen_width.d_;
toggle.window_mode = toggle_fullscreen_window_mode.d_;
toggle.depth = borderless_mode.depth;
toggle.height = borderless_mode.height;
toggle.width = borderless_mode.width;
toggle.window_mode = kWindowModeBorderless;
ChangeResolution(&toggle);
}
SoftInitializeResolution();
Expand Down Expand Up @@ -299,12 +295,6 @@ static bool DoExecuteChangeResolution(DisplayMode *mode)

DeterminePixelAspect();

LogPrint("Pixel aspect: %1.3f\n", pixel_aspect_ratio.f_);

// gfx card doesn't like to switch too rapidly
SleepForMilliseconds(250);
SleepForMilliseconds(250);

return true;
}

Expand Down Expand Up @@ -346,7 +336,7 @@ void SetInitialResolution(void)
{
LogDebug("SetInitialResolution...\n");

if (current_window_mode == 2)
if (current_window_mode == kWindowModeBorderless)
{
if (DoExecuteChangeResolution(&borderless_mode))
return;
Expand Down Expand Up @@ -387,7 +377,7 @@ bool ChangeResolution(DisplayMode *mode)
{
LogDebug("ChangeResolution...\n");

if (DoExecuteChangeResolution(mode->window_mode == 2 ? &borderless_mode : mode))
if (DoExecuteChangeResolution(mode->window_mode == kWindowModeBorderless ? &borderless_mode : mode))
return true;

LogDebug("- Failed : switching back...\n");
Expand Down
Loading

0 comments on commit d4aec2b

Please sign in to comment.