Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix bitfieldInsert according to GLSL spec #818

Merged
merged 1 commit into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion glm/detail/func_integer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ namespace detail
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_integer, "'bitfieldInsert' only accept integer values");

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
Expand Down
6 changes: 3 additions & 3 deletions test/core/core_func_integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ namespace bitfieldInsert
{0x00000000, 0xffffffff, 0, 32, 0xffffffff},
{0x00000000, 0xffffffff, 0, 31, 0x7fffffff},
{0x00000000, 0xffffffff, 0, 0, 0x00000000},
{0xff000000, 0x0000ff00, 8, 8, 0xff00ff00},
{0xffff0000, 0x0000ffff, 16, 16, 0x00000000},
{0x0000ffff, 0xffff0000, 16, 16, 0xffffffff}
{0xff000000, 0x000000ff, 8, 8, 0xff00ff00},
{0xffff0000, 0xffff0000, 16, 16, 0x00000000},
{0x0000ffff, 0x0000ffff, 16, 16, 0xffffffff}
};

static int test()
Expand Down