gtx_color_space.cpp 766 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <glm/ext/vector_relational.hpp>
  2. #include <glm/ext/scalar_constants.hpp>
  3. #define GLM_ENABLE_EXPERIMENTAL
  4. #include <glm/gtx/color_space.hpp>
  5. static int test_hsv()
  6. {
  7. int Error = 0;
  8. glm::vec3 colorHSV = glm::hsvColor(glm::vec3(1.0f, 0.5f, 0.0f));
  9. glm::vec3 colorRGB = glm::rgbColor(colorHSV);
  10. Error += glm::all(glm::equal(colorRGB, glm::vec3(1.0f, 0.5f, 0.0f), glm::epsilon<float>())) ? 0 : 1;
  11. return Error;
  12. }
  13. static int test_saturation()
  14. {
  15. int Error = 0;
  16. glm::vec4 Color = glm::saturation(1.0f, glm::vec4(1.0, 0.5, 0.0, 1.0));
  17. Error += glm::all(glm::equal(Color, glm::vec4(1.0, 0.5, 0.0, 1.0), glm::epsilon<float>())) ? 0 : 1;
  18. return Error;
  19. }
  20. int main()
  21. {
  22. int Error(0);
  23. Error += test_hsv();
  24. Error += test_saturation();
  25. return Error;
  26. }