Beispiel #1
0
void R_ScreenShotJPEG_f( void ) {
	char checkname[MAX_OSPATH];
	int len;
	static int lastNumber = -1;
	qboolean silent;

	if ( !strcmp( ri.Cmd_Argv( 1 ), "levelshot" ) ) {
		R_LevelShot();
		return;
	}

	if ( !strcmp( ri.Cmd_Argv( 1 ), "silent" ) ) {
		silent = qtrue;
	} else {
		silent = qfalse;
	}

	if ( ri.Cmd_Argc() == 2 && !silent ) {
		// explicit filename
		Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", ri.Cmd_Argv( 1 ) );
	} else {
		// scan for a free filename

		// if we have saved a previous screenshot, don't scan
		// again, because recording demo avis can involve
		// thousands of shots
		if ( lastNumber == -1 ) {
			lastNumber = 0;
		}
		// scan for a free number
		for ( ; lastNumber <= 9999 ; lastNumber++ ) {
			R_ScreenshotFilenameJPEG( lastNumber, checkname );

			len = ri.FS_ReadFile( checkname, NULL );
			if ( len <= 0 ) {
				break;  // file doesn't exist
			}
		}

		if ( lastNumber == 10000 ) {
			ri.Printf( PRINT_ALL, "ScreenShot: Couldn't create a file\n" );
			return;
		}

		lastNumber++;
	}


	R_TakeScreenshotJPEG( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );

	if ( !silent ) {
		ri.Printf( PRINT_ALL, "Wrote %s\n", checkname );
	}
}
Beispiel #2
0
void
R_ScreenShotJPEG_f(void)
{
	char checkname[MAX_OSPATH];
	static int	lastNumber = -1;
	qbool		silent;

	if(!strcmp(ri.cmdargv(1), "levelshot")){
		R_LevelShot();
		return;
	}

	if(!strcmp(ri.cmdargv(1), "silent")){
		silent = qtrue;
	}else{
		silent = qfalse;
	}

	if(ri.cmdargc() == 2 && !silent){
		/* explicit filename */
		Q_sprintf(checkname, MAX_OSPATH, "screenshots/%s.jpg", ri.cmdargv(1));
	}else{
		/* scan for a free filename */

		/* if we have saved a previous screenshot, don't scan
		 * again, because recording demo avis can involve
		 * thousands of shots */
		if(lastNumber == -1){
			lastNumber = 0;
		}
		/* scan for a free number */
		for(; lastNumber <= 9999; lastNumber++){
			R_ScreenshotFilenameJPEG(lastNumber, checkname);

			if(!ri.fsfileexists(checkname)){
				break;	/* file doesn't exist */
			}
		}

		if(lastNumber == 10000){
			ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n");
			return;
		}

		lastNumber++;
	}

	R_TakeScreenshot(0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qtrue);

	if(!silent){
		ri.Printf (PRINT_ALL, "Wrote %s\n", checkname);
	}
}
Beispiel #3
0
/*
==================
R_ScreenShot_f

screenshot[JPEG|PNG] [silent | <filename>]
==================
*/
void R_ScreenShot_f( void )
{
	char       checkname[ MAX_OSPATH ];
	int        len;
	static int lastNumber = -1;
	ssFormat_t format;
	qboolean   silent;

	if ( !Q_stricmp( ri.Cmd_Argv( 0 ), "screenshotJPEG" ) )
	{
		format = SSF_JPEG;
	}
	else if ( !Q_stricmp( ri.Cmd_Argv( 0 ), "screenshotPNG" ) )
	{
		format = SSF_PNG;
	}
	else
	{
		format = SSF_TGA;
	}

	if ( !strcmp( ri.Cmd_Argv( 1 ), "silent" ) )
	{
		silent = qtrue;
	}
	else
	{
		silent = qfalse;
	}

	if ( ri.Cmd_Argc() == 2 && !silent )
	{
		// explicit filename
		switch ( format )
		{
			case SSF_TGA:
				Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri.Cmd_Argv( 1 ) );
				break;

			case SSF_JPEG:
				Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpeg", ri.Cmd_Argv( 1 ) );
				break;

			case SSF_PNG:
				Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.png", ri.Cmd_Argv( 1 ) );
				break;
		}
	}
	else
	{
		// scan for a free filename

		// if we have saved a previous screenshot, don't scan
		// again, because recording demo avis can involve
		// thousands of shots
		if ( lastNumber == -1 )
		{
			lastNumber = 0;
		}

		// scan for a free number
		for ( ; lastNumber <= 9999; lastNumber++ )
		{
			switch ( format )
			{
				case SSF_TGA:
					R_ScreenshotFilename( lastNumber, checkname );
					break;

				case SSF_JPEG:
					R_ScreenshotFilenameJPEG( lastNumber, checkname );
					break;

				case SSF_PNG:
					R_ScreenshotFilenamePNG( lastNumber, checkname );
					break;
			}

			len = ri.FS_ReadFile( checkname, NULL );

			if ( len <= 0 )
			{
				break; // file doesn't exist
			}
		}

		if ( lastNumber >= 10000 )
		{
			ri.Printf( PRINT_ALL, "ScreenShot: Couldn't create a file\n" );
			return;
		}

		lastNumber++;
	}

	switch ( format )
	{
		case SSF_TGA:
			R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );
			break;

		case SSF_JPEG:
			R_TakeScreenshotJPEG( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );
			break;

		case SSF_PNG:
			R_TakeScreenshotPNG( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname );
			break;
	}

	if ( !silent )
	{
		ri.Printf( PRINT_ALL, "Wrote %s\n", checkname );
	}
}