Skip to content

Commit

Permalink
tr_renderer: add r_imageFitScreen cvar
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 29, 2024
1 parent 87d8065 commit 5ca11c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/engine/renderer/InternalImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,15 @@ int R_GetImageCustomScalingStep( const image_t *image, const imageParams_t &imag

int scalingStep = 0;

// Scale down the image size until it's not smaller than screen.
// Scale down the image size according to the screen size.
if ( image->bits & IF_FITSCREEN )
{
// If disabled, do nothing.
if ( !r_imageFitScreen.Get() )
{
return 0;
}

int largerSide = std::max( glConfig.vidWidth, glConfig.vidHeight );

if ( scaledDimension > largerSide )
Expand All @@ -123,8 +129,13 @@ int R_GetImageCustomScalingStep( const image_t *image, const imageParams_t &imag
scalingStep++;
}

// We need the larger image size before it becomes smaller than screen.
if ( scaledDimension != largerSide )
/* With r_imageFitScreen == 1, we need the larger image size before
it becomes smaller than screen.
With r_imageFitScreen == 2 the image is never larger than screen, as
we allow the larger size that is not larger than screen, it can be the
larger size smaller than screen. */
if ( scaledDimension != largerSide && r_imageFitScreen.Get() != 2 )
{
scaledDimension <<= 1;
scalingStep--;
Expand Down
2 changes: 2 additions & 0 deletions src/engine/renderer/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cvar_t *r_ignoreMaterialMinDimension;
cvar_t *r_ignoreMaterialMaxDimension;
cvar_t *r_replaceMaterialMinDimensionIfPresentWithMaxDimension;
Cvar::Range<Cvar::Cvar<int>> r_imageFitScreen("r_imageFitScreen", "downscale “fitscreen” images according to screen size: 0: disable, 1: downscale as much as possible without being smaller than screen size, 2: downscale to never be larger then screen size", Cvar::NONE, 1, 0, 2);
cvar_t *r_finish;
cvar_t *r_clear;
cvar_t *r_textureMode;
Expand Down Expand Up @@ -1095,6 +1096,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p
r_ignoreMaterialMaxDimension = Cvar_Get( "r_ignoreMaterialMaxDimension", "0", CVAR_LATCH | CVAR_ARCHIVE );
r_replaceMaterialMinDimensionIfPresentWithMaxDimension
= Cvar_Get( "r_replaceMaterialMinDimensionIfPresentWithMaxDimension", "0", CVAR_LATCH | CVAR_ARCHIVE );
Cvar::Latch(r_imageFitScreen);
r_colorbits = Cvar_Get( "r_colorbits", "0", CVAR_LATCH );
r_mode = Cvar_Get( "r_mode", "-2", CVAR_LATCH | CVAR_ARCHIVE );
r_customwidth = Cvar_Get( "r_customwidth", "1600", CVAR_LATCH | CVAR_ARCHIVE );
Expand Down
1 change: 1 addition & 0 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2911,6 +2911,7 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };
extern cvar_t *r_ignoreMaterialMinDimension;
extern cvar_t *r_ignoreMaterialMaxDimension;
extern cvar_t *r_replaceMaterialMinDimensionIfPresentWithMaxDimension;
extern Cvar::Range<Cvar::Cvar<int>> r_imageFitScreen;
extern cvar_t *r_finish;
extern cvar_t *r_drawBuffer;
extern cvar_t *r_textureMode;
Expand Down

0 comments on commit 5ca11c1

Please sign in to comment.