Skip to content

Commit 386fa0b

Browse files
committed
tr_image: make builtin images 1×1 sized
1 parent 0e2fa2d commit 386fa0b

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
@@ -2723,11 +2723,8 @@ R_CreateBuiltinImages
27232723
*/
27242724
void R_CreateBuiltinImages()
27252725
{
2726-
constexpr int DIMENSION = 8;
2727-
int x;
2728-
byte data[ DIMENSION * DIMENSION * 4 ];
2726+
byte data[ 1 * 1 * 4 ];
27292727
byte *dataPtr = data;
2730-
byte *out;
27312728

27322729
R_CreateDefaultImage();
27332730

@@ -2739,50 +2736,34 @@ void R_CreateBuiltinImages()
27392736
imageParams.filterType = filterType_t::FT_LINEAR;
27402737
imageParams.wrapType = wrapTypeEnum_t::WT_REPEAT;
27412738

2742-
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2739+
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27432740

27442741
// we use a solid black image instead of disabling texturing
27452742
memset( data, 0, sizeof( data ) );
2746-
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2743+
2744+
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27472745

27482746
// red
2749-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2750-
{
2751-
out[ 1 ] = out[ 2 ] = 0;
2752-
out[ 0 ] = out[ 3 ] = 255;
2753-
}
2747+
Vector4Set( data, 255, 0, 0, 255 );
27542748

2755-
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2749+
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27562750

27572751
// green
2758-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2759-
{
2760-
out[ 0 ] = out[ 2 ] = 0;
2761-
out[ 1 ] = out[ 3 ] = 255;
2762-
}
2752+
Vector4Set( data, 0, 255, 0, 255 );
27632753

2764-
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2754+
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27652755

27662756
// blue
2767-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2768-
{
2769-
out[ 0 ] = out[ 1 ] = 0;
2770-
out[ 2 ] = out[ 3 ] = 255;
2771-
}
2757+
Vector4Set( data, 0, 0, 255, 255 );
27722758

2773-
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2759+
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27742760

27752761
// generate a default normalmap with a fully opaque heightmap (no displacement)
2776-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2777-
{
2778-
out[ 0 ] = out[ 1 ] = 128;
2779-
out[ 2 ] = 255;
2780-
out[ 3 ] = 255;
2781-
}
2762+
Vector4Set( data, 128, 128, 255, 255 );
27822763

27832764
imageParams.bits = IF_NOPICMIP | IF_NORMALMAP;
27842765

2785-
tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2766+
tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27862767

27872768
imageParams.bits = IF_NOPICMIP;
27882769
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;

0 commit comments

Comments
 (0)