PDA

View Full Version : How should I cast a glm::vec2 to glm::ivec2?



ricardo_ruiz
09-26-2009, 04:06 AM
Hi everybody!

How should I cast a glm::vec2 to glm::ivec2? or vice versa.

I guess this is not correct
glm::vec2 v=glm::vec2(1.0,1.0)+(glm::vec)glm::ivec2(2,2);

What do you think? BTW, I'm using GLM math library.

Thanks a lot for your help.

marshats
09-26-2009, 09:07 AM
You are missing a "2" in your cast. Replace "(glm::vec)" in the cast to "(glm::vec2)" as



glm::vec2 v=glm::vec2(1.0,1.0)+(glm::vec2)glm::ivec2(2,2);


and to go in reverse


glm::ivec2 v=(glm::ivec2)glm::vec2(1.0,1.0)+glm::ivec2(2,2);