/* * R_TakeEnvShot */ void R_TakeEnvShot( const char *path, const char *name, unsigned maxPixels ) { int i; unsigned size, maxSize; int checkname_size; char *checkname; refdef_t fd; struct cubemapSufAndFlip { char *suf; vec3_t angles; int flags; } cubemapShots[6] = { { "px", { 0, 0, 0 }, IT_FLIPX | IT_FLIPY | IT_FLIPDIAGONAL }, { "nx", { 0, 180, 0 }, IT_FLIPDIAGONAL }, { "py", { 0, 90, 0 }, IT_FLIPY }, { "ny", { 0, 270, 0 }, IT_FLIPX }, { "pz", { -90, 180, 0 }, IT_FLIPDIAGONAL }, { "nz", { 90, 180, 0 }, IT_FLIPDIAGONAL } }; if( !R_IsRenderingToScreen() || !rsh.worldModel ) { return; } maxSize = min( min( glConfig.width, glConfig.height ), glConfig.maxTextureSize ); if( maxSize > maxPixels ) { maxSize = maxPixels; } for( size = 1; size < maxSize; size <<= 1 ) ; if( size > maxSize ) { size >>= 1; }
void RF_WriteAviFrame( int frame, bool scissor ) { int x, y, w, h; const char *writedir, *gamedir; size_t path_size; char *path; char name[32]; if( !R_IsRenderingToScreen() ) return; if( scissor ) { x = rsc.refdef.x; y = glConfig.height - rsc.refdef.height - rsc.refdef.y; w = rsc.refdef.width; h = rsc.refdef.height; } else { x = 0; y = 0; w = glConfig.width; h = glConfig.height; } writedir = ri.FS_WriteDirectory(); gamedir = ri.FS_GameDirectory(); path_size = strlen( writedir ) + 1 + strlen( gamedir ) + strlen( "/avi/" ) + 1; path = alloca( path_size ); Q_snprintfz( path, path_size, "%s/%s/avi/", writedir, gamedir ); Q_snprintfz( name, sizeof( name ), "%06i", frame ); RF_AdapterWait( &rrf.adapter ); rrf.adapter.cmdPipe->AviShot( rrf.adapter.cmdPipe, path, name, x, y, w, h ); }
/* * R_TakeScreenShot */ void R_TakeScreenShot( const char *path, const char *name, const char *fmtString, int x, int y, int w, int h, bool silent, bool media ) { const char *extension; size_t path_size = strlen( path ) + 1; char *checkname = NULL; size_t checkname_size = 0; int quality; if( !R_IsRenderingToScreen() ) { return; } if( r_screenshot_jpeg->integer ) { extension = ".jpg"; quality = r_screenshot_jpeg_quality->integer; } else { extension = ".tga"; quality = 100; } if( name && name[0] && Q_stricmp( name, "*" ) ) { if( !COM_ValidateRelativeFilename( name ) ) { Com_Printf( "Invalid filename\n" ); return; } checkname_size = ( path_size - 1 ) + strlen( name ) + strlen( extension ) + 1; checkname = alloca( checkname_size ); Q_snprintfz( checkname, checkname_size, "%s%s", path, name ); COM_DefaultExtension( checkname, extension, checkname_size ); } // // find a file name to save it to // if( !checkname ) { const int maxFiles = 100000; static int lastIndex = 0; bool addIndex = false; char timestampString[MAX_QPATH]; static char lastFmtString[MAX_QPATH]; struct tm newtime; R_Localtime( time( NULL ), &newtime ); strftime( timestampString, sizeof( timestampString ), fmtString, &newtime ); checkname_size = ( path_size - 1 ) + strlen( timestampString ) + 5 + 1 + strlen( extension ); checkname = alloca( checkname_size ); // if the string format is a constant or file already exists then iterate if( !*fmtString || !strcmp( timestampString, fmtString ) ) { addIndex = true; // force a rescan in case some vars have changed.. if( strcmp( lastFmtString, fmtString ) ) { lastIndex = 0; Q_strncpyz( lastFmtString, fmtString, sizeof( lastFmtString ) ); r_screenshot_fmtstr->modified = false; } if( r_screenshot_jpeg->modified ) { lastIndex = 0; r_screenshot_jpeg->modified = false; } } else { Q_snprintfz( checkname, checkname_size, "%s%s%s", path, timestampString, extension ); if( ri.FS_FOpenAbsoluteFile( checkname, NULL, FS_READ ) != -1 ) { lastIndex = 0; addIndex = true; } } for( ; addIndex && lastIndex < maxFiles; lastIndex++ ) { Q_snprintfz( checkname, checkname_size, "%s%s%05i%s", path, timestampString, lastIndex, extension ); if( ri.FS_FOpenAbsoluteFile( checkname, NULL, FS_READ ) == -1 ) { break; // file doesn't exist } } if( lastIndex == maxFiles ) { Com_Printf( "Couldn't create a file\n" ); return; } lastIndex++; } R_ScreenShot( checkname, x, y, w, h, quality, false, false, false, silent ); if( media ) { ri.FS_AddFileToMedia( checkname ); } }