fix image loading sRGB conversion
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 22 Oct 2011 15:28:56 +0000 (15:28 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 22 Oct 2011 15:28:56 +0000 (15:28 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11460 d7cf8633-e32d-0410-b094-e92efae38249

gl_textures.c
image.h

index aa1d2f1..2fbc559 100644 (file)
@@ -1620,6 +1620,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                        {
                                temppixels = (unsigned char *)Mem_Alloc(tempmempool, size);
                                memcpy(temppixels, data, size);
+                               data = temppixels;
                        }
                        Image_MakeLinearColorsFromsRGB(temppixels, temppixels, width*height*depth*sides);
                }
diff --git a/image.h b/image.h
index c027f64..9153577 100644 (file)
--- a/image.h
+++ b/image.h
@@ -51,10 +51,8 @@ extern cvar_t r_fixtrans_auto;
 
 #define Image_LinearFloatFromsRGBFloat(c) (((c) <= 0.04045f) ? (c) * (1.0f / 12.92f) : (float)pow(((c) + 0.055f)*(1.0f/1.055f), 2.4f))
 #define Image_sRGBFloatFromLinearFloat(c) (((c) < 0.0031308f) ? (c) * 12.92f : 1.055f * (float)pow((c), 1.0f/2.4f) - 0.055f)
-
 #define Image_LinearFloatFromsRGB(c) Image_LinearFloatFromsRGBFloat((c) * (1.0f / 255.0f))
 #define Image_sRGBFloatFromLinear(c) Image_sRGBFloatFromLinearFloat((c) * (1.0f / 255.0f))
-
 #define Image_sRGBFloatFromLinear_Lightmap(c) Image_sRGBFloatFromLinearFloat((c) * (2.0f / 255.0f)) * 0.5f
 
 void Image_MakeLinearColorsFromsRGB(unsigned char *pout, const unsigned char *pin, int numpixels);