Mercurial > sdl-ios-xcode
comparison src/video/SDL_gamma.c @ 1612:97d0966f4bf7
Fixed some ultra-pedantic gcc warnings
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 24 Mar 2006 06:10:24 +0000 |
parents | d910939febfa |
children | 782fd950bd46 65800e7f7146 |
comparison
equal
deleted
inserted
replaced
1611:ec3466b08f17 | 1612:97d0966f4bf7 |
---|---|
41 static void CalculateGammaRamp(float gamma, Uint16 *ramp) | 41 static void CalculateGammaRamp(float gamma, Uint16 *ramp) |
42 { | 42 { |
43 int i; | 43 int i; |
44 | 44 |
45 /* 0.0 gamma is all black */ | 45 /* 0.0 gamma is all black */ |
46 if ( gamma <= 0.0 ) { | 46 if ( gamma <= 0.0f ) { |
47 for ( i=0; i<256; ++i ) { | 47 for ( i=0; i<256; ++i ) { |
48 ramp[i] = 0; | 48 ramp[i] = 0; |
49 } | 49 } |
50 return; | 50 return; |
51 } else | 51 } else |
52 /* 1.0 gamma is identity */ | 52 /* 1.0 gamma is identity */ |
53 if ( gamma == 1.0 ) { | 53 if ( gamma >= 1.0f ) { |
54 for ( i=0; i<256; ++i ) { | 54 for ( i=0; i<256; ++i ) { |
55 ramp[i] = (i << 8) | i; | 55 ramp[i] = (i << 8) | i; |
56 } | 56 } |
57 return; | 57 return; |
58 } else | 58 } else |
71 static void CalculateGammaFromRamp(float *gamma, Uint16 *ramp) | 71 static void CalculateGammaFromRamp(float *gamma, Uint16 *ramp) |
72 { | 72 { |
73 /* The following is adapted from a post by Garrett Bass on OpenGL | 73 /* The following is adapted from a post by Garrett Bass on OpenGL |
74 Gamedev list, March 4, 2000. | 74 Gamedev list, March 4, 2000. |
75 */ | 75 */ |
76 float sum = 0.0; | 76 float sum = 0.0f; |
77 int i, count = 0; | 77 int i, count = 0; |
78 | 78 |
79 *gamma = 1.0; | 79 *gamma = 1.0; |
80 for ( i = 1; i < 256; ++i ) { | 80 for ( i = 1; i < 256; ++i ) { |
81 if ( (ramp[i] != 0) && (ramp[i] != 65535) ) { | 81 if ( (ramp[i] != 0) && (ramp[i] != 65535) ) { |
83 double A = ramp[i] / 65535.0; | 83 double A = ramp[i] / 65535.0; |
84 sum += (float) ( log(A) / log(B) ); | 84 sum += (float) ( log(A) / log(B) ); |
85 count++; | 85 count++; |
86 } | 86 } |
87 } | 87 } |
88 if ( count && sum ) { | 88 if ( count && sum > 0.0f ) { |
89 *gamma = 1.0f / (sum / count); | 89 *gamma = 1.0f / (sum / count); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 int SDL_SetGamma(float red, float green, float blue) | 93 int SDL_SetGamma(float red, float green, float blue) |