mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 19:34:36 +00:00
Fix bitfieldInsert according to GLSL spec
"bitfieldInsert inserts the bits least significant bits of insert into base at offset offset..."
This commit is contained in:
parent
77ce9b5b29
commit
d0ae3f966e
@ -269,7 +269,7 @@ namespace detail
|
|||||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldInsert' only accept integer values");
|
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldInsert' only accept integer values");
|
||||||
|
|
||||||
T const Mask = static_cast<T>(detail::mask(Bits) << Offset);
|
T const Mask = static_cast<T>(detail::mask(Bits) << Offset);
|
||||||
return (Base & ~Mask) | (Insert & Mask);
|
return (Base & ~Mask) | ((Insert << static_cast<T>(Offset)) & Mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bitfieldReverse
|
// bitfieldReverse
|
||||||
|
@ -41,9 +41,9 @@ namespace bitfieldInsert
|
|||||||
{0x00000000, 0xffffffff, 0, 32, 0xffffffff},
|
{0x00000000, 0xffffffff, 0, 32, 0xffffffff},
|
||||||
{0x00000000, 0xffffffff, 0, 31, 0x7fffffff},
|
{0x00000000, 0xffffffff, 0, 31, 0x7fffffff},
|
||||||
{0x00000000, 0xffffffff, 0, 0, 0x00000000},
|
{0x00000000, 0xffffffff, 0, 0, 0x00000000},
|
||||||
{0xff000000, 0x0000ff00, 8, 8, 0xff00ff00},
|
{0xff000000, 0x000000ff, 8, 8, 0xff00ff00},
|
||||||
{0xffff0000, 0x0000ffff, 16, 16, 0x00000000},
|
{0xffff0000, 0xffff0000, 16, 16, 0x00000000},
|
||||||
{0x0000ffff, 0xffff0000, 16, 16, 0xffffffff}
|
{0x0000ffff, 0x0000ffff, 16, 16, 0xffffffff}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int test()
|
static int test()
|
||||||
|
Loading…
Reference in New Issue
Block a user