summaryrefslogtreecommitdiff
path: root/gfx/gl/camera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/gl/camera.cpp')
-rw-r--r--gfx/gl/camera.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp
index 1c46200..994d8ab 100644
--- a/gfx/gl/camera.cpp
+++ b/gfx/gl/camera.cpp
@@ -7,12 +7,7 @@ Camera::Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar)
position {pos}, forward {::north}, up {::up}, fov {fov}, aspect {aspect}, near {zNear}, far {zFar},
projection {glm::perspective(fov, aspect, zNear, zFar)}
{
-}
-
-glm::mat4
-Camera::getViewProjection() const
-{
- return projection * glm::lookAt(position, position + forward, up);
+ updateView();
}
Ray
@@ -22,3 +17,10 @@ Camera::unProject(const glm::vec2 & mouse) const
return {position,
glm::normalize(glm::unProject(mouse ^ 1, glm::lookAt(::origin, forward, up), projection, screen))};
}
+
+void
+Camera::updateView()
+{
+ view = glm::lookAt(position, position + forward, up);
+ viewProjection = projection * view;
+}