I crossed a very simple error when I started using glm (in VS2010). I have this short code:
glm::mat4 translate = glm::translate(glm::mat4(1.f), glm::vec3(2.f, 0.f, 0.f)); glm::vec4 vector(1.f,1.f,1.f,0.f); glm::vec4 transformedVector = translate * vector;
The result of the transformed Vector coincides with its original value (1.f, 1.f, 1.f, 0.f). I donβt know what is missing here. I tried the rotation matrix and it works fine, the point is correctly converted.
glm::mat4 rotate = glm::rotate(glm::mat4(1.f), 90.f, glm::vec3(0.f, 0.f, 1.f)); glm::vec4 vector(1.f, 1.f, 1.f, 0.f); glm::vec4 transformedVector = rotate * vector;
Ok, I figured out the problem. I would like to translate the vertex not into a vector, in this case I had to set the value of w to 1.
c ++ glm-math
user2661133
source share