parent
2fd6a9eeee
commit
8a54ba3462
6 changed files with 173 additions and 5 deletions
@ -0,0 +1,50 @@ |
|||||||
|
/// @ref gtc_color_encoding
|
||||||
|
/// @file glm/gtc/color_encoding.hpp
|
||||||
|
///
|
||||||
|
/// @see core (dependence)
|
||||||
|
/// @see gtc_color_encoding (dependence)
|
||||||
|
///
|
||||||
|
/// @defgroup gtc_color_encoding GLM_GTC_color_encoding
|
||||||
|
/// @ingroup gtc
|
||||||
|
///
|
||||||
|
/// @brief Allow to perform bit operations on integer values
|
||||||
|
///
|
||||||
|
/// <glm/gtc/color_encoding.hpp> need to be included to use these functionalities.
|
||||||
|
|
||||||
|
#pragma once |
||||||
|
|
||||||
|
// Dependencies
|
||||||
|
#include "../detail/setup.hpp" |
||||||
|
#include "../detail/precision.hpp" |
||||||
|
#include "../vec3.hpp" |
||||||
|
#include <limits> |
||||||
|
|
||||||
|
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED) |
||||||
|
# pragma message("GLM: GLM_GTC_color_encoding extension included") |
||||||
|
#endif |
||||||
|
|
||||||
|
namespace glm |
||||||
|
{ |
||||||
|
/// @addtogroup gtc_color_encoding
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/// Convert a linear sRGB color to D65 YUV.
|
||||||
|
template <typename T, precision P> |
||||||
|
GLM_FUNC_DECL tvec3<T, P> convertLinearSRGBToD65XYZ(tvec3<T, P> const& ColorLinearSRGB); |
||||||
|
|
||||||
|
/// Convert a D65 YUV color to linear sRGB.
|
||||||
|
template <typename T, precision P> |
||||||
|
GLM_FUNC_DECL tvec3<T, P> convertD65XYZToLinearSRGB(tvec3<T, P> const& ColorD65XYZ); |
||||||
|
|
||||||
|
/// Convert a D50 YUV color to D65 YUV.
|
||||||
|
template <typename T, precision P> |
||||||
|
GLM_FUNC_DECL tvec3<T, P> convertD50XYZToD65XYZ(tvec3<T, P> const& ColorD50XYZ); |
||||||
|
|
||||||
|
/// Convert a D65 YUV color to D50 YUV.
|
||||||
|
template <typename T, precision P> |
||||||
|
GLM_FUNC_DECL tvec3<T, P> convertD65XYZToD50XYZ(tvec3<T, P> const& ColorD65XYZ); |
||||||
|
|
||||||
|
/// @}
|
||||||
|
} //namespace glm
|
||||||
|
|
||||||
|
#include "color_encoding.inl" |
@ -0,0 +1,51 @@ |
|||||||
|
#include <glm/gtc/color_encoding.hpp> |
||||||
|
#include <glm/gtc/color_space.hpp> |
||||||
|
#include <glm/gtc/epsilon.hpp> |
||||||
|
#include <glm/gtc/constants.hpp> |
||||||
|
|
||||||
|
namespace srgb |
||||||
|
{ |
||||||
|
int test() |
||||||
|
{ |
||||||
|
int Error(0); |
||||||
|
|
||||||
|
glm::vec3 const ColorSourceRGB(1.0, 0.5, 0.0); |
||||||
|
|
||||||
|
{ |
||||||
|
glm::vec3 const ColorSRGB = glm::convertLinearSRGBToD65XYZ(ColorSourceRGB); |
||||||
|
glm::vec3 const ColorRGB = glm::convertD65XYZToLinearSRGB(ColorSRGB); |
||||||
|
Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1; |
||||||
|
} |
||||||
|
|
||||||
|
{ |
||||||
|
glm::vec3 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGB, 2.8f); |
||||||
|
glm::vec3 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB, 2.8f); |
||||||
|
Error += glm::all(glm::epsilonEqual(ColorSourceRGB, ColorRGB, 0.00001f)) ? 0 : 1; |
||||||
|
} |
||||||
|
|
||||||
|
glm::vec4 const ColorSourceRGBA(1.0, 0.5, 0.0, 1.0); |
||||||
|
|
||||||
|
{ |
||||||
|
glm::vec4 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGBA); |
||||||
|
glm::vec4 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB); |
||||||
|
Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1; |
||||||
|
} |
||||||
|
|
||||||
|
{ |
||||||
|
glm::vec4 const ColorSRGB = glm::convertLinearToSRGB(ColorSourceRGBA, 2.8f); |
||||||
|
glm::vec4 const ColorRGB = glm::convertSRGBToLinear(ColorSRGB, 2.8f); |
||||||
|
Error += glm::all(glm::epsilonEqual(ColorSourceRGBA, ColorRGB, 0.00001f)) ? 0 : 1; |
||||||
|
} |
||||||
|
|
||||||
|
return Error; |
||||||
|
} |
||||||
|
}//namespace srgb
|
||||||
|
|
||||||
|
int main() |
||||||
|
{ |
||||||
|
int Error(0); |
||||||
|
|
||||||
|
Error += srgb::test(); |
||||||
|
|
||||||
|
return Error; |
||||||
|
} |
Loading…
Reference in New Issue