redefined include files of Color,half float
This commit is contained in:
@@ -76,56 +76,7 @@ namespace hgl
|
||||
|
||||
return double(floor(value*per))/per;
|
||||
}
|
||||
|
||||
inline const float half_to_float(const uint16 &h)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
uint32 u;
|
||||
}x;
|
||||
|
||||
x.u=(((h&0x8000)<<16) | (((h&0x7c00)+0x1C000)<<13) | ((h&0x03FF)<<13));
|
||||
|
||||
return x.f;
|
||||
}
|
||||
|
||||
inline void half_to_float(uint32 *target,const uint16 *source,uint32 count)
|
||||
{
|
||||
while (count--)
|
||||
{
|
||||
*target = (((*source & 0x8000) << 16) | (((*source & 0x7c00) + 0x1C000) << 13) | ((*source & 0x03FF) << 13));
|
||||
++target;
|
||||
++source;
|
||||
}
|
||||
}
|
||||
|
||||
inline void half_to_uint16(uint16 *target, const uint16 *source, uint32 count)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
uint32 u;
|
||||
}x;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
x.u = (((*source & 0x8000) << 16) | (((*source & 0x7c00) + 0x1C000) << 13) | ((*source & 0x03FF) << 13));
|
||||
|
||||
*target=x.f*65535;
|
||||
|
||||
++target;
|
||||
++source;
|
||||
}
|
||||
}
|
||||
|
||||
inline constexpr uint16 float_to_half(const float &f)
|
||||
{
|
||||
const uint32 x = *((uint32 *)&f);
|
||||
|
||||
return ((x>>16)&0x8000)|((((x&0x7f800000)-0x38000000)>>13)&0x7c00)|((x>>13)&0x03ff);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 正圆面积计算
|
||||
* @param radius 半径
|
||||
|
Reference in New Issue
Block a user