glm::rotation syntax help

Trying to rotate x degrees around a given vector

glm::vec3 myRotationAxis( 3, 6, 9);
glm::rotate( 45, myRotationAxis );

but am getting an error:

.\src\main.cpp:128:34: error: no matching function for call to ‘rotate(int, glm::vec3&)’
glm::rotate( 45, myRotationAxis );

Am I supposed to have a third parameter g.g. (model,45,myRotationAxis)?

glm::rotate is defined such that the angle and axis use the same base type; so assuming that glm::vec3 is a vector of 3 floats, then the angle must also be a float.

What your compiler is telling you is that it’s interpreting the angle as an int, and therefore that there is no matching overload.

To fix, you need to tell the compiler that you want the angle to be interpreted as a float, either via a cast or by appending the “f” suffix; the latter should be preferable. So:

glm::rotate( 45.0f, myRotationAxis );

[QUOTE=mhagain;1288223]glm::rotate is defined such that the angle and axis use the same base type; so assuming that glm::vec3 is a vector of 3 floats, then the angle must also be a float.

What your compiler is telling you is that it’s interpreting the angle as an int, and therefore that there is no matching overload.

To fix, you need to tell the compiler that you want the angle to be interpreted as a float, either via a cast or by appending the “f” suffix; the latter should be preferable. So:

glm::rotate( 45.0f, myRotationAxis );[/QUOTE]

OK it worked at first but then something happened.
I wrote a little program below to set the vector and to then print its contents. I already declared myRotationAxis elsewhere in the program.

myRotationAxis = {3.0f,5.0f,7.0f};
print_vector3(myRotationAxis);
rotate(45.0f, myRotationAxis);
print_vector3(myRotationAxis);

output:
vec3(3.000000, 5.000000, 7.000000)
vec3(3.000000, 5.000000, 7.000000)

myRotationAxis should be different from each other, but it seems the rotation isn’t having an effect

function call:

glm::vec3 print_vector3(glm::vec3 test_vector3)
{
std::cout<<glm::to_string(test_vector3)<<std::endl;
return test_vector3;
}