iOS/buildlibs/armv7/allegro-4.4.2/addons/allegrogl/src/x.c
/* allegro_gl_x_exit:
 *  Shuts down the driver (shared between windowed and full-screen)
 */
Shuts down the driver (shared between windowed and full-screen)
Shuts down the driver ( shared between windowed and full - screen )
static void allegro_gl_x_exit(BITMAP *bmp)
{
#ifdef ALLEGROGL_HAVE_XF86VIDMODE
	XSetWindowAttributes setattr;
#endif
	XLOCK();
	glXWaitGL();
	__allegro_gl_unmanage_extensions();	
	if (_glxwin.ctx) {
		if (!allegro_gl_info.is_ati_r200_chip) {
			if (!glXMakeCurrent(_xwin.display, None, NULL)) {
				ustrzcpy (allegro_error, ALLEGRO_ERROR_SIZE,
				          get_config_text ("Could not release drawing context.\n"));
			}
		}
		glXDestroyContext(_xwin.display, _glxwin.ctx);
		_glxwin.ctx = NULL;
	}
	if (_xwin.mouse_grabbed) {
		XUngrabPointer(_xwin.display, CurrentTime);
		_xwin.mouse_grabbed = 0;
	}
	if (_xwin.keyboard_grabbed) {
		XUngrabKeyboard(_xwin.display, CurrentTime);
		_xwin.keyboard_grabbed = 0;
	}
#ifdef ALLEGROGL_HAVE_XF86VIDMODE
	if (_glxwin.fullscreen) {
		if (_xwin.mode_switched) {
			XF86VidModeLockModeSwitch(_xwin.display, _xwin.screen, False);
			XF86VidModeSwitchToMode(_xwin.display, _xwin.screen,
			                        _xwin.modesinfo[0]);
			XF86VidModeSetViewPort(_xwin.display, _xwin.screen, 0, 0);
			_xwin.mode_switched = 0;
		}
		if (_xwin.override_redirected) {
			setattr.override_redirect = False;
			XChangeWindowAttributes(_xwin.display, _xwin.window,
			                        CWOverrideRedirect, &setattr);
			_xwin.override_redirected = 0;
		}
		free_modelines(_xwin.modesinfo, _xwin.num_modes);
		_xwin.num_modes = 0;
		_xwin.modesinfo = NULL;
	}
#endif
	ASSERT(allegro_gl_screen == screen);
 	allegro_gl_screen = NULL;
	if (_xwin.window != None)
		XUnmapWindow(_xwin.display, _xwin.window);
	if (_glxwin.use_glx_window) {
		glXDestroyWindow(_xwin.display, _glxwin.window);
		_glxwin.window = 0;
		_glxwin.use_glx_window = FALSE;
	}
	__allegro_gl_valid_context = FALSE;
	_xwin_window_redrawer = old_window_redrawer;
	XSetErrorHandler(old_x_error_handler);
#if GET_ALLEGRO_VERSION() >= MAKE_VER(4, 2, 1)
	if (backup_allegro_window != None) {
		if (_xwin.colormap != None) {
			XUninstallColormap(_xwin.display, _xwin.colormap);
			XFreeColormap(_xwin.display, _xwin.colormap);
		}
		_xwin.colormap = backup_allegro_colormap;
		if (_xwin.window != None)
			XDestroyWindow(_xwin.display, _xwin.window);
		_xwin.window = backup_allegro_window;
		backup_allegro_window = None;
		XMapWindow(_xwin.display, _xwin.window);
	}
#endif
	XUNLOCK();
}
static void allegro_gl_x_exit ( BITMAP * bmp ) { #ifdef ALLEGROGL_HAVE_XF86VIDMODE XSetWindowAttributes setattr ; #endif XLOCK ( ) ; glXWaitGL ( ) ; __allegro_gl_unmanage_extensions ( ) ; if ( _glxwin . ctx ) { if ( ! allegro_gl_info . is_ati_r200_chip ) { if ( ! glXMakeCurrent ( _xwin . display , None , NULL ) ) { ustrzcpy ( allegro_error , ALLEGRO_ERROR_SIZE , get_config_text ( " \n " ) ) ; } } glXDestroyContext ( _xwin . display , _glxwin . ctx ) ; _glxwin . ctx = NULL ; } if ( _xwin . mouse_grabbed ) { XUngrabPointer ( _xwin . display , CurrentTime ) ; _xwin . mouse_grabbed = 0 ; } if ( _xwin . keyboard_grabbed ) { XUngrabKeyboard ( _xwin . display , CurrentTime ) ; _xwin . keyboard_grabbed = 0 ; } #ifdef ALLEGROGL_HAVE_XF86VIDMODE if ( _glxwin . fullscreen ) { if ( _xwin . mode_switched ) { XF86VidModeLockModeSwitch ( _xwin . display , _xwin . screen , False ) ; XF86VidModeSwitchToMode ( _xwin . display , _xwin . screen , _xwin . modesinfo [ 0 ] ) ; XF86VidModeSetViewPort ( _xwin . display , _xwin . screen , 0 , 0 ) ; _xwin . mode_switched = 0 ; } if ( _xwin . override_redirected ) { setattr . override_redirect = False ; XChangeWindowAttributes ( _xwin . display , _xwin . window , CWOverrideRedirect , & setattr ) ; _xwin . override_redirected = 0 ; } free_modelines ( _xwin . modesinfo , _xwin . num_modes ) ; _xwin . num_modes = 0 ; _xwin . modesinfo = NULL ; } #endif ASSERT ( allegro_gl_screen == screen ) ; allegro_gl_screen = NULL ; if ( _xwin . window != None ) XUnmapWindow ( _xwin . display , _xwin . window ) ; if ( _glxwin . use_glx_window ) { glXDestroyWindow ( _xwin . display , _glxwin . window ) ; _glxwin . window = 0 ; _glxwin . use_glx_window = FALSE ; } __allegro_gl_valid_context = FALSE ; _xwin_window_redrawer = old_window_redrawer ; XSetErrorHandler ( old_x_error_handler ) ; #if GET_ALLEGRO_VERSION ( ) >= MAKE_VER ( 4 , 2 , 1 ) if ( backup_allegro_window != None ) { if ( _xwin . colormap != None ) { XUninstallColormap ( _xwin . display , _xwin . colormap ) ; XFreeColormap ( _xwin . display , _xwin . colormap ) ; } _xwin . colormap = backup_allegro_colormap ; if ( _xwin . window != None ) XDestroyWindow ( _xwin . display , _xwin . window ) ; _xwin . window = backup_allegro_window ; backup_allegro_window = None ; XMapWindow ( _xwin . display , _xwin . window ) ; } #endif XUNLOCK ( ) ; }
allegro_gl_x_exit:
  Shuts down the driver (shared between windowed and full-screen)
allegro_gl_x_exit : Shuts down the driver ( shared between windowed and full - screen )
/* We politely wait for OpenGL to finish its current operations before
	   shutting down the driver */ /* The DRI drivers for ATI cards with R200 chip
			 * seem to be broken since they crash at this point.
			 * As a workaround AGL does not release the GLX context
			 * here. This should not hurt since the GLX specs don't
			 * require the context to be released before the program
			 * ends or before another context is made current to the
			 * thread.
			 */ /* Free modelines.  */ /* Note: Allegro will destroy screen (== allegro_gl_screen),
	 * so don't destroy it here.
	 */ //destroy_bitmap(allegro_gl_screen); /* Unmap the window in order not to see the cursor when quitting.
	   The window *must not* be destroyed and _xwin.visual must be left
	   to its current value otherwise the program will crash when exiting */ /* Hack: Allegro 4.2.1 uses a persistent window, we need to restore it. */