static void gfx_ctx_destroy(void) { if (g_dpy && g_ctx) { glXMakeContextCurrent(g_dpy, None, None, NULL); glXDestroyContext(g_dpy, g_ctx); g_ctx = NULL; } if (g_win) { glXDestroyWindow(g_dpy, g_glx_win); g_glx_win = 0; // Save last used monitor for later. #ifdef HAVE_XINERAMA XWindowAttributes target; Window child; int x = 0, y = 0; XGetWindowAttributes(g_dpy, g_win, &target); XTranslateCoordinates(g_dpy, g_win, DefaultRootWindow(g_dpy), target.x, target.y, &x, &y, &child); g_screen = x11_get_xinerama_monitor(g_dpy, x, y, target.width, target.height); RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen); #endif XUnmapWindow(g_dpy, g_win); XDestroyWindow(g_dpy, g_win); g_win = None; } if (g_cmap) { XFreeColormap(g_dpy, g_cmap); g_cmap = None; } if (g_should_reset_mode) { x11_exit_fullscreen(g_dpy, &g_desktop_mode); g_should_reset_mode = false; } if (g_dpy) { XCloseDisplay(g_dpy); g_dpy = NULL; } g_inited = false; g_pglSwapInterval = NULL; }
static void gfx_ctx_xegl_destroy(void *data) { x11_input_ctx_destroy(); egl_destroy(data); if (g_x11_win) { /* Save last used monitor for later. */ #ifdef HAVE_XINERAMA XWindowAttributes target; Window child; int x = 0, y = 0; XGetWindowAttributes(g_x11_dpy, g_x11_win, &target); XTranslateCoordinates(g_x11_dpy, g_x11_win, RootWindow(g_x11_dpy, DefaultScreen(g_x11_dpy)), target.x, target.y, &x, &y, &child); g_screen = x11_get_xinerama_monitor(g_x11_dpy, x, y, target.width, target.height); RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen); #endif x11_window_destroy(false); } x11_colormap_destroy(); if (g_should_reset_mode) { x11_exit_fullscreen(g_x11_dpy, &g_desktop_mode); g_should_reset_mode = false; } /* Do not close g_x11_dpy. We'll keep one for the entire application * lifecycle to work-around nVidia EGL limitations. */ }
static void ctx_glx_destroy_resources(gfx_ctx_glx_data_t *glx) { driver_t *driver = driver_get_ptr(); if (!glx) return; x11_destroy_input_context(&glx->g_xim, &glx->g_xic); if (glx->g_dpy && glx->g_ctx) { glFinish(); glXMakeContextCurrent(glx->g_dpy, None, None, NULL); if (!driver->video_cache_context) { if (glx->g_hw_ctx) glXDestroyContext(glx->g_dpy, glx->g_hw_ctx); glXDestroyContext(glx->g_dpy, glx->g_ctx); glx->g_ctx = NULL; glx->g_hw_ctx = NULL; } } if (glx->g_win) { glXDestroyWindow(glx->g_dpy, glx->g_glx_win); glx->g_glx_win = 0; /* Save last used monitor for later. */ #ifdef HAVE_XINERAMA XWindowAttributes target; Window child; int x = 0, y = 0; XGetWindowAttributes(glx->g_dpy, glx->g_win, &target); XTranslateCoordinates(glx->g_dpy, glx->g_win, DefaultRootWindow(glx->g_dpy), target.x, target.y, &x, &y, &child); glx->g_screen = x11_get_xinerama_monitor(glx->g_dpy, x, y, target.width, target.height); RARCH_LOG("[GLX]: Saved monitor #%u.\n", glx->g_screen); #endif XUnmapWindow(glx->g_dpy, glx->g_win); XDestroyWindow(glx->g_dpy, glx->g_win); glx->g_win = None; } if (glx->g_cmap) { XFreeColormap(glx->g_dpy, glx->g_cmap); glx->g_cmap = None; } if (glx->g_should_reset_mode) { x11_exit_fullscreen(glx->g_dpy, &glx->g_desktop_mode); glx->g_should_reset_mode = false; } if (!driver->video_cache_context && glx->g_dpy) { XCloseDisplay(glx->g_dpy); glx->g_dpy = NULL; } g_pglSwapInterval = NULL; g_pglSwapIntervalSGI = NULL; g_pglSwapIntervalEXT = NULL; g_major = g_minor = 0; glx->g_core_es = false; }
static void gfx_ctx_xegl_destroy(void *data) { (void)data; x11_destroy_input_context(&g_xim, &g_xic); if (g_egl_dpy) { if (g_egl_ctx) { eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(g_egl_dpy, g_egl_ctx); } if (g_egl_hw_ctx) eglDestroyContext(g_egl_dpy, g_egl_hw_ctx); if (g_egl_surf) eglDestroySurface(g_egl_dpy, g_egl_surf); eglTerminate(g_egl_dpy); } g_egl_ctx = NULL; g_egl_hw_ctx = NULL; g_egl_surf = NULL; g_egl_dpy = NULL; g_egl_config = 0; if (g_win) { /* Save last used monitor for later. */ #ifdef HAVE_XINERAMA XWindowAttributes target; Window child; int x = 0, y = 0; XGetWindowAttributes(g_dpy, g_win, &target); XTranslateCoordinates(g_dpy, g_win, RootWindow(g_dpy, DefaultScreen(g_dpy)), target.x, target.y, &x, &y, &child); g_screen = x11_get_xinerama_monitor(g_dpy, x, y, target.width, target.height); RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen); #endif XUnmapWindow(g_dpy, g_win); XDestroyWindow(g_dpy, g_win); g_win = None; } if (g_cmap) { XFreeColormap(g_dpy, g_cmap); g_cmap = None; } if (g_should_reset_mode) { x11_exit_fullscreen(g_dpy, &g_desktop_mode); g_should_reset_mode = false; } /* Do not close g_dpy. We'll keep one for the entire application * lifecycle to work-around nVidia EGL limitations. */ g_inited = false; }
static void gfx_ctx_destroy(void) { if (g_egl_dpy) { if (g_egl_ctx) { eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(g_egl_dpy, g_egl_ctx); } if (g_egl_surf) eglDestroySurface(g_egl_dpy, g_egl_surf); eglTerminate(g_egl_dpy); } g_egl_ctx = NULL; g_egl_surf = NULL; g_egl_dpy = NULL; g_config = 0; if (g_win) { // Save last used monitor for later. #ifdef HAVE_XINERAMA XWindowAttributes target; Window child; int x = 0, y = 0; XGetWindowAttributes(g_dpy, g_win, &target); XTranslateCoordinates(g_dpy, g_win, RootWindow(g_dpy, DefaultScreen(g_dpy)), target.x, target.y, &x, &y, &child); g_screen = x11_get_xinerama_monitor(g_dpy, x, y, target.width, target.height); RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen); #endif XUnmapWindow(g_dpy, g_win); XDestroyWindow(g_dpy, g_win); g_win = None; } if (g_cmap) { XFreeColormap(g_dpy, g_cmap); g_cmap = None; } if (g_should_reset_mode) { x11_exit_fullscreen(g_dpy, &g_desktop_mode); g_should_reset_mode = false; } if (g_dpy) { XCloseDisplay(g_dpy); g_dpy = NULL; } g_inited = false; }