this is my code
glm::vec3 v(4, -6, 7);
glm::vec3 twiceV = 2 * v;
I have included glm Stable and experimental glm extensions.
Why I cannot use int * vec
?
this is my code
glm::vec3 v(4, -6, 7);
glm::vec3 twiceV = 2 * v;
I have included glm Stable and experimental glm extensions.
Why I cannot use int * vec
?
This is because there is no global overloaded operator of the form
glm::vec3 operator*(int, const glm::vec3&)
Does v * 2
work by any chance? (A member function operator overload would suffice for that.)
Or perhaps even 2f * v
, which would then require the first parameter of the overloaded *
operator to be a float
?
2
is an integer, while the elements of aglm::vec3
are floats. Try this instead:I would also pass floating-point values to the constructor (
4.0f
), just to make it explicit that you're dealing with floats.Alternatively, you can use an integer vector
glm::ivec3
:Of course, an integer vector will only hold integer values, which might not be what you want.