00001 /* 00002 RenderStack Support library for OpenGL 3+ 00003 Copyright (C) 2010 Timo Suoranta 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00027 #ifndef COLOR_HPP 00028 #define COLOR_HPP 00029 00030 #include "renderstack/rs.h" 00031 #include "renderstack/vec3.hpp" 00032 00033 namespace renderstack { 00034 00036 class color 00037 { 00038 public: 00039 color(float r_, float g_, float b_) 00040 : r(r_) 00041 , g(g_) 00042 , b(b_) 00043 { 00044 } 00045 00046 color(vec3 const &v) 00047 : r(v.x) 00048 , g(v.y) 00049 , b(v.y) 00050 { 00051 } 00052 00053 float max_component() const; 00054 float min_component() const; 00055 vec3 hsv() const; 00056 00057 public: 00058 float r; 00059 float g; 00060 float b; 00061 }; 00062 00063 color make_color_from_hsv(vec3 const &hsv); 00064 00065 float srgb_to_linear (float cs); 00066 float linear_to_srgb (float cl); 00067 00068 } 00069 00070 #endif 00071