summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-07 02:51:42 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-07 02:51:42 +0000
commitd6e99a696aa582b81018078b68f6600c8030d643 (patch)
tree5c1451bbc76c31f78ddd169fca7780a0943f5910 /gfx/gl
parentReformat with new clang-format (diff)
downloadilt-d6e99a696aa582b81018078b68f6600c8030d643.tar.bz2
ilt-d6e99a696aa582b81018078b68f6600c8030d643.tar.xz
ilt-d6e99a696aa582b81018078b68f6600c8030d643.zip
WIP typedefing all the things - headers
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/bufferedLocation.h14
-rw-r--r--gfx/gl/camera.cpp4
-rw-r--r--gfx/gl/camera.h25
-rw-r--r--gfx/gl/sceneRenderer.cpp2
-rw-r--r--gfx/gl/sceneRenderer.h10
-rw-r--r--gfx/gl/sceneShader.h5
-rw-r--r--gfx/gl/shadowMapper.cpp2
-rw-r--r--gfx/gl/shadowMapper.h9
-rw-r--r--gfx/gl/uiShader.h3
9 files changed, 39 insertions, 35 deletions
diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h
index 8096489..39d3139 100644
--- a/gfx/gl/bufferedLocation.h
+++ b/gfx/gl/bufferedLocation.h
@@ -8,7 +8,7 @@
class BufferedLocation {
public:
- BufferedLocation(glm::vec3 = {}, glm::vec3 = {});
+ BufferedLocation(Position3D = {}, Rotation3D = {});
BufferedLocation(const Location &);
virtual ~BufferedLocation() = default;
@@ -16,13 +16,13 @@ public:
operator const Location &() const;
- glm::vec3 position() const;
- glm::vec3 rotation() const;
- void setPosition(glm::vec3, bool update = true);
- void setRotation(glm::vec3, bool update = true);
- void setLocation(glm::vec3, glm::vec3);
+ [[nodiscard]] Position3D position() const;
+ [[nodiscard]] Rotation3D rotation() const;
+ void setPosition(Position3D, bool update = true);
+ void setRotation(Rotation3D, bool update = true);
+ void setLocation(Position3D, Rotation3D);
- glm::mat4 getTransform() const;
+ [[nodiscard]] glm::mat4 getTransform() const;
private:
virtual void updateBuffer() = 0;
diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp
index c4c9544..80feab4 100644
--- a/gfx/gl/camera.cpp
+++ b/gfx/gl/camera.cpp
@@ -5,7 +5,7 @@
#include <maths.h>
#include <ray.h>
-Camera::Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar) :
+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)},
@@ -14,7 +14,7 @@ Camera::Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar)
}
Ray
-Camera::unProject(const glm::vec2 & mouse) const
+Camera::unProject(const ScreenRelCoord & mouse) const
{
static constexpr const glm::vec4 screen {0, 0, 1, 1};
const auto mouseProjection = glm::lookAt(::origin, forward, up);
diff --git a/gfx/gl/camera.h b/gfx/gl/camera.h
index 7956ec3..469df0d 100644
--- a/gfx/gl/camera.h
+++ b/gfx/gl/camera.h
@@ -1,12 +1,13 @@
#pragma once
+#include "config/types.h"
#include <glm/glm.hpp>
#include <maths.h>
#include <ray.h>
class Camera {
public:
- Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar);
+ Camera(Position3D, Angle fov, Angle aspect, Distance zNear, Distance zFar);
[[nodiscard]] glm::mat4
getViewProjection() const
@@ -14,23 +15,23 @@ public:
return viewProjection;
}
- [[nodiscard]] Ray unProject(const glm::vec2 &) const;
+ [[nodiscard]] Ray unProject(const ScreenRelCoord &) const;
void
- setPosition(const glm::vec3 & p)
+ setPosition(const Position3D & p)
{
position = p;
updateView();
}
void
- setForward(const glm::vec3 & f)
+ setForward(const Direction3D & f)
{
setForward(f, upFromForward(f));
}
void
- setForward(const glm::vec3 & f, const glm::vec3 & u)
+ setForward(const Direction3D & f, const Direction3D & u)
{
forward = f;
up = u;
@@ -38,21 +39,21 @@ public:
}
void
- setView(const glm::vec3 & p, const glm::vec3 & f)
+ setView(const Position3D & p, const Direction3D & f)
{
position = p;
setForward(f);
}
void
- setView(const glm::vec3 & p, const glm::vec3 & f, const glm::vec3 & u)
+ setView(const Position3D & p, const Direction3D & f, const Direction3D & u)
{
position = p;
setView(f, u);
}
void
- lookAt(const glm::vec3 & target)
+ lookAt(const Position3D & target)
{
setForward(glm::normalize(target - position));
}
@@ -71,14 +72,14 @@ public:
[[nodiscard]] std::array<glm::vec4, 4> extentsAtDist(float) const;
- [[nodiscard]] static glm::vec3 upFromForward(const glm::vec3 & forward);
+ [[nodiscard]] static Direction3D upFromForward(const Direction3D & forward);
private:
void updateView();
- glm::vec3 position;
- glm::vec3 forward;
- glm::vec3 up;
+ Position3D position;
+ Direction3D forward;
+ Direction3D up;
float near, far;
glm::mat4 projection;
diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp
index 5799daf..218cf6d 100644
--- a/gfx/gl/sceneRenderer.cpp
+++ b/gfx/gl/sceneRenderer.cpp
@@ -14,7 +14,7 @@ static constexpr const std::array<const glm::i8vec4, 4> displayVAOdata {{
{1, -1, 1, 0},
}};
-SceneRenderer::SceneRenderer(glm::ivec2 s, GLuint o) :
+SceneRenderer::SceneRenderer(ScreenAbsCoord s, GLuint o) :
camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, ratio(s), 0.1F, 10000.0F}, size {s}, output {o},
lighting {lighting_vs, lighting_fs}, shadowMapper {{2048, 2048}}
{
diff --git a/gfx/gl/sceneRenderer.h b/gfx/gl/sceneRenderer.h
index 55df84d..87f474b 100644
--- a/gfx/gl/sceneRenderer.h
+++ b/gfx/gl/sceneRenderer.h
@@ -11,18 +11,18 @@
class SceneRenderer {
public:
- explicit SceneRenderer(glm::ivec2 size, GLuint output);
+ explicit SceneRenderer(ScreenAbsCoord size, GLuint output);
void render(const SceneProvider &) const;
- void setAmbientLight(const glm::vec3 & colour) const;
- void setDirectionalLight(const glm::vec3 & colour, const glm::vec3 & direction, const SceneProvider &) const;
+ void setAmbientLight(const RGB & colour) const;
+ void setDirectionalLight(const RGB & colour, const Direction3D & direction, const SceneProvider &) const;
Camera camera;
private:
void renderQuad() const;
- glm::ivec2 size;
+ ScreenAbsCoord size;
GLuint output;
glFrameBuffer gBuffer;
glTexture gPosition, gNormal, gAlbedoSpec, gIllumination;
@@ -39,7 +39,7 @@ private:
DirectionalLightProgram();
using Program::use;
- void setDirectionalLight(const glm::vec3 &, const glm::vec3 &, const std::span<const glm::mat4x4>,
+ void setDirectionalLight(const RGB &, const Direction3D &, const std::span<const glm::mat4x4>,
const std::span<const glm::vec4>, std::size_t maps) const;
private:
diff --git a/gfx/gl/sceneShader.h b/gfx/gl/sceneShader.h
index ead184e..d1c6ef2 100644
--- a/gfx/gl/sceneShader.h
+++ b/gfx/gl/sceneShader.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "program.h"
#include <glArrays.h>
@@ -52,7 +53,7 @@ class SceneShader {
public:
PointLightShader();
- void add(const glm::vec3 & position, const glm::vec3 & colour, const float kq) const;
+ void add(const Position3D & position, const RGB & colour, const float kq) const;
private:
UniformLocation colourLoc;
@@ -65,7 +66,7 @@ class SceneShader {
public:
SpotLightShader();
- void add(const glm::vec3 & position, const glm::vec3 & direction, const glm::vec3 & colour, const float kq,
+ void add(const Position3D & position, const Direction3D & direction, const RGB & colour, const float kq,
const float arc) const;
private:
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp
index 79b39c0..58f65c4 100644
--- a/gfx/gl/shadowMapper.cpp
+++ b/gfx/gl/shadowMapper.cpp
@@ -15,7 +15,7 @@
#include <tuple>
#include <vector>
-ShadowMapper::ShadowMapper(const glm::ivec2 & s) :
+ShadowMapper::ShadowMapper(const TextureAbsCoord & s) :
fixedPoint {shadowFixedPoint_vs}, dynamicPointInst {shadowDynamicPointInst_vs}, size {s}
{
glBindTexture(GL_TEXTURE_2D, depthMap);
diff --git a/gfx/gl/shadowMapper.h b/gfx/gl/shadowMapper.h
index cd1b975..e5272a3 100644
--- a/gfx/gl/shadowMapper.h
+++ b/gfx/gl/shadowMapper.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "lib/glArrays.h"
#include "program.h"
#include <glm/vec2.hpp>
@@ -11,7 +12,7 @@ class Camera;
class ShadowMapper {
public:
- explicit ShadowMapper(const glm::ivec2 & size);
+ explicit ShadowMapper(const TextureAbsCoord & size);
static constexpr std::size_t SHADOW_BANDS {4};
@@ -21,7 +22,7 @@ public:
size_t maps {};
};
- [[nodiscard]] Definitions update(const SceneProvider &, const glm::vec3 & direction, const Camera &) const;
+ [[nodiscard]] Definitions update(const SceneProvider &, const Direction3D & direction, const Camera &) const;
class FixedPoint : public Program {
public:
@@ -55,9 +56,9 @@ public:
}
private:
- [[nodiscard]] static std::vector<std::array<glm::vec3, 4>> getBandViewExtents(
+ [[nodiscard]] static std::vector<std::array<Position3D, 4>> getBandViewExtents(
const Camera &, const glm::mat4 & lightView);
glFrameBuffer depthMapFBO;
glTexture depthMap;
- glm::ivec2 size;
+ TextureAbsCoord size;
};
diff --git a/gfx/gl/uiShader.h b/gfx/gl/uiShader.h
index 2766af8..362e90c 100644
--- a/gfx/gl/uiShader.h
+++ b/gfx/gl/uiShader.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "program.h"
#include <cstddef>
#include <glad/gl.h>
@@ -33,7 +34,7 @@ private:
class TextProgram : public UIProgram {
public:
explicit TextProgram(const glm::mat4 & vp);
- void use(const glm::vec3 & colour) const;
+ void use(const RGB & colour) const;
private:
RequiredUniformLocation colorLoc;