Add a gamma correction function

This commit is contained in:
ehofman
2003-05-17 12:43:47 +00:00
parent 4ea676b229
commit 42b4ec310f
2 changed files with 52 additions and 2 deletions

View File

@@ -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 \

50
simgear/screen/colors.hxx Normal file
View File

@@ -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 <math.h>
#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