Use TGA in specific places

This commit is contained in:
Nick Whitlock 2023-05-22 21:45:34 -04:00
parent df4e8405b0
commit c86cb9a982
4 changed files with 12 additions and 8 deletions

View file

@ -2666,7 +2666,7 @@ void idSessionLocal::Frame() {
// skipped frames so write them out
int c = aviDemoFrameCount - aviTicStart;
while ( c-- ) {
renderSystem->TakeScreenshot( com_aviDemoWidth.GetInteger(), com_aviDemoHeight.GetInteger(), name, com_aviDemoSamples.GetInteger(), NULL );
renderSystem->TakeScreenshot( com_aviDemoWidth.GetInteger(), com_aviDemoHeight.GetInteger(), name, com_aviDemoSamples.GetInteger(), NULL, 0 );
name = va("demos/%s/%s_%05i.tga", aviDemoShortName.c_str(), aviDemoShortName.c_str(), ++aviTicStart );
}
}
@ -2676,7 +2676,7 @@ void idSessionLocal::Frame() {
console->ClearNotifyLines();
// this will call Draw, possibly multiple times if com_aviDemoSamples is > 1
renderSystem->TakeScreenshot( com_aviDemoWidth.GetInteger(), com_aviDemoHeight.GetInteger(), name, com_aviDemoSamples.GetInteger(), NULL );
renderSystem->TakeScreenshot( com_aviDemoWidth.GetInteger(), com_aviDemoHeight.GetInteger(), name, com_aviDemoSamples.GetInteger(), NULL, 0 );
}
// at startup, we may be backwards

View file

@ -229,7 +229,7 @@ public:
// This will perform swapbuffers, so it is NOT an approppriate way to
// generate image files that happen during gameplay, as for savegame
// markers. Use WriteRender() instead.
virtual void TakeScreenshot( int width, int height, const char *fileName, int samples, struct renderView_s *ref ) = 0;
virtual void TakeScreenshot( int width, int height, const char *fileName, int samples, struct renderView_s *ref, int overrideFormat = -1 ) = 0;
// the render output can be cropped down to a subset of the real screen, as
// for save-game reviews and split-screen multiplayer. Users of the renderer

View file

@ -1279,7 +1279,7 @@ Downsample is the number of steps to mipmap the image before saving it
If ref == NULL, session->updateScreen will be used
==================
*/
void idRenderSystemLocal::TakeScreenshot( int width, int height, const char *fileName, int blends, renderView_t *ref ) {
void idRenderSystemLocal::TakeScreenshot( int width, int height, const char *fileName, int blends, renderView_t *ref, int overrideFormat ) {
byte *buffer, *flippedBuffer;
int i, j, k;
@ -1334,8 +1334,12 @@ void idRenderSystemLocal::TakeScreenshot( int width, int height, const char *fil
f = fileSystem->OpenFileWrite( fileName );
}
switch (cvarSystem->GetCVarInteger( "r_screenshotFormat" ))
{
// If no specific format is requested, default to using the CVar value.
if (overrideFormat == -1) {
overrideFormat = cvarSystem->GetCVarInteger( "r_screenshotFormat" );
}
switch (overrideFormat) {
default:
stbi_write_tga_to_func( WriteScreenshot, f, width, height, 3, flippedBuffer );
break;
@ -1609,7 +1613,7 @@ void R_EnvShot_f( const idCmdArgs &args ) {
ref.height = glConfig.vidHeight;
ref.viewaxis = axis[i];
sprintf( fullname, "env/%s%s", baseName, extensions[i] );
tr.TakeScreenshot( size, size, fullname, blends, &ref );
tr.TakeScreenshot( size, size, fullname, blends, &ref, 0 );
}
common->Printf( "Wrote %s, etc\n", fullname.c_str() );

View file

@ -721,7 +721,7 @@ public:
virtual void DrawDemoPics();
virtual void BeginFrame( int windowWidth, int windowHeight );
virtual void EndFrame( int *frontEndMsec, int *backEndMsec );
virtual void TakeScreenshot( int width, int height, const char *fileName, int downSample, renderView_t *ref );
virtual void TakeScreenshot( int width, int height, const char *fileName, int downSample, renderView_t *ref, int overrideFormat = -1 );
virtual void CropRenderSize( int width, int height, bool makePowerOfTwo = false, bool forceDimensions = false );
virtual void CaptureRenderToImage( const char *imageName );
virtual void CaptureRenderToFile( const char *fileName, bool fixAlpha );