From 9a82d2a956efafe7c42790a64d9242689b3b8ad6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 03:01:50 +0100 Subject: [PATCH] Create win32_monitor_set_fullscreen --- gfx/common/win32_common.cpp | 17 +++++++++++++++++ gfx/common/win32_common.h | 3 +++ gfx/d3d/d3d.cpp | 3 ++- gfx/drivers_context/wgl_ctx.cpp | 18 +----------------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index fe40272a61..cb34e23d02 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -478,6 +478,23 @@ void win32_monitor_init(void) g_quit = false; } +bool win32_monitor_set_fullscreen(unsigned width, unsigned height, unsigned refresh, char *dev_name) +{ +#ifndef _XBOX + DEVMODE devmode; + + memset(&devmode, 0, sizeof(devmode)); + devmode.dmSize = sizeof(DEVMODE); + devmode.dmPelsWidth = width; + devmode.dmPelsHeight = height; + devmode.dmDisplayFrequency = refresh; + devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; + + RARCH_LOG("[WGL]: Setting fullscreen to %ux%u @ %uHz on device %s.\n", width, height, refresh, dev_name); + return ChangeDisplaySettingsEx(dev_name, &devmode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL; +#endif +} + void win32_show_cursor(bool state) { #ifndef _XBOX diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index ce500f4c0d..cd70aa8c3f 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -53,6 +53,9 @@ void create_gl_context(HWND hwnd); void win32_monitor_init(void); +bool win32_monitor_set_fullscreen(unsigned width, + unsigned height, unsigned refresh, char *dev_name); + bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); bool win32_window_create(void *data, unsigned style, diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 1abfe57cbe..33714e3613 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -649,7 +649,8 @@ static bool d3d_construct(d3d_video_t *d3d, { style = WS_POPUP | WS_VISIBLE; - if (!set_fullscreen(win_width, win_height, refresh, current_mon.szDevice)) + if (!win32_monitor_set_fullscreen(win_width, win_height, + refresh, current_mon.szDevice)) {} /* Display settings might have changed, get new coordinates. */ diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index da96d4b306..f86260f16e 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -322,22 +322,6 @@ static bool gfx_ctx_wgl_init(void *data) return true; } -static bool set_fullscreen(unsigned width, unsigned height, unsigned refresh, char *dev_name) -{ - DEVMODE devmode; - - memset(&devmode, 0, sizeof(devmode)); - devmode.dmSize = sizeof(DEVMODE); - devmode.dmPelsWidth = width; - devmode.dmPelsHeight = height; - devmode.dmDisplayFrequency = refresh; - devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; - - RARCH_LOG("[WGL]: Setting fullscreen to %ux%u @ %uHz on device %s.\n", width, height, refresh, dev_name); - return ChangeDisplaySettingsEx(dev_name, &devmode, NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL; -} - - static bool gfx_ctx_wgl_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen) @@ -382,7 +366,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, { style = WS_POPUP | WS_VISIBLE; - if (!set_fullscreen(width, height, refresh, current_mon.szDevice)) + if (!win32_monitor_set_fullscreen(width, height, refresh, current_mon.szDevice)) goto error; /* Display settings might have changed, get new coordinates. */