From 0dce6479c116a562ae84c39f5559e47a722b3e04 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Nov 2015 02:51:40 +0100 Subject: [PATCH] Create win32_window_create --- gfx/common/win32_common.cpp | 22 ++++++++++++++++++++++ gfx/common/win32_common.h | 4 ++++ gfx/d3d/d3d.cpp | 12 ++---------- gfx/drivers_context/wgl_ctx.cpp | 12 +----------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 011670a02b..71cad29ca8 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -259,6 +259,28 @@ bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen) return true; } +bool win32_window_create(void *data, unsigned style, + RECT *mon_rect, unsigned width, + unsigned height, bool fullscreen) +{ +#ifndef _XBOX + driver_t *driver = driver_get_ptr(); + g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", + style, + info->fullscreen ? mon_rect.left : g_pos_x, + info->fullscreen ? mon_rect.top : g_pos_y, + win_width, win_height, + NULL, NULL, NULL, data); + if (!g_hwnd) + return false; + + driver->display_type = RARCH_DISPLAY_WIN32; + driver->video_display = 0; + driver->video_window = (uintptr_t)g_hwnd; +#endif + return true; +} + static bool win32_browser( HWND owner, char *filename, diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 95a11c7d89..223408d614 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -58,6 +58,10 @@ void win32_monitor_init(void); bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen); +bool win32_window_create(void *data, unsigned style, + RECT *mon_rect, unsigned width, + unsigned height, bool fullscreen); + bool win32_suppress_screensaver(void *data, bool enable); bool win32_get_metrics(void *data, diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 57d5f9e854..1abfe57cbe 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -667,16 +667,8 @@ static bool d3d_construct(d3d_video_t *d3d, win_height = rect.bottom - rect.top; } - g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", - style, - info->fullscreen ? mon_rect.left : CW_USEDEFAULT, - info->fullscreen ? mon_rect.top : CW_USEDEFAULT, - win_width, win_height, - NULL, NULL, NULL, d3d); - - driver->display_type = RARCH_DISPLAY_WIN32; - driver->video_display = 0; - driver->video_window = (uintptr_t)g_hwnd; + win32_window_create(d3d, style, &mon_rect, win_width, + win_height, info->fullscreen); #endif #endif diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index c549b10676..da96d4b306 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -401,13 +401,7 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, g_resize_height = height = rect.bottom - rect.top; } - g_hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", style, - fullscreen ? mon_rect.left : g_pos_x, - fullscreen ? mon_rect.top : g_pos_y, - width, height, - NULL, NULL, NULL, NULL); - - if (!g_hwnd) + if (!win32_window_create(NULL, style, &mon_rect, width, height, fullscreen)) goto error; if (!fullscreen || windowed_full) @@ -443,10 +437,6 @@ static bool gfx_ctx_wgl_set_video_mode(void *data, gfx_ctx_wgl_swap_interval(data, g_interval); - driver->display_type = RARCH_DISPLAY_WIN32; - driver->video_display = 0; - driver->video_window = (uintptr_t)g_hwnd; - return true; error: