September 2018
Intermediate to advanced
472 pages
15h 36m
English
To use the GLM libraries, include the core header file, and headers for any extensions. For this example, we'll include the matrix transform extension:
#include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp>
The GLM classes are available in the glm namespace. The following is an example of how you might go about making use of some of them:
glm::vec4 position = glm::vec4( 1.0f, 0.0f, 0.0f, 1.0f ); glm::mat4 view = glm::lookAt( glm::vec3(0.0f, 0.0f, 5.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f) ); glm::mat4 model(1.0f); // The identity matrix model = glm::rotate( model, 90.0f, glm::vec3(0.0f,1.0f,0.0) ); glm::mat4 mv = view * model; glm::vec4 transformed = mv * position;
Read now
Unlock full access