Skip to content

Commit 3bb4521

Browse files
committed
tr_image: resize builtin images as 1×1
1 parent d802326 commit 3bb4521

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
@@ -2636,11 +2636,8 @@ R_CreateBuiltinImages
26362636
*/
26372637
void R_CreateBuiltinImages()
26382638
{
2639-
constexpr int DIMENSION = 8;
2640-
int x;
2641-
byte data[ DIMENSION * DIMENSION * 4 ];
2639+
byte data[ 1 * 1 * 4 ];
26422640
byte *dataPtr = data;
2643-
byte *out;
26442641

26452642
R_CreateDefaultImage();
26462643

@@ -2652,50 +2649,34 @@ void R_CreateBuiltinImages()
26522649
imageParams.filterType = filterType_t::FT_LINEAR;
26532650
imageParams.wrapType = wrapTypeEnum_t::WT_REPEAT;
26542651

2655-
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2652+
tr.whiteImage = R_CreateImage( "_white", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
26562653

26572654
// we use a solid black image instead of disabling texturing
26582655
memset( data, 0, sizeof( data ) );
2659-
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2656+
2657+
tr.blackImage = R_CreateImage( "_black", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
26602658

26612659
// red
2662-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2663-
{
2664-
out[ 1 ] = out[ 2 ] = 0;
2665-
out[ 0 ] = out[ 3 ] = 255;
2666-
}
2660+
Vector4Set( data, 255, 0, 0, 255 );
26672661

2668-
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2662+
tr.redImage = R_CreateImage( "_red", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
26692663

26702664
// green
2671-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2672-
{
2673-
out[ 0 ] = out[ 2 ] = 0;
2674-
out[ 1 ] = out[ 3 ] = 255;
2675-
}
2665+
Vector4Set( data, 0, 255, 0, 255 );
26762666

2677-
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2667+
tr.greenImage = R_CreateImage( "_green", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
26782668

26792669
// blue
2680-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2681-
{
2682-
out[ 0 ] = out[ 1 ] = 0;
2683-
out[ 2 ] = out[ 3 ] = 255;
2684-
}
2670+
Vector4Set( data, 0, 0, 255, 255 );
26852671

2686-
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2672+
tr.blueImage = R_CreateImage( "_blue", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
26872673

26882674
// generate a default normalmap with a fully opaque heightmap (no displacement)
2689-
for ( x = DIMENSION * DIMENSION, out = data; x; --x, out += 4 )
2690-
{
2691-
out[ 0 ] = out[ 1 ] = 128;
2692-
out[ 2 ] = 255;
2693-
out[ 3 ] = 255;
2694-
}
2675+
Vector4Set( data, 128, 128, 255, 255 );
26952676

26962677
imageParams.bits = IF_NOPICMIP | IF_NORMALMAP;
26972678

2698-
tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, DIMENSION, DIMENSION, 1, imageParams );
2679+
tr.flatImage = R_CreateImage( "_flat", ( const byte ** ) &dataPtr, 1, 1, 1, imageParams );
26992680

27002681
imageParams.bits = IF_NOPICMIP;
27012682
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;

0 commit comments

Comments
 (0)