Example #1
0
//	This routine does all OS specific shutdown procedures for the OpenGL
// subsystem. This means deleting the rendering context, destroying the
// window and restoring video mode. The state structure is also nulled out.
void GLimp_Shutdown() {
	IN_DeactivateMouse();
	if ( dpy ) {
		GLW_DeleteDefaultLists();

		if ( ctx ) {
			glXDestroyContext( dpy, ctx );
		}
		if ( win ) {
			XDestroyWindow( dpy, win );
		}
		if ( vidmode_active ) {
			XF86VidModeSwitchToMode( dpy, scrnum, vidmodes[ 0 ] );
		}
		if ( glConfig.deviceSupportsGamma ) {
			XF86VidModeSetGamma( dpy, scrnum, &vidmode_InitialGamma );
		}
		// NOTE TTimo opening/closing the display should be necessary only once per run
		//   but it seems QGL_Shutdown gets called in a lot of occasion
		//   in some cases, this XCloseDisplay is known to raise some X errors
		//   ( https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=33 )
		XCloseDisplay( dpy );
	}
	vidmode_active = false;
	dpy = NULL;
	win = 0;
	ctx = NULL;

	Com_Memset( &glConfig, 0, sizeof ( glConfig ) );
	Com_Memset( &glState, 0, sizeof ( glState ) );
}
Example #2
0
//	This routine does all OS specific shutdown procedures for the OpenGL
// subsystem.
void GLimp_Shutdown() {
	const char* success[] = { "failed", "success" };

	common->Printf( "Shutting down OpenGL subsystem\n" );

	// delete display lists
	GLW_DeleteDefaultLists();

	// restore gamma.
	if ( glConfig.deviceSupportsGamma ) {
		HDC hDC = GetDC( GetDesktopWindow() );
		SetDeviceGammaRamp( hDC, s_oldHardwareGamma );
		ReleaseDC( GetDesktopWindow(), hDC );
		glConfig.deviceSupportsGamma = false;
	}

	// set current context to NULL
	int retVal = wglMakeCurrent( NULL, NULL ) != 0;

	common->Printf( "...wglMakeCurrent( NULL, NULL ): %s\n", success[ retVal ] );

	// delete HGLRC
	if ( baseRC ) {
		retVal = wglDeleteContext( baseRC ) != 0;
		common->Printf( "...deleting GL context: %s\n", success[ retVal ] );
		baseRC = NULL;
	}

	// release DC
	if ( maindc ) {
		retVal = ReleaseDC( GMainWindow, maindc ) != 0;
		common->Printf( "...releasing DC: %s\n", success[ retVal ] );
		maindc = NULL;
	}

	// destroy window
	if ( GMainWindow ) {
		common->Printf( "...destroying window\n" );
		ShowWindow( GMainWindow, SW_HIDE );
		DestroyWindow( GMainWindow );
		GMainWindow = NULL;
		pixelFormatSet = false;
	}

	// reset display settings
	if ( cdsFullscreen ) {
		common->Printf( "...resetting display\n" );
		ChangeDisplaySettings( 0, 0 );
		cdsFullscreen = false;
	}

	Com_Memset( &glConfig, 0, sizeof ( glConfig ) );
	Com_Memset( &glState, 0, sizeof ( glState ) );
}
Example #3
0
/*
** GLimp_Shutdown
**
** This routine does all OS specific shutdown procedures for the OpenGL
** subsystem.
*/
void GLimp_Shutdown( void ) {
//	const char *strings[] = { "soft", "hard" };
	const char *success[] = { "failed", "success" };
	int retVal;

	// FIXME: Brian, we need better fallbacks from partially initialized failures
	if ( !qwglMakeCurrent ) {
		return;
	}

	ri.Printf( PRINT_ALL, "Shutting down OpenGL subsystem\n" );

	// restore gamma.  We do this first because 3Dfx's extension needs a valid OGL subsystem
	WG_RestoreGamma();

	// delete display lists
	GLW_DeleteDefaultLists();

	// set current context to NULL
	if ( qwglMakeCurrent ) {
		retVal = qwglMakeCurrent( NULL, NULL ) != 0;

		ri.Printf( PRINT_ALL, "...wglMakeCurrent( NULL, NULL ): %s\n", success[retVal] );
	}

	// delete HGLRC
	if ( glw_state.hGLRC ) {
		retVal = qwglDeleteContext( glw_state.hGLRC ) != 0;
		ri.Printf( PRINT_ALL, "...deleting GL context: %s\n", success[retVal] );
		glw_state.hGLRC = NULL;
	}

	// release DC
	if ( glw_state.hDC ) {
		retVal = ReleaseDC( g_wv.hWnd, glw_state.hDC ) != 0;
		ri.Printf( PRINT_ALL, "...releasing DC: %s\n", success[retVal] );
		glw_state.hDC   = NULL;
	}

	// destroy window
	if ( g_wv.hWnd ) {
		ri.Printf( PRINT_ALL, "...destroying window\n" );
		ShowWindow( g_wv.hWnd, SW_HIDE );
		DestroyWindow( g_wv.hWnd );
		g_wv.hWnd = NULL;
		glw_state.pixelFormatSet = qfalse;
	}

	// close the r_logFile
	if ( glw_state.log_fp ) {
		fclose( glw_state.log_fp );
		glw_state.log_fp = 0;
	}

	// reset display settings
	if ( glw_state.cdsFullscreen ) {
		ri.Printf( PRINT_ALL, "...resetting display\n" );
		ChangeDisplaySettings( 0, 0 );
		glw_state.cdsFullscreen = qfalse;
	}

	// shutdown QGL subsystem
	QGL_Shutdown();

	memset( &glConfig, 0, sizeof( glConfig ) );
	memset( &glState, 0, sizeof( glState ) );
}