diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 05d7f539f4..8568151694 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -1605,3 +1605,21 @@ void win32_get_video_output_size(unsigned *width, unsigned *height) *height = dm.dmPelsHeight; } } + +void win32_setup_pixel_format(HDC hdc, bool supports_gl) +{ + PIXELFORMATDESCRIPTOR pfd = {0}; + pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 32; + pfd.cDepthBits = 0; + pfd.cStencilBits = 0; + pfd.iLayerType = PFD_MAIN_PLANE; + + if (supports_gl) + pfd.dwFlags |= PFD_SUPPORT_OPENGL; + + SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); +} diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index 59c0fc3832..c122d4d172 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -143,6 +143,8 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam); bool win32_load_content_from_gui(const char *szFilename); +void win32_setup_pixel_format(HDC hdc, bool supports_gl); + RETRO_END_DECLS #endif diff --git a/gfx/drivers_context/gdi_ctx.c b/gfx/drivers_context/gdi_ctx.c index a7f18ec43f..1567bba6f6 100644 --- a/gfx/drivers_context/gdi_ctx.c +++ b/gfx/drivers_context/gdi_ctx.c @@ -56,21 +56,6 @@ typedef struct gfx_ctx_gdi_data void *dinput_gdi; -static void setup_gdi_pixel_format(HDC hdc) -{ - PIXELFORMATDESCRIPTOR pfd = {0}; - pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 32; - pfd.cDepthBits = 0; - pfd.cStencilBits = 0; - pfd.iLayerType = PFD_MAIN_PLANE; - - SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); -} - static void gfx_ctx_gdi_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, bool is_shutdown) { @@ -345,10 +330,9 @@ static void gfx_ctx_gdi_swap_buffers(void *data, void *data2) void create_gdi_context(HWND hwnd, bool *quit) { - (void)quit; win32_gdi_hdc = GetDC(hwnd); - setup_gdi_pixel_format(win32_gdi_hdc); + win32_setup_pixel_format(win32_gdi_hdc, false); g_win32_inited = true; } diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 221443970b..3047eca2e7 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -173,24 +173,6 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol) } #if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE) -static void setup_pixel_format(HDC hdc, bool supports_gl) -{ - PIXELFORMATDESCRIPTOR pfd = {0}; - pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 32; - pfd.cDepthBits = 0; - pfd.cStencilBits = 0; - pfd.iLayerType = PFD_MAIN_PLANE; - - if (supports_gl) - pfd.dwFlags |= PFD_SUPPORT_OPENGL; - - SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); -} - static void create_gl_context(HWND hwnd, bool *quit) { struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); @@ -198,7 +180,7 @@ static void create_gl_context(HWND hwnd, bool *quit) bool core_context = (win32_major * 1000 + win32_minor) >= 3001; win32_hdc = GetDC(hwnd); - setup_pixel_format(win32_hdc, true); + win32_setup_pixel_format(win32_hdc, true); #ifdef GL_DEBUG debug = true;