To carry out the mathematical operations we've just looked at in OpenGL and Vulkan projects, we will be using a header-only C++ mathematics library called GLM. This was initially developed to be used with OpenGL, but it can be used with Vulkan as well:
The latest version of GLM can be downloaded from https://glm.g-truc.net/0.9.9/index.html.
Apart from being able to create points and perform vector addition and subtraction, GLM can also define matrices, carry out matrix transforms, generate random numbers, and generate noise. The following are a few examples of how these functions can be carried out:
- To define 2D and 3D points, we will need to include #include <glm/glm.hpp>, which uses the glm namespace. To define a 2D point in space, we use the following code:
glm::vec2 p1 = glm::vec2(2.0f, 10.0f); Where the 2 arguments passed in are the...