3#include <glm/gtc/matrix_transform.hpp>
27static_assert(
sizeof(ViewTransform) == 128,
28 "ViewTransform must be exactly 128 bytes (Vulkan minimum push constant size)");
39 const glm::vec3& target,
40 const glm::vec3& up = glm::vec3(0.0F, 1.0F, 0.0F))
42 return { .
view = glm::lookAt(eye, target, up) };
59 return { .
projection = glm::perspective(fov_radians, aspect, near, far) };
73 float left,
float right,
74 float bottom,
float top,
75 float near = -1.0F,
float far = 1.0F)
77 return { .
projection = glm::ortho(left, right, bottom, top, near, far) };
93 const glm::vec3& target,
98 const glm::vec3& up = glm::vec3(0.0F, 1.0F, 0.0F))
101 .
view = glm::lookAt(eye, target, up),
102 .projection = glm::perspective(fov_radians, aspect, near, far)
ViewTransform look_at(const glm::vec3 &eye, const glm::vec3 &target, const glm::vec3 &up=glm::vec3(0.0F, 1.0F, 0.0F))
Construct view matrix from eye position, target, and up vector.
ViewTransform look_at_perspective(const glm::vec3 &eye, const glm::vec3 &target, float fov_radians, float aspect, float near, float far, const glm::vec3 &up=glm::vec3(0.0F, 1.0F, 0.0F))
Construct complete ViewTransform from look-at and perspective parameters.
ViewTransform ortho(float left, float right, float bottom, float top, float near=-1.0F, float far=1.0F)
Construct orthographic projection matrix.
ViewTransform perspective(float fov_radians, float aspect, float near, float far)
Construct perspective projection matrix.