1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
// Declaration in .h file:
struct ModelViewProjection
{
float fov, aspect, near, far;
glm::mat4 projection, view, model;
ModelViewProjection(float field_of_view, float aspect_ratio, float zNear, float zFar);
glm::mat4 GetMVP();
};
// Definition in .cpp file:
ModelViewProjection::ModelViewProjection(float field_of_view, float aspect_ratio, float zNear, float zFar)
: fov(field_of_view), aspect(aspect_ratio), near(zNear), far(zFar),
projection(glm::perspective(glm::radians(fov), aspect, near, far)),
view(glm::translate(glm::mat4(1.0F), glm::vec3(0.0F, 0.0F, 0.0F))),
model(glm::translate(glm::mat4(1.0F), glm::vec3(0.0F, 0.0F, 0.0F))) {}
|