Create win32_set_video_mode
This commit is contained in:
parent
d3efdf8e5a
commit
105236a543
|
@ -569,3 +569,103 @@ bool win32_suppress_screensaver(void *data, bool enable)
|
|||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool win32_set_video_mode(void *data,
|
||||
unsigned width, unsigned height,
|
||||
bool fullscreen)
|
||||
{
|
||||
#ifndef _XBOX
|
||||
DWORD style;
|
||||
MSG msg;
|
||||
RECT mon_rect;
|
||||
unsigned mon_id;
|
||||
MONITORINFOEX current_mon;
|
||||
float refresh_mod;
|
||||
unsigned refresh;
|
||||
bool windowed_full;
|
||||
RECT rect = {0};
|
||||
HMONITOR hm_to_use = NULL;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
win32_monitor_info(¤t_mon, &hm_to_use, &mon_id);
|
||||
|
||||
mon_rect = current_mon.rcMonitor;
|
||||
g_resize_width = width;
|
||||
g_resize_height = height;
|
||||
|
||||
/* Windows only reports the refresh rates for modelines as
|
||||
* an integer, so video.refresh_rate needs to be rounded. Also, account
|
||||
* for black frame insertion using video.refresh_rate set to half
|
||||
* of the display refresh rate, as well as higher vsync swap intervals. */
|
||||
refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f;
|
||||
refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval);
|
||||
|
||||
windowed_full = settings->video.windowed_fullscreen;
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
if (windowed_full)
|
||||
{
|
||||
style = WS_EX_TOPMOST | WS_POPUP;
|
||||
g_resize_width = width = mon_rect.right - mon_rect.left;
|
||||
g_resize_height = height = mon_rect.bottom - mon_rect.top;
|
||||
}
|
||||
else
|
||||
{
|
||||
style = WS_POPUP | WS_VISIBLE;
|
||||
|
||||
if (!win32_monitor_set_fullscreen(width, height, refresh, current_mon.szDevice))
|
||||
goto error;
|
||||
|
||||
/* Display settings might have changed, get new coordinates. */
|
||||
GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon);
|
||||
mon_rect = current_mon.rcMonitor;
|
||||
g_restore_desktop = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
||||
rect.right = width;
|
||||
rect.bottom = height;
|
||||
AdjustWindowRect(&rect, style, FALSE);
|
||||
g_resize_width = width = rect.right - rect.left;
|
||||
g_resize_height = height = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
if (!win32_window_create(NULL, style, &mon_rect, width, height, fullscreen))
|
||||
goto error;
|
||||
|
||||
if (!fullscreen || windowed_full)
|
||||
{
|
||||
if (!fullscreen && settings->ui.menubar_enable)
|
||||
{
|
||||
RECT rc_temp = {0, 0, (LONG)height, 0x7FFF};
|
||||
SetMenu(g_hwnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU)));
|
||||
SendMessage(g_hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp);
|
||||
g_resize_height = height += rc_temp.top + rect.top;
|
||||
SetWindowPos(g_hwnd, NULL, 0, 0, width, height, SWP_NOMOVE);
|
||||
}
|
||||
|
||||
ShowWindow(g_hwnd, SW_RESTORE);
|
||||
UpdateWindow(g_hwnd);
|
||||
SetForegroundWindow(g_hwnd);
|
||||
SetFocus(g_hwnd);
|
||||
}
|
||||
|
||||
win32_show_cursor(!fullscreen);
|
||||
|
||||
/* Wait until context is created (or failed to do so ...) */
|
||||
while (!g_inited && !g_quit && GetMessage(&msg, g_hwnd, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
if (g_quit)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@ void create_gl_context(HWND hwnd);
|
|||
|
||||
void win32_monitor_init(void);
|
||||
|
||||
bool win32_set_video_mode(void *data,
|
||||
unsigned width, unsigned height,
|
||||
bool fullscreen)
|
||||
|
||||
bool win32_monitor_set_fullscreen(unsigned width,
|
||||
unsigned height, unsigned refresh, char *dev_name);
|
||||
|
||||
|
|
|
@ -324,95 +324,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data,
|
|||
unsigned width, unsigned height,
|
||||
bool fullscreen)
|
||||
{
|
||||
DWORD style;
|
||||
MSG msg;
|
||||
RECT mon_rect;
|
||||
unsigned mon_id;
|
||||
MONITORINFOEX current_mon;
|
||||
float refresh_mod;
|
||||
unsigned refresh;
|
||||
bool windowed_full;
|
||||
RECT rect = {0};
|
||||
HMONITOR hm_to_use = NULL;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
win32_monitor_info(¤t_mon, &hm_to_use, &mon_id);
|
||||
|
||||
mon_rect = current_mon.rcMonitor;
|
||||
g_resize_width = width;
|
||||
g_resize_height = height;
|
||||
|
||||
/* Windows only reports the refresh rates for modelines as
|
||||
* an integer, so video.refresh_rate needs to be rounded. Also, account
|
||||
* for black frame insertion using video.refresh_rate set to half
|
||||
* of the display refresh rate, as well as higher vsync swap intervals. */
|
||||
refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f;
|
||||
refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval);
|
||||
|
||||
windowed_full = settings->video.windowed_fullscreen;
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
if (windowed_full)
|
||||
{
|
||||
style = WS_EX_TOPMOST | WS_POPUP;
|
||||
g_resize_width = width = mon_rect.right - mon_rect.left;
|
||||
g_resize_height = height = mon_rect.bottom - mon_rect.top;
|
||||
}
|
||||
else
|
||||
{
|
||||
style = WS_POPUP | WS_VISIBLE;
|
||||
|
||||
if (!win32_monitor_set_fullscreen(width, height, refresh, current_mon.szDevice))
|
||||
goto error;
|
||||
|
||||
/* Display settings might have changed, get new coordinates. */
|
||||
GetMonitorInfo(hm_to_use, (MONITORINFO*)¤t_mon);
|
||||
mon_rect = current_mon.rcMonitor;
|
||||
g_restore_desktop = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
|
||||
rect.right = width;
|
||||
rect.bottom = height;
|
||||
AdjustWindowRect(&rect, style, FALSE);
|
||||
g_resize_width = width = rect.right - rect.left;
|
||||
g_resize_height = height = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
if (!win32_window_create(NULL, style, &mon_rect, width, height, fullscreen))
|
||||
goto error;
|
||||
|
||||
if (!fullscreen || windowed_full)
|
||||
{
|
||||
if (!fullscreen && settings->ui.menubar_enable)
|
||||
{
|
||||
RECT rc_temp = {0, 0, (LONG)height, 0x7FFF};
|
||||
SetMenu(g_hwnd, LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU)));
|
||||
SendMessage(g_hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp);
|
||||
g_resize_height = height += rc_temp.top + rect.top;
|
||||
SetWindowPos(g_hwnd, NULL, 0, 0, width, height, SWP_NOMOVE);
|
||||
}
|
||||
|
||||
ShowWindow(g_hwnd, SW_RESTORE);
|
||||
UpdateWindow(g_hwnd);
|
||||
SetForegroundWindow(g_hwnd);
|
||||
SetFocus(g_hwnd);
|
||||
}
|
||||
|
||||
win32_show_cursor(!fullscreen);
|
||||
|
||||
/* Wait until GL context is created (or failed to do so ...) */
|
||||
while (!g_inited && !g_quit && GetMessage(&msg, g_hwnd, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
if (g_quit)
|
||||
if (!win32_set_video_mode(data, width, height, fullscreen))
|
||||
goto error;
|
||||
|
||||
p_swap_interval = (BOOL (APIENTRY *)(int))wglGetProcAddress("wglSwapIntervalEXT");
|
||||
|
|
Loading…
Reference in New Issue