From feebb78f7557075e1750ff86887a040367a6ab77 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 23 Jun 2013 23:18:05 +0200 Subject: [PATCH] Support cached contexts on Win32. Only tested on Wine, but works. --- gfx/context/wgl_ctx.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index 912a50ff71..52f3be9e20 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -83,7 +83,14 @@ static void create_gl_context(HWND hwnd) g_hdc = GetDC(hwnd); setup_pixel_format(g_hdc); - g_hrc = wglCreateContext(g_hdc); + if (!g_hrc) + g_hrc = wglCreateContext(g_hdc); + else + { + RARCH_LOG("[WGL]: Using cached GL context.\n"); + driver.video_cache_context_ack = true; + } + if (g_hrc) { if (wglMakeCurrent(g_hdc, g_hrc)) @@ -484,8 +491,12 @@ static void gfx_ctx_destroy(void) if (g_hrc) { wglMakeCurrent(NULL, NULL); - wglDeleteContext(g_hrc); - g_hrc = NULL; + + if (!driver.video_cache_context) + { + wglDeleteContext(g_hrc); + g_hrc = NULL; + } } if (g_hwnd && g_hdc) @@ -514,6 +525,7 @@ static void gfx_ctx_destroy(void) g_inited = false; g_major = g_minor = 0; + p_swap_interval = NULL; } static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)