diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-13 00:17:11 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-13 00:17:11 +0000 |
commit | 356e874050e5ad5af87b04a2bb01ce34a86640bb (patch) | |
tree | c3f2a5d548340821378f6d79b03c81bd63382282 /gfx/gl/camera.cpp | |
parent | Refactor BufferedLocationT to use a callback (diff) | |
download | ilt-356e874050e5ad5af87b04a2bb01ce34a86640bb.tar.bz2 ilt-356e874050e5ad5af87b04a2bb01ce34a86640bb.tar.xz ilt-356e874050e5ad5af87b04a2bb01ce34a86640bb.zip |
Send position and rotation matrix to GPU separately
Diffstat (limited to 'gfx/gl/camera.cpp')
-rw-r--r-- | gfx/gl/camera.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp index 6a0359c..15f76c4 100644 --- a/gfx/gl/camera.cpp +++ b/gfx/gl/camera.cpp @@ -8,10 +8,9 @@ Camera::Camera(Position3D pos, Angle fov, Angle aspect, Distance zNear, Distance zFar) : position {pos}, forward {::north}, up {::up}, near {zNear}, far {zFar}, - projection {glm::perspective(fov, aspect, zNear, zFar)}, - viewProjection {projection * glm::lookAt(position, position + forward, up)}, - inverseViewProjection {glm::inverse(viewProjection)} + projection {glm::perspective(fov, aspect, zNear, zFar)}, viewProjection {}, inverseViewProjection {} { + updateView(); } Ray @@ -25,8 +24,8 @@ Camera::unProject(const ScreenRelCoord & mouse) const void Camera::updateView() { - viewProjection = projection * glm::lookAt(position, position + forward, up); - inverseViewProjection = glm::inverse(viewProjection); + viewProjection = projection * glm::lookAt(origin, forward, up); + inverseViewProjection = glm::inverse(projection * glm::lookAt(position, position + forward, up)); } Direction3D |