diff options
author | SmileTheory <SmileTheory@gmail.com> | 2014-08-01 23:57:26 -0700 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-08-28 11:13:04 +0100 |
commit | c348fd4c49359c91c201ca0f66a2cd71041dca34 (patch) | |
tree | 658c90f03f5e4029453e86b6c9704303e94a112a /src/renderergl2/tr_image.c | |
parent | d2c5e367fcd4a9e1cf39d74638dc80b2af29361a (diff) |
OpenGL2: Remove R_MipMap() and R_MipMap2(), and fix gamma conversion in R_MipMapsRGB()
Diffstat (limited to 'src/renderergl2/tr_image.c')
-rw-r--r-- | src/renderergl2/tr_image.c | 102 |
1 files changed, 3 insertions, 99 deletions
diff --git a/src/renderergl2/tr_image.c b/src/renderergl2/tr_image.c index 75626531..060eb1c4 100644 --- a/src/renderergl2/tr_image.c +++ b/src/renderergl2/tr_image.c @@ -1276,61 +1276,12 @@ void R_LightScaleTexture (byte *in, int inwidth, int inheight, qboolean only_gam /* ================ -R_MipMap2 +R_MipMapsRGB Operates in place, quartering the size of the texture -Proper linear filter +Colors are gamma correct ================ */ -static void R_MipMap2( byte *in, int inWidth, int inHeight ) { - int i, j, k; - byte *outpix; - int inWidthMask, inHeightMask; - int total; - int outWidth, outHeight; - unsigned *temp; - - outWidth = inWidth >> 1; - outHeight = inHeight >> 1; - temp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); - - inWidthMask = inWidth - 1; - inHeightMask = inHeight - 1; - - for ( i = 0 ; i < outHeight ; i++ ) { - for ( j = 0 ; j < outWidth ; j++ ) { - outpix = (byte *) ( temp + i * outWidth + j ); - for ( k = 0 ; k < 4 ; k++ ) { - total = - 1 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + - 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + - 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + - 1 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] + - - 2 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + - 4 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + - 4 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + - 2 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] + - - 2 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + - 4 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + - 4 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + - 2 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] + - - 1 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + - 2 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + - 2 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + - 1 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k]; - outpix[k] = total / 36; - } - } - } - - Com_Memcpy( in, temp, outWidth * outHeight * 4 ); - ri.Hunk_FreeTempMemory( temp ); -} - - static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) { int x, y, c, stride; @@ -1342,7 +1293,7 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) if (!downmipSrgbLookupSet) { for (x = 0; x < 256; x++) - downmipSrgbLookup[x] = ((x < 10) ? x / 3294.6f : powf((x / 255.0f + 0.055f) / 1.055f, 2.4f)) * 0.25f; + downmipSrgbLookup[x] = powf(x / 255.0f, 2.2f) * 0.25f; downmipSrgbLookupSet = 1; } @@ -1380,53 +1331,6 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) } } -/* -================ -R_MipMap - -Operates in place, quartering the size of the texture -================ -*/ -static void R_MipMap (byte *in, int width, int height) { - int i, j; - byte *out; - int row; - - if ( !r_simpleMipMaps->integer ) { - R_MipMap2( in, width, height ); - return; - } - - if ( width == 1 && height == 1 ) { - return; - } - - row = width * 4; - out = in; - width >>= 1; - height >>= 1; - - if ( width == 0 || height == 0 ) { - width += height; // get largest - for (i=0 ; i<width ; i++, out+=4, in+=8 ) { - out[0] = ( in[0] + in[4] )>>1; - out[1] = ( in[1] + in[5] )>>1; - out[2] = ( in[2] + in[6] )>>1; - out[3] = ( in[3] + in[7] )>>1; - } - return; - } - - for (i=0 ; i<height ; i++, in+=row) { - for (j=0 ; j<width ; j++, out+=4, in+=8) { - out[0] = (in[0] + in[4] + in[row+0] + in[row+4])>>2; - out[1] = (in[1] + in[5] + in[row+1] + in[row+5])>>2; - out[2] = (in[2] + in[6] + in[row+2] + in[row+6])>>2; - out[3] = (in[3] + in[7] + in[row+3] + in[row+7])>>2; - } - } -} - static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int height) { |