-
Notifications
You must be signed in to change notification settings - Fork 944
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
Restrict use of color vec components to XYZW #2319
base: master
Are you sure you want to change the base?
Conversation
- Be able to compile using GLM_FORCE_XYZW_ONLY
I see your point. But this change will affect projects that depend on the I will let other chime in. |
Hmm I think it would work. Here I only changed the source files accessing .rgba components of glm::vectors to use .xyzw, but I am not enforcing GLM_FORCE_XYZW_ONLY itself nor touching any cinder defined types. Basically, is hard to see in the diff but if you look closely, these PR targets only usages INSIDE functions that take a glm::vector as a param. All colorT types still have rgba etc, publicly and also used internally. Overall, I think the public API reflects no changes at all with this PR.
Idk tests pass too, but I could be missing some insights like you say etc. |
Ok, so what you're saying is that vec2's, vec3's and vec4's still have their r, g, b and a properties? Or am I misunderstanding the purpose of the PR? I should try your branch for myself, of course, but am a little short on time. My understanding was that you'd like to get rid of the |
Yes, the vectors keep those components if you compile the code with no additional GLM defines. The purpose of this PR is to make the code compatible with the GLM_FORCE_XYZW_ONLY option, which does exactly what you said: In my case, as an end user I compile my code with this flag. But I also compile it along cinder to reflect modifications to cinder sources. So to my surprise, to be able to compile all the code with the same flags I just had to make these few edits to color.h and .cpp |
I think this makes sense - libcinder sources itself should try to make as few assumptions about the GLM macro settings that people are using if it can. The swizzle versions of vecs could easily be avoided in the internal code, so that users can choose their macros and recompile from source if they wish. |
That was my rationale behind sharing these changes in a PR :) In the case of swizzling, it is disabled by default and only available when compiling GLM with GLM_FORCE_SWIZZLE: https://github.com/g-truc/glm/blob/master/manual.md#-214-glm_force_swizzle-enable-swizzle-operators So cinder is not currently using it. In fact, there are no additional GLM defines. I think these two defines are the most common for people to use if any, so it seems resonable to keep the code compatible with them in mind. That would be:
As of now, this PR makes the minimal changes to comply with the stated above (just had to make it compatible with GLM_FORCE_XYZW_ONLY).
|
This allows to compile GLM using GLM_FORCE_XYZW_ONLY, which personally simplifies debugging etc.