I am trying to create a simply matrix to use in my shader (new to OpenGL 3.x), however, I am getting errors from GLM.
Here is one thing I tried doing:
glm::mat4 scaleMatrix = glm::scale(2.0f, 2.0f, 2.0f);
Unfortunately, the compiler (MinGW) gives me the error:
error: no matching function for call to 'scale(float, float, float)'
candiate is:
template<class T, glm::precision P> glm::detail::tmat4x4<T, P> glm::scale(const
glm::detail::tmat4x4<T, P>&, const glm::detail::tvec3<T, P>&)
When I click on the error in the IDE it takes me to the first line below in "matrix_transform.inl":
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> scale
(
detail::tmat4x4<T, P> const & m,
detail::tvec3<T, P> const & v
)
Why am I getting this error?
At least in the current version of glm (0.9.6) there is no glm::scale function taking three floats as argument. There is only one overload that takes a matrix which should be scaled a vector containing the scaling factors.
The correct solution for your code sample would (according to here) be
glm::mat4 scaleMatrix = glm::scale(glm::mat4(1.0f), glm::vec3(2.0f, 2.0f, 2.0f));
Edit: I just stumbled over this page, and it looks as if there has been a glm:scale(float,float,float) overload in 0.9.4.
Edit: As pointed out by sajas, there is a second overload of the glm::scale function available. This one would take only a glm::vec3 and might be more what you were looking for.
glm::mat4 scaleMatrix = glm::scale(glm::vec3(2.0f, 2.0f, 2.0f));