Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

glm::mod() behaves differently for int and float with negative values #308

Closed
sponji opened this issue Feb 11, 2015 · 1 comment
Closed
Assignees
Milestone

Comments

@sponji
Copy link

sponji commented Feb 11, 2015

Seems like glm::mod<int>() gives wrong results for negative values. For example, glm::mod<int>(-1, 10) gives -1, but glm::mod<float>(-1.0f, 10.0f) gives 9.0f.

@Groovounet Groovounet added this to the GLM 0.9.7 milestone Feb 15, 2015
@Groovounet Groovounet self-assigned this Feb 15, 2015
Groovounet pushed a commit that referenced this issue Feb 15, 2015
@Groovounet
Copy link
Member

Hi,

The source of the issue is the rounding of 'mod' with GLSL which can't be translated into integers.

As a return, I removed the integer overload and added a fmod overload in glm/gtx_common.hpp which rounding supports float and int flavors.

This version is based on HLSL version of fmod. http://stackoverflow.com/questions/7610631/glsl-mod-vs-hlsl-fmod

This work has been done on master branch for GLM 0.9.7 release.

Thanks,
Christophe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants