3 // -- This header file contains color related functions
5 // Copyright (C) 2003 FlightGear Flight Simulator
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef _SG_COLORS_HXX
25 #define _SG_COLORS_HXX 1
29 #if defined( macintosh )
30 const float system_gamma = 1.4;
33 const float system_gamma = 1.7;
36 const float system_gamma = 2.5;
40 // simple architecture independant gamma correction function.
41 inline void gamma_correct_rgb(float *color,
42 float reff = 2.5, float system = system_gamma)
44 color[0] = pow(color[0], reff/system);
45 color[1] = pow(color[1], reff/system);
46 color[2] = pow(color[2], reff/system);
49 inline void gamma_correct_c(float *color,
50 float reff = 2.5, float system = system_gamma)
52 *color = pow(*color, reff/system);
55 inline void gamma_restore_rgb(float *color,
56 float reff = 2.5, float system = system_gamma)
58 color[0] = pow(color[0], system/reff);
59 color[1] = pow(color[1], system/reff);
60 color[2] = pow(color[2], system/reff);
63 inline void gamma_restore_c(float *color,
64 float reff = 2.5, float system = system_gamma)
66 *color = pow(*color, system/reff);
70 #endif // _SG_COLORS_HXX