Mercurial > sdl-ios-xcode
comparison src/video/SDL_gamma.c @ 3012:7e30c2dc7783
Fixed Visual C++ release build for Visual C++ 2005
* Some math functions become intrinsic in release mode, so we need to
convert all the math functions into SDL math functions, like we did
with the stdlib functions.
* Constant initializers of 8-bit values become calls to memset() in
release mode, but memset() itself is an intrinsic when explicitly
called. So we'll just explicitly call memset() in those cases.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 10 Jan 2009 18:32:24 +0000 |
parents | 99210400e8b9 |
children | 62d4992e5a92 |
comparison
equal
deleted
inserted
replaced
3011:8f4ed5ec2b06 | 3012:7e30c2dc7783 |
---|---|
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 #include "SDL_config.h" | 22 #include "SDL_config.h" |
23 | 23 |
24 /* Gamma correction support */ | 24 /* Gamma correction support */ |
25 | |
26 #include "../libm/math.h" | |
27 | 25 |
28 #include "SDL_sysvideo.h" | 26 #include "SDL_sysvideo.h" |
29 | 27 |
30 | 28 |
31 static void | 29 static void |
50 /* Calculate a real gamma ramp */ | 48 /* Calculate a real gamma ramp */ |
51 { | 49 { |
52 int value; | 50 int value; |
53 gamma = 1.0f / gamma; | 51 gamma = 1.0f / gamma; |
54 for (i = 0; i < 256; ++i) { | 52 for (i = 0; i < 256; ++i) { |
55 value = (int) (pow((double) i / 256.0, gamma) * 65535.0 + 0.5); | 53 value = (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5); |
56 if (value > 65535) { | 54 if (value > 65535) { |
57 value = 65535; | 55 value = 65535; |
58 } | 56 } |
59 ramp[i] = (Uint16) value; | 57 ramp[i] = (Uint16) value; |
60 } | 58 } |
73 *gamma = 1.0; | 71 *gamma = 1.0; |
74 for (i = 1; i < 256; ++i) { | 72 for (i = 1; i < 256; ++i) { |
75 if ((ramp[i] != 0) && (ramp[i] != 65535)) { | 73 if ((ramp[i] != 0) && (ramp[i] != 65535)) { |
76 double B = (double) i / 256.0; | 74 double B = (double) i / 256.0; |
77 double A = ramp[i] / 65535.0; | 75 double A = ramp[i] / 65535.0; |
78 sum += (float) (log(A) / log(B)); | 76 sum += (float) (SDL_log(A) / SDL_log(B)); |
79 count++; | 77 count++; |
80 } | 78 } |
81 } | 79 } |
82 if (count && sum > 0.0f) { | 80 if (count && sum > 0.0f) { |
83 *gamma = 1.0f / (sum / count); | 81 *gamma = 1.0f / (sum / count); |