From 42b4ec310f8070a7fe9e4ef97b09e6284340e6f5 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sat, 17 May 2003 12:43:47 +0000 Subject: [PATCH] Add a gamma correction function --- simgear/screen/Makefile.am | 4 +-- simgear/screen/colors.hxx | 50 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 simgear/screen/colors.hxx diff --git a/simgear/screen/Makefile.am b/simgear/screen/Makefile.am index 20ccf043..c5c05dcc 100644 --- a/simgear/screen/Makefile.am +++ b/simgear/screen/Makefile.am @@ -12,10 +12,10 @@ IMAGE_SERVER_INCL = IMAGE_SERVER_SRCS = endif -noinst_HEADERS = \ - colours.h +noinst_HEADERS = colours.h include_HEADERS = \ + colors.hxx \ texture.hxx \ $(IMAGE_SERVER_INCL) \ screen-dump.hxx \ diff --git a/simgear/screen/colors.hxx b/simgear/screen/colors.hxx new file mode 100644 index 00000000..13c6ef3f --- /dev/null +++ b/simgear/screen/colors.hxx @@ -0,0 +1,50 @@ +// colours.h +// +// -- This header file contains color related functions +// +// Copyright (C) 2003 FlightGear Flight Simulator +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// 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. +// +// $Id$ + + +#ifndef _SG_COLORS_HXX +#define _SG_COLORS_HXX 1 + +#include + +#if defined( macintosh ) +const float system_gamma = 1.4; + +#elif defined (sgi) +const float system_gamma = 1.7; + +#else // others +const float system_gamma = 2.5; +#endif + + +// simple architecture independant gamma correction function. +inline void gamma_correct(float *color, + 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); +}; + +#endif // _SG_COLORS_HXX + -- 2.39.5