<commit_before>// 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_rgb(float *color,
                              float reff = 2.5, float system = system_gamma)
{
    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);

    if ( color[0] < 0.0 ) { color[0] = 0.0; }
    if ( color[1] < 0.0 ) { color[1] = 0.0; }
    if ( color[2] < 0.0 ) { color[2] = 0.0; }
    if ( color[0] > 1.0 ) { color[0] = 1.0; }
    if ( color[1] > 1.0 ) { color[1] = 1.0; }
    if ( color[2] > 1.0 ) { color[2] = 1.0; }
};

inline void gamma_correct_c(float *color,
                            float reff = 2.5, float system = system_gamma)
{
   if (reff == system)
      return;

   *color = pow(*color, reff/system);
   if ( *color < 0.0 ) { *color = 0.0; }
   if ( *color > 1.0 ) { *color = 1.0; }
};

inline void gamma_restore_rgb(float *color,
                              float reff = 2.5, float system = system_gamma)
{
    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);

    if ( color[0] < 0.0 ) { color[0] = 0.0; }
    if ( color[1] < 0.0 ) { color[1] = 0.0; }
    if ( color[2] < 0.0 ) { color[2] = 0.0; }
    if ( color[0] > 1.0 ) { color[0] = 1.0; }
    if ( color[1] > 1.0 ) { color[1] = 1.0; }
    if ( color[2] > 1.0 ) { color[2] = 1.0; }
};

inline void gamma_restore_c(float *color,
                            float reff = 2.5, float system = system_gamma)
{
   if (reff == system)
      return;

   *color = pow(*color, system/reff);
   if ( *color < 0.0 ) { *color = 0.0; }
   if ( *color > 1.0 ) { *color = 1.0; }
};


#endif // _SG_COLORS_HXX
<commit_msg>These test should not be needed when properly using OpnGL colors.<commit_after>// 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_rgb(float *color,
                              float reff = 2.5, float system = system_gamma)
{
    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)
{
   if (reff == system)
      return;

   *color = pow(*color, reff/system);
};

inline void gamma_restore_rgb(float *color,
                              float reff = 2.5, float system = system_gamma)
{
    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)
{
   if (reff == system)
      return;

   *color = pow(*color, system/reff);
};


#endif // _SG_COLORS_HXX

{'fraction_non_alphanumeric': 0.13339805825242718, 'fraction_numerical': 0.03262135922330097, 'mean_word_length': 2.5232558139534884, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2728321', 'n_tokens_mistral': 1801, 'n_tokens_neox': 1706, 'n_words': 588}