Skip to content

Commit 0b6351e

Browse files
committed
tr_image: resize builtin images as 1×1
1 parent 310cb74 commit 0b6351e

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed

src/engine/renderer/tr_image.cpp

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,11 +2732,8 @@ R_CreateBuiltinImages
27322732
*/
27332733
void R_CreateBuiltinImages()
27342734
{
2735-
constexpr int DIMENSION = 8;
2736-
int x;
2737-
byte data[ DIMENSION * DIMENSION * 4 ];
2735+
byte data[ 1 * 1 * 4 ];
27382736
byte *dataPtr = data;
2739-
byte *out;
27402737

27412738
R_CreateDefaultImage();
27422739

@@ -2748,50 +2745,34 @@ void R_CreateBuiltinImages()
27482745
imageParams.filterType = filterType_t::FT_LINEAR;
27492746
imageParams.wrapType = wrapTypeEnum_t::WT_REPEAT;
27502747

2751-
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2748+
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27522749

27532750
// we use a solid black image instead of disabling texturing
27542751
memset( data, 0, sizeof( data ) );
2755-
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2752+
2753+
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27562754

27572755
// red
2758-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2759-
{
2760-
out[ 1 ] = out[ 2 ] = 0;
2761-
out[ 0 ] = out[ 3 ] = 255;
2762-
}
2756+
Vector4Set( data, 255, 0, 0, 255 );
27632757

2764-
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2758+
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27652759

27662760
// green
2767-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2768-
{
2769-
out[ 0 ] = out[ 2 ] = 0;
2770-
out[ 1 ] = out[ 3 ] = 255;
2771-
}
2761+
Vector4Set( data, 0, 255, 0, 255 );
27722762

2773-
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2763+
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27742764

27752765
// blue
2776-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2777-
{
2778-
out[ 0 ] = out[ 1 ] = 0;
2779-
out[ 2 ] = out[ 3 ] = 255;
2780-
}
2766+
Vector4Set( data, 0, 0, 255, 255 );
27812767

2782-
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2768+
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27832769

27842770
// generate a default normalmap with a fully opaque heightmap (no displacement)
2785-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2786-
{
2787-
out[ 0 ] = out[ 1 ] = 128;
2788-
out[ 2 ] = 255;
2789-
out[ 3 ] = 255;
2790-
}
2771+
Vector4Set( data, 128, 128, 255, 255 );
27912772

27922773
imageParams.bits = IF_NOPICMIP | IF_NORMALMAP;
27932774

2794-
tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2775+
tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27952776

27962777
imageParams.bits = IF_NOPICMIP;
27972778
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;

0 commit comments

Comments
 (0)