From e6d7116da0edc020d97ad1809893e41e8c40eabe Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 4 Jan 2017 14:03:01 -0500 Subject: [PATCH] create GDI window --- gfx/common/gdi_common.h | 2 +- gfx/drivers/gdi_gfx.c | 85 ++++++++++++++++++++++++++++++++++++++ gfx/video_context_driver.h | 3 +- 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/gfx/common/gdi_common.h b/gfx/common/gdi_common.h index 31334cfb74..b4acb0afb5 100644 --- a/gfx/common/gdi_common.h +++ b/gfx/common/gdi_common.h @@ -20,7 +20,7 @@ typedef struct gdi { - bool test; + WNDCLASSEX wndclass; } gdi_t; #endif diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 2009aa0c0b..afac35945f 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -47,8 +47,12 @@ static void gdi_gfx_create() static void *gdi_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) { + unsigned full_x, full_y; settings_t *settings = config_get_ptr(); gdi_t *gdi = (gdi_t*)calloc(1, sizeof(*gdi)); + const gfx_ctx_driver_t *ctx_driver = NULL; + gfx_ctx_input_t inp; + gfx_ctx_mode_t mode; *input = NULL; *input_data = NULL; @@ -64,10 +68,91 @@ static void *gdi_gfx_init(const video_info_t *video, gdi_gfx_create(); + ctx_driver = video_context_driver_init_first(gdi, + settings->video.context_driver, + GFX_CTX_GDI_API, 1, 0, false); + if (!ctx_driver) + goto error; + + video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver); + +#ifdef HAVE_WINDOW + win32_window_init(&gdi->wndclass, true, NULL); +#endif + +#ifdef HAVE_MONITOR + bool windowed_full; + RECT mon_rect; + MONITORINFOEX current_mon; + HMONITOR hm_to_use; + + win32_monitor_info(¤t_mon, &hm_to_use, &d3d->cur_mon_id); + mon_rect = current_mon.rcMonitor; + g_resize_width = video->width; + g_resize_height = video->height; + + windowed_full = settings->video.windowed_fullscreen; + + full_x = (windowed_full || video->width == 0) ? + (mon_rect.right - mon_rect.left) : video->width; + full_y = (windowed_full || video->height == 0) ? + (mon_rect.bottom - mon_rect.top) : video->height; + RARCH_LOG("[GDI]: Monitor size: %dx%d.\n", + (int)(mon_rect.right - mon_rect.left), + (int)(mon_rect.bottom - mon_rect.top)); +#else + { + video_context_driver_get_video_size(&mode); + + full_x = mode.width; + full_y = mode.height; + } +#endif + { + unsigned new_width = video->fullscreen ? full_x : video->width; + unsigned new_height = video->fullscreen ? full_y : video->height; + mode.width = new_width; + mode.height = new_height; + mode.fullscreen = video->fullscreen; + + video_context_driver_set_video_mode(&mode); + video_driver_set_size(&new_width, &new_height); + } + +#ifdef HAVE_WINDOW + DWORD style; + unsigned win_width, win_height; + RECT rect = {0}; + + video_driver_get_size(&win_width, &win_height); + + win32_set_style(¤t_mon, &hm_to_use, &win_width, &win_height, + video->fullscreen, windowed_full, &rect, &mon_rect, &style); + + win32_window_create(gdi, style, &mon_rect, win_width, + win_height, video->fullscreen); + + win32_set_window(&win_width, &win_height, video->fullscreen, + windowed_full, &rect); +#endif + if (settings->video.font_enable) font_driver_init_osd(NULL, false, FONT_DRIVER_RENDER_GDI); + inp.input = input; + inp.input_data = input_data; + + video_context_driver_input_driver(&inp); + + RARCH_LOG("[GDI]: Init complete.\n"); + return gdi; + +error: + video_context_driver_destroy(); + if (gdi) + free(gdi); + return NULL; } static bool gdi_gfx_frame(void *data, const void *frame, diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 63426451e7..55a150c177 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -37,7 +37,8 @@ enum gfx_ctx_api GFX_CTX_DIRECT3D8_API, GFX_CTX_DIRECT3D9_API, GFX_CTX_OPENVG_API, - GFX_CTX_VULKAN_API + GFX_CTX_VULKAN_API, + GFX_CTX_GDI_API }; enum display_metric_types