We will create a basic camera class so that we can set the camera's position and set the view and projection matrices. This class will be very similar to the camera class created for the OpenGL project. The camera.h file is as follows:
#pragma once #define GLM_FORCE_RADIAN #include <glm\glm.hpp> #include <glm\gtc\matrix_transform.hpp> class Camera { public: void init(float FOV, float width, float height, float nearplane,
float farPlane); void setCameraPosition(glm::vec3 position); glm::mat4 getViewMatrix(); glm::mat4 getprojectionMatrix(); private: glm::mat4 projectionMatrix; glm::mat4 viewMatrix; glm::vec3 cameraPos; };
It has an init function, which takes the FOV, width, and height of the viewport, and the near and far planes to construct the projection matrix. We have a setCameraPosition...