mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-02-28 06:32:00 +00:00
astyle and other wonderbar stuff!
This commit is contained in:
parent
fedaf6b691
commit
fc7ed840bc
4 changed files with 233 additions and 184 deletions
|
@ -530,7 +530,8 @@ void idCommonLocal::Frame()
|
|||
// save the screenshot and audio from the last draw if needed
|
||||
if( aviCaptureMode )
|
||||
{
|
||||
idStr name = va( "demos/%s/%s_%05i", aviDemoShortName.c_str(), aviDemoShortName.c_str(), aviDemoFrameCount++ );
|
||||
idStr name;
|
||||
name.Format( "demos/%s/%s_%05i", aviDemoShortName.c_str(), aviDemoShortName.c_str(), aviDemoFrameCount++ );
|
||||
renderSystem->TakeScreenshot( com_aviDemoWidth.GetInteger(), com_aviDemoHeight.GetInteger(), name, com_aviDemoSamples.GetInteger(), NULL, TGA );
|
||||
|
||||
// remove any printed lines at the top before taking the screenshot
|
||||
|
|
|
@ -69,7 +69,7 @@ typedef enum
|
|||
CF_2D_ARRAY // not a cube map but not a single 2d texture either
|
||||
} cubeFiles_t;
|
||||
|
||||
enum fileType_t
|
||||
enum imageFileType_t
|
||||
{
|
||||
TGA,
|
||||
PNG,
|
||||
|
|
|
@ -550,16 +550,22 @@ void R_RotatePic( byte* data, int width )
|
|||
|
||||
// transforms in both ways, the images from a cube map,
|
||||
// in both the Env map and the Skybox map systems.
|
||||
void R_ApplyCubeMapTransforms ( int iter, byte* data, int size ) {
|
||||
if ( ( iter == 1 ) || ( iter == 2 ) ) {
|
||||
void R_ApplyCubeMapTransforms( int iter, byte* data, int size )
|
||||
{
|
||||
if( ( iter == 1 ) || ( iter == 2 ) )
|
||||
{
|
||||
R_VerticalFlip( data, size, size );
|
||||
}
|
||||
if ( ( iter == 0 ) || ( iter == 1 ) || ( iter == 4 ) || ( iter == 5 ) ) {
|
||||
if( ( iter == 0 ) || ( iter == 1 ) || ( iter == 4 ) || ( iter == 5 ) )
|
||||
{
|
||||
R_RotatePic( data, size ); // apparently not only rotates but also flips horitzontally
|
||||
}
|
||||
if ( iter == 1 ) {
|
||||
if( iter == 1 )
|
||||
{
|
||||
R_VerticalFlip( data, size, size );
|
||||
} else if ( iter == 3 ) { // that's so just for having less lines
|
||||
}
|
||||
else if( iter == 3 ) // that's so just for having less lines
|
||||
{
|
||||
R_HorizontalFlip( data, size, size );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ idCVar r_shadowMapPolygonOffset( "r_shadowMapPolygonOffset", "3000", CVAR_RENDER
|
|||
idCVar r_shadowMapOccluderFacing( "r_shadowMapOccluderFacing", "2", CVAR_RENDERER | CVAR_INTEGER, "0 = front faces, 1 = back faces, 2 = twosided" );
|
||||
// RB end
|
||||
|
||||
const char* fileExten [3] = { "tga", "png", "jpg" };
|
||||
const char* fileExten[3] = { "tga", "png", "jpg" };
|
||||
const char* envDirection[6] = { "_nx", "_py", "_ny", "_pz", "_nz", "_px" };
|
||||
const char* skyDirection[6] = { "_forward", "_back", "_left", "_right", "_up", "_down" };
|
||||
|
||||
|
@ -1231,28 +1231,33 @@ void idRenderSystemLocal::TakeScreenshot( int width, int height, const char* fil
|
|||
{
|
||||
byte* buffer;
|
||||
int i, j, c, temp;
|
||||
const char *formatName[3] = { ".tga", ".png", ".jpg" };
|
||||
idStr finalFileName;
|
||||
|
||||
sprintf( finalFileName, "%s%s", fileName, formatName[exten] );
|
||||
finalFileName.Format( "%s.%s", fileName, fileExten[exten] );
|
||||
|
||||
takingScreenshot = true;
|
||||
|
||||
int pix = width * height;
|
||||
const int bufferSize = pix * 3 + 18;
|
||||
|
||||
if ( exten == PNG ) {
|
||||
if( exten == PNG )
|
||||
{
|
||||
buffer = ( byte* )R_StaticAlloc( pix * 3 );
|
||||
} else if ( exten == TGA ) {
|
||||
buffer = (byte *)R_StaticAlloc( bufferSize );
|
||||
}
|
||||
else if( exten == TGA )
|
||||
{
|
||||
buffer = ( byte* )R_StaticAlloc( bufferSize );
|
||||
memset( buffer, 0, bufferSize );
|
||||
}
|
||||
|
||||
if( blends <= 1 )
|
||||
{
|
||||
if ( exten == PNG ) {
|
||||
if( exten == PNG )
|
||||
{
|
||||
R_ReadTiledPixels( width, height, buffer, ref );
|
||||
} else if ( exten == TGA ) {
|
||||
}
|
||||
else if( exten == TGA )
|
||||
{
|
||||
R_ReadTiledPixels( width, height, buffer + 18, ref );
|
||||
}
|
||||
}
|
||||
|
@ -1266,17 +1271,23 @@ void idRenderSystemLocal::TakeScreenshot( int width, int height, const char* fil
|
|||
|
||||
for( i = 0 ; i < blends ; i++ )
|
||||
{
|
||||
if ( exten == PNG ) {
|
||||
if( exten == PNG )
|
||||
{
|
||||
R_ReadTiledPixels( width, height, buffer, ref );
|
||||
} else if ( exten == TGA ) {
|
||||
}
|
||||
else if( exten == TGA )
|
||||
{
|
||||
R_ReadTiledPixels( width, height, buffer + 18, ref );
|
||||
}
|
||||
|
||||
for( j = 0 ; j < pix * 3 ; j++ )
|
||||
{
|
||||
if ( exten == PNG ) {
|
||||
if( exten == PNG )
|
||||
{
|
||||
shortBuffer[j] += buffer[j];
|
||||
} else if ( exten == TGA ) {
|
||||
}
|
||||
else if( exten == TGA )
|
||||
{
|
||||
shortBuffer[j] += buffer[18 + j];
|
||||
}
|
||||
}
|
||||
|
@ -1285,9 +1296,12 @@ void idRenderSystemLocal::TakeScreenshot( int width, int height, const char* fil
|
|||
// divide back to bytes
|
||||
for( i = 0 ; i < pix * 3 ; i++ )
|
||||
{
|
||||
if ( exten == PNG ) {
|
||||
if( exten == PNG )
|
||||
{
|
||||
buffer[i] = shortBuffer[i] / blends;
|
||||
} else if ( exten == TGA ) {
|
||||
}
|
||||
else if( exten == TGA )
|
||||
{
|
||||
buffer[18 + i] = shortBuffer[i] / blends;
|
||||
}
|
||||
}
|
||||
|
@ -1295,9 +1309,12 @@ void idRenderSystemLocal::TakeScreenshot( int width, int height, const char* fil
|
|||
R_StaticFree( shortBuffer );
|
||||
r_jitter.SetBool( false );
|
||||
}
|
||||
if ( exten == PNG ) {
|
||||
if( exten == PNG )
|
||||
{
|
||||
R_WritePNG( finalFileName, buffer, 3, width, height, false );
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// fill in the header (this is vertically flipped, which qglReadPixels emits)
|
||||
buffer[2] = 2; // uncompressed type
|
||||
buffer[12] = width & 255;
|
||||
|
@ -1309,10 +1326,11 @@ void idRenderSystemLocal::TakeScreenshot( int width, int height, const char* fil
|
|||
// swap rgb to bgr
|
||||
c = 18 + width * height * 3;
|
||||
|
||||
for (i=18 ; i<c ; i+=3) {
|
||||
for( i = 18 ; i < c ; i += 3 )
|
||||
{
|
||||
temp = buffer[i];
|
||||
buffer[i] = buffer[i+2];
|
||||
buffer[i+2] = temp;
|
||||
buffer[i] = buffer[i + 2];
|
||||
buffer[i + 2] = temp;
|
||||
}
|
||||
|
||||
fileSystem->WriteFile( finalFileName, buffer, c );
|
||||
|
@ -1503,40 +1521,48 @@ envshot <basename>
|
|||
Saves out env/<basename>_ft.tga, etc
|
||||
==================
|
||||
*/
|
||||
void R_EnvShot_f( const idCmdArgs &args ) {
|
||||
void R_EnvShot_f( const idCmdArgs& args )
|
||||
{
|
||||
idStr fullname;
|
||||
const char *baseName;
|
||||
const char* baseName;
|
||||
int i;
|
||||
idMat3 axis[7], oldAxis;
|
||||
renderView_t ref;
|
||||
viewDef_t primary;
|
||||
int blends;
|
||||
const char *extensions[7] = { "_wrong", "_nx", "_py", "_ny", "_pz", "_nz", "_px" };
|
||||
const char* extension;
|
||||
int size;
|
||||
int res_w, res_h, old_fov_x, old_fov_y;
|
||||
|
||||
res_w = renderSystem->GetWidth();
|
||||
res_h = renderSystem->GetHeight();
|
||||
|
||||
if ( args.Argc() != 2 && args.Argc() != 3 && args.Argc() != 4 ) {
|
||||
if( args.Argc() != 2 && args.Argc() != 3 && args.Argc() != 4 )
|
||||
{
|
||||
common->Printf( "USAGE: envshot <basename> [size] [blends]\n" );
|
||||
return;
|
||||
}
|
||||
baseName = args.Argv( 1 );
|
||||
|
||||
blends = 1;
|
||||
if ( args.Argc() == 4 ) {
|
||||
if( args.Argc() == 4 )
|
||||
{
|
||||
size = atoi( args.Argv( 2 ) );
|
||||
blends = atoi( args.Argv( 3 ) );
|
||||
} else if ( args.Argc() == 3 ) {
|
||||
}
|
||||
else if( args.Argc() == 3 )
|
||||
{
|
||||
size = atoi( args.Argv( 2 ) );
|
||||
blends = 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
size = 256;
|
||||
blends = 1;
|
||||
}
|
||||
|
||||
if ( !tr.primaryView ) {
|
||||
if( !tr.primaryView )
|
||||
{
|
||||
common->Printf( "No primary view.\n" );
|
||||
return;
|
||||
}
|
||||
|
@ -1573,26 +1599,36 @@ void R_EnvShot_f( const idCmdArgs &args ) {
|
|||
axis[6][2][1] = 1;
|
||||
|
||||
// let's get the game window to a "size" resolution
|
||||
if ( ( res_w != size ) || ( res_h != size ) ) {
|
||||
if( ( res_w != size ) || ( res_h != size ) )
|
||||
{
|
||||
cvarSystem->SetCVarInteger( "r_windowWidth", size );
|
||||
cvarSystem->SetCVarInteger( "r_windowHeight", size );
|
||||
R_SetNewMode( false ); // the same as "vid_restart"
|
||||
} // FIXME that's a hack!!
|
||||
|
||||
for ( i = 0 ; i < 7 ; i++ ) {
|
||||
for( i = 0 ; i < 7 ; i++ )
|
||||
{
|
||||
|
||||
ref = primary.renderView;
|
||||
|
||||
if ( i == 0 ) {
|
||||
if( i == 0 )
|
||||
{
|
||||
// so we return to that axis and fov after the fact.
|
||||
oldAxis = ref.viewaxis;
|
||||
old_fov_x = ref.fov_x;
|
||||
old_fov_y = ref.fov_y;
|
||||
//this is part of the hack
|
||||
extension = "_wrong";
|
||||
}
|
||||
else
|
||||
{
|
||||
// this keeps being part of the hack
|
||||
extension = envDirection[ i - 1 ]; //yes, indeed, this is totally part of the hack!
|
||||
}
|
||||
|
||||
ref.fov_x = ref.fov_y = 90;
|
||||
ref.viewaxis = axis[i];
|
||||
sprintf( fullname, "env/%s%s", baseName, extensions[i] );
|
||||
fullname.Format( "env/%s%s", baseName, extension );
|
||||
|
||||
tr.TakeScreenshot( size, size, fullname, blends, &ref, TGA );
|
||||
}
|
||||
|
@ -1699,9 +1735,6 @@ void R_MakeAmbientMap_f( const idCmdArgs& args )
|
|||
renderView_t ref;
|
||||
viewDef_t primary;
|
||||
int downSample;
|
||||
const char* extensions[6] = { "_px.tga", "_nx.tga", "_py.tga", "_ny.tga",
|
||||
"_pz.tga", "_nz.tga"
|
||||
};
|
||||
int outSize;
|
||||
byte* buffers[6];
|
||||
int width = 0, height = 0;
|
||||
|
@ -1751,7 +1784,7 @@ void R_MakeAmbientMap_f( const idCmdArgs& args )
|
|||
// read all of the images
|
||||
for( i = 0 ; i < 6 ; i++ )
|
||||
{
|
||||
sprintf( fullname, "env/%s%s", baseName, extensions[i] );
|
||||
fullname.Format( "env/%s%s.%s", baseName, envDirection[i], fileExten[TGA] );
|
||||
common->Printf( "loading %s\n", fullname.c_str() );
|
||||
const bool captureToImage = false;
|
||||
common->UpdateScreen( captureToImage );
|
||||
|
@ -1826,11 +1859,11 @@ void R_MakeAmbientMap_f( const idCmdArgs& args )
|
|||
|
||||
if( map == 0 )
|
||||
{
|
||||
sprintf( fullname, "env/%s_amb%s", baseName, extensions[i] );
|
||||
fullname.Format( "env/%s_amb%s.%s", baseName, envDirection[i], fileExten[TGA] );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( fullname, "env/%s_spec%s", baseName, extensions[i] );
|
||||
fullname.Format( "env/%s_spec%s.%s", baseName, envDirection[i], fileExten[TGA] );
|
||||
}
|
||||
common->Printf( "writing %s\n", fullname.c_str() );
|
||||
const bool captureToImage = false;
|
||||
|
@ -1852,7 +1885,6 @@ void R_TransformCubemap( const char* orgDirection[6], const char* orgDir, const
|
|||
{
|
||||
idStr fullname;
|
||||
int i;
|
||||
const char* ext = ".tga";
|
||||
bool errorInOriginalImages = false;
|
||||
int outSize;
|
||||
byte* buffers[6];
|
||||
|
@ -1861,27 +1893,33 @@ void R_TransformCubemap( const char* orgDirection[6], const char* orgDir, const
|
|||
for( i = 0 ; i < 6 ; i++ )
|
||||
{
|
||||
// read every image images
|
||||
sprintf( fullname, "%s/%s%s.%s", orgDir, baseName, orgDirection[i], fileExten [TGA] );
|
||||
fullname.Format( "%s/%s%s.%s", orgDir, baseName, orgDirection[i], fileExten [TGA] );
|
||||
common->Printf( "loading %s\n", fullname.c_str() );
|
||||
const bool captureToImage = false;
|
||||
common->UpdateScreen( captureToImage );
|
||||
R_LoadImage( fullname, &buffers[i], &width, &height, NULL, true );
|
||||
|
||||
//check if the buffer is troublesome
|
||||
if ( !buffers[i] )
|
||||
if( !buffers[i] )
|
||||
{
|
||||
common->Printf( "failed.\n" );
|
||||
errorInOriginalImages = true;
|
||||
} else if ( width != height ) {
|
||||
}
|
||||
else if( width != height )
|
||||
{
|
||||
common->Printf( "wrong size pal!\n\n\nget your shit together and set the size according to your images!\n\n\ninept programmers are inept!\n" );
|
||||
errorInOriginalImages = true; // yeah, but don't just choke on a joke!
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInOriginalImages = false;
|
||||
}
|
||||
|
||||
if ( errorInOriginalImages ) {
|
||||
if( errorInOriginalImages )
|
||||
{
|
||||
errorInOriginalImages = false;
|
||||
for( i-- ; i >= 0 ; i-- ) {
|
||||
for( i-- ; i >= 0 ; i-- )
|
||||
{
|
||||
Mem_Free( buffers[i] ); // clean up every buffer from this stage down
|
||||
}
|
||||
|
||||
|
@ -1892,7 +1930,7 @@ void R_TransformCubemap( const char* orgDirection[6], const char* orgDir, const
|
|||
R_ApplyCubeMapTransforms( i, buffers[i], width );
|
||||
|
||||
//save the images with the appropiate skybox naming convention
|
||||
sprintf( fullname, "%s/%s/%s%s.%s", destDir, baseName, baseName, destDirection[i], fileExten [TGA] );
|
||||
fullname.Format( "%s/%s/%s%s.%s", destDir, baseName, baseName, destDirection[i], fileExten [TGA] );
|
||||
common->Printf( "writing %s\n", fullname.c_str() );
|
||||
common->UpdateScreen( false );
|
||||
R_WriteTGA( fullname, buffers[i], width, width );
|
||||
|
@ -1917,9 +1955,11 @@ transforms env textures (of the type px, py, pz, nx, ny, nz)
|
|||
to skybox textures ( forward, back, left, right, up, down)
|
||||
==================
|
||||
*/
|
||||
void R_TransformEnvToSkybox_f( const idCmdArgs& args ){
|
||||
void R_TransformEnvToSkybox_f( const idCmdArgs& args )
|
||||
{
|
||||
|
||||
if( args.Argc() != 2 ) {
|
||||
if( args.Argc() != 2 )
|
||||
{
|
||||
common->Printf( "USAGE: envToSky <basename>\n" );
|
||||
return;
|
||||
}
|
||||
|
@ -1938,9 +1978,11 @@ to env textures (of the type px, py, pz, nx, ny, nz)
|
|||
==================
|
||||
*/
|
||||
|
||||
void R_TransformSkyboxToEnv_f ( const idCmdArgs& args ){
|
||||
void R_TransformSkyboxToEnv_f( const idCmdArgs& args )
|
||||
{
|
||||
|
||||
if( args.Argc() != 2 ) {
|
||||
if( args.Argc() != 2 )
|
||||
{
|
||||
common->Printf( "USAGE: skyToEnv <basename>\n" );
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue