Skip to content

Commit c8e138d

Browse files
committed
tr_image: resize builtin images as 1×1
1 parent f7d9627 commit c8e138d

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
@@ -2751,11 +2751,8 @@ R_CreateBuiltinImages
27512751
*/
27522752
void R_CreateBuiltinImages()
27532753
{
2754-
constexpr int DIMENSION = 8;
2755-
int x;
2756-
byte data[ DIMENSION * DIMENSION * 4 ];
2754+
byte data[ 1 * 1 * 4 ];
27572755
byte *dataPtr = data;
2758-
byte *out;
27592756

27602757
R_CreateDefaultImage();
27612758

@@ -2767,50 +2764,34 @@ void R_CreateBuiltinImages()
27672764
imageParams.filterType = filterType_t::FT_LINEAR;
27682765
imageParams.wrapType = wrapTypeEnum_t::WT_REPEAT;
27692766

2770-
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2767+
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27712768

27722769
// we use a solid black image instead of disabling texturing
27732770
memset( data, 0, sizeof( data ) );
2774-
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2771+
2772+
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27752773

27762774
// red
2777-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2778-
{
2779-
out[ 1 ] = out[ 2 ] = 0;
2780-
out[ 0 ] = out[ 3 ] = 255;
2781-
}
2775+
Vector4Set( data, 255, 0, 0, 255 );
27822776

2783-
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2777+
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27842778

27852779
// green
2786-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2787-
{
2788-
out[ 0 ] = out[ 2 ] = 0;
2789-
out[ 1 ] = out[ 3 ] = 255;
2790-
}
2780+
Vector4Set( data, 0, 255, 0, 255 );
27912781

2792-
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2782+
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
27932783

27942784
// blue
2795-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2796-
{
2797-
out[ 0 ] = out[ 1 ] = 0;
2798-
out[ 2 ] = out[ 3 ] = 255;
2799-
}
2785+
Vector4Set( data, 0, 0, 255, 255 );
28002786

2801-
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2787+
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
28022788

28032789
// generate a default normalmap with a fully opaque heightmap (no displacement)
2804-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2805-
{
2806-
out[ 0 ] = out[ 1 ] = 128;
2807-
out[ 2 ] = 255;
2808-
out[ 3 ] = 255;
2809-
}
2790+
Vector4Set( data, 128, 128, 255, 255 );
28102791

28112792
imageParams.bits = IF_NOPICMIP | IF_NORMALMAP;
28122793

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

28152796
imageParams.bits = IF_NOPICMIP;
28162797
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;

0 commit comments

Comments
 (0)