summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-29 18:50:02 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-29 18:50:02 +0100
commit4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17 (patch)
tree6f4bd0c999e3b4a11410aed234622e80842261ad /gfx/gl
parentLookup material details once in the vertex shader (diff)
downloadilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.tar.bz2
ilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.tar.xz
ilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.zip
Dunno how, but some DOS new lines got in here!
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/camera.h156
1 files changed, 78 insertions, 78 deletions
diff --git a/gfx/gl/camera.h b/gfx/gl/camera.h
index b5611f8..5c168e7 100644
--- a/gfx/gl/camera.h
+++ b/gfx/gl/camera.h
@@ -1,78 +1,78 @@
-#pragma once
-
-#include <glm/glm.hpp>
-#include <maths.h>
-#include <ray.hpp>
-
-class Camera {
-public:
- Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar);
-
- [[nodiscard]] glm::mat4
- getViewProjection() const
- {
- return viewProjection;
- }
- [[nodiscard]] Ray unProject(const glm::vec2 &) const;
-
- void
- setPosition(const glm::vec3 & p)
- {
- position = p;
- updateView();
- }
- void
- setForward(const glm::vec3 & f)
- {
- setForward(f, upFromForward(f));
- }
- void
- setForward(const glm::vec3 & f, const glm::vec3 & u)
- {
- forward = f;
- up = u;
- updateView();
- }
- void
- setView(const glm::vec3 & p, const glm::vec3 & f)
- {
- position = p;
- setForward(f);
- }
- void
- setView(const glm::vec3 & p, const glm::vec3 & f, const glm::vec3 & u)
- {
- position = p;
- setView(f, u);
- }
- void
- lookAt(const glm::vec3 & target)
- {
- setForward(glm::normalize(target - position));
- }
- [[nodiscard]] auto
- getForward() const
- {
- return forward;
- }
- [[nodiscard]] auto
- getPosition() const
- {
- return position;
- }
-
- [[nodiscard]] std::array<glm::vec4, 4> extentsAtDist(float) const;
-
- [[nodiscard]] static glm::vec3 upFromForward(const glm::vec3 & forward);
-
-private:
- void updateView();
-
- glm::vec3 position;
- glm::vec3 forward;
- glm::vec3 up;
-
- float near, far;
- glm::mat4 projection;
- glm::mat4 viewProjection, inverseViewProjection;
-};
+#pragma once
+
+#include <glm/glm.hpp>
+#include <maths.h>
+#include <ray.hpp>
+
+class Camera {
+public:
+ Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar);
+
+ [[nodiscard]] glm::mat4
+ getViewProjection() const
+ {
+ return viewProjection;
+ }
+ [[nodiscard]] Ray unProject(const glm::vec2 &) const;
+
+ void
+ setPosition(const glm::vec3 & p)
+ {
+ position = p;
+ updateView();
+ }
+ void
+ setForward(const glm::vec3 & f)
+ {
+ setForward(f, upFromForward(f));
+ }
+ void
+ setForward(const glm::vec3 & f, const glm::vec3 & u)
+ {
+ forward = f;
+ up = u;
+ updateView();
+ }
+ void
+ setView(const glm::vec3 & p, const glm::vec3 & f)
+ {
+ position = p;
+ setForward(f);
+ }
+ void
+ setView(const glm::vec3 & p, const glm::vec3 & f, const glm::vec3 & u)
+ {
+ position = p;
+ setView(f, u);
+ }
+ void
+ lookAt(const glm::vec3 & target)
+ {
+ setForward(glm::normalize(target - position));
+ }
+ [[nodiscard]] auto
+ getForward() const
+ {
+ return forward;
+ }
+ [[nodiscard]] auto
+ getPosition() const
+ {
+ return position;
+ }
+
+ [[nodiscard]] std::array<glm::vec4, 4> extentsAtDist(float) const;
+
+ [[nodiscard]] static glm::vec3 upFromForward(const glm::vec3 & forward);
+
+private:
+ void updateView();
+
+ glm::vec3 position;
+ glm::vec3 forward;
+ glm::vec3 up;
+
+ float near, far;
+ glm::mat4 projection;
+ glm::mat4 viewProjection, inverseViewProjection;
+};