added ClampU8/ClampU16
This commit is contained in:
parent
4826d5d9dc
commit
b0804710ee
@ -1,5 +1,7 @@
|
||||
#ifndef HGL_Primary_Mathematics_INCLUDE
|
||||
#define HGL_Primary_Mathematics_INCLUDE
|
||||
|
||||
#include<hgl/platform/Platform.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
@ -50,5 +52,19 @@ namespace hgl
|
||||
{
|
||||
return Clamp<T>(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
|
||||
|
Loading…
x
Reference in New Issue
Block a user