diff --git a/inc/hgl/math/PrimaryMathematics.h b/inc/hgl/math/PrimaryMathematics.h index d360619..0b7d366 100644 --- a/inc/hgl/math/PrimaryMathematics.h +++ b/inc/hgl/math/PrimaryMathematics.h @@ -1,5 +1,7 @@ #ifndef HGL_Primary_Mathematics_INCLUDE #define HGL_Primary_Mathematics_INCLUDE + +#include namespace hgl { /** @@ -50,5 +52,19 @@ namespace hgl { return Clamp(value,0,1); } + + inline constexpr uint8 ClampU8(const int &value) + { + if(value<0)return 0; + if(value>0xFF)return 0xFF; + return value; + } + + inline constexpr uint16 ClampU16(const int value) + { + if(value<0)return 0; + if(value>0xFFFF)return 0xFFFF; + return value; + } }//namespace hgl #endif//HGL_Primary_Mathematics_INCLUDE