imgui icon indicating copy to clipboard operation
imgui copied to clipboard

SliderFloat3() problem

Open djones4487169 opened this issue 10 years ago • 5 comments

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

djones4487169 avatar Aug 15 '16 10:08 djones4487169

The code looks right, assuming that glm::vec3 (whatever that is) contains 3 contiguous float.

What is the crash?

ocornut avatar Aug 15 '16 10:08 ocornut

https://github.com/g-truc/glm/blob/316460408a5ef0338029a7c8f387ac49a2f1561c/glm/detail/type_vec3.hpp#L29

probably won't work?

MrSapps avatar Aug 15 '16 11:08 MrSapps

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.

ocornut avatar Aug 15 '16 11:08 ocornut

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.

djones4487169 avatar Aug 15 '16 11:08 djones4487169

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.

ghost avatar Jan 07 '23 22:01 ghost