X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscreen%2Fcolors.hxx;h=c3ea8e7e27e3a9f62e079470a3ea68b9650cbab6;hb=33970663435dd1a12941b017739285341205acf4;hp=197597079de733b06f3e0d72decd28dcfcdd8a43;hpb=94c22fec4668b259e83038f6ba1f098df353c73e;p=simgear.git diff --git a/simgear/screen/colors.hxx b/simgear/screen/colors.hxx index 19759707..c3ea8e7e 100644 --- a/simgear/screen/colors.hxx +++ b/simgear/screen/colors.hxx @@ -16,7 +16,7 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ @@ -26,43 +26,53 @@ #include -#if defined( macintosh ) -const float system_gamma = 1.4; - -#elif defined (sgi) -const float system_gamma = 1.7; +#if defined (sgi) +const float system_gamma = 2.0/1.7; #else // others const float system_gamma = 2.5; #endif - // simple architecture independant gamma correction function. inline void gamma_correct_rgb(float *color, - float reff = 2.5, float system = system_gamma) + float reff = 2.5, float system = system_gamma) { - color[0] = pow(color[0], reff/system); - color[1] = pow(color[1], reff/system); - color[2] = pow(color[2], reff/system); + if (reff == system) + return; + + float tmp = reff/system; + color[0] = pow(color[0], tmp); + color[1] = pow(color[1], tmp); + color[2] = pow(color[2], tmp); }; inline void gamma_correct_c(float *color, - float reff = 2.5, float system = system_gamma) + float reff = 2.5, float system = system_gamma) { + if (reff == system) + return; + *color = pow(*color, reff/system); }; inline void gamma_restore_rgb(float *color, - float reff = 2.5, float system = system_gamma) + float reff = 2.5, float system = system_gamma) { - color[0] = pow(color[0], system/reff); - color[1] = pow(color[1], system/reff); - color[2] = pow(color[2], system/reff); + if (reff == system) + return; + + float tmp = system/reff; + color[0] = pow(color[0], tmp); + color[1] = pow(color[1], tmp); + color[2] = pow(color[2], tmp); }; inline void gamma_restore_c(float *color, - float reff = 2.5, float system = system_gamma) + float reff = 2.5, float system = system_gamma) { + if (reff == system) + return; + *color = pow(*color, system/reff); };