SliderFloat3() problem
I have a global glm::vec3 LightIntensity parameter and I want to use it in the ImGui::SliderFloar3() so I can change each of the x, y, and z positions. I’ve tried:
ImGui::SliderFloat3("Light Intensity", (float*)&gLightIntensity, 0.0f, 1.0f);
But it keeps crashing? How do I get my LightIntensity vec3 into the float *v it is expecting?
David
The code looks right, assuming that glm::vec3 (whatever that is) contains 3 contiguous float.
What is the crash?
https://github.com/g-truc/glm/blob/316460408a5ef0338029a7c8f387ac49a2f1561c/glm/detail/type_vec3.hpp#L29
probably won't work?
It's an ugly mess because it is GLM but it should work if your precision is float, not double. It's just 3 raw float in the end.
Thanks guys got it working and the code above did actually work not sure what the crash was for but will keeps my eyes open and let you know if it happens again.
Chiming in in case anyone finds this page by googling like I did, in glm/gtc/type_ptr.hpp there's glm::value_ptr(someVector) that does (float*)& for you.