summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-17 00:23:21 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-17 00:34:57 +0000
commit5283c898f008a54a1f275841281e2b7aa685f02c (patch)
treea75620a02da52e444a5c72d08b5f8d37e675fe61
parentTidy code for calculating position of rail vehicle by bogeys (diff)
downloadilt-5283c898f008a54a1f275841281e2b7aa685f02c.tar.bz2
ilt-5283c898f008a54a1f275841281e2b7aa685f02c.tar.xz
ilt-5283c898f008a54a1f275841281e2b7aa685f02c.zip
Disconnect camera control from shader
-rw-r--r--application/main.cpp3
-rw-r--r--gfx/camera_controller.h3
-rw-r--r--gfx/followCameraController.cpp4
-rw-r--r--gfx/followCameraController.h3
-rw-r--r--gfx/manualCameraController.cpp3
-rw-r--r--gfx/manualCameraController.h3
6 files changed, 7 insertions, 12 deletions
diff --git a/application/main.cpp b/application/main.cpp
index 04ff9c0..72da726 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -98,7 +98,8 @@ public:
const auto t_passed = std::chrono::duration_cast<WorldObject::TickDuration>(t_end - t_start);
world.apply(&WorldObject::tick, t_passed);
- world.apply<CameraController>(&CameraController::updateCamera, &camera, &shader);
+ world.apply<CameraController>(&CameraController::updateCamera, &camera);
+ shader.setView(camera.GetViewProjection());
windows.apply(&Window::Clear, 0.0F, 0.0F, 0.0F, 1.0F);
world.apply<Renderable>(&Renderable::render, shader);
windows.apply(&Window::SwapBuffers);
diff --git a/gfx/camera_controller.h b/gfx/camera_controller.h
index cdc70d2..926c93b 100644
--- a/gfx/camera_controller.h
+++ b/gfx/camera_controller.h
@@ -4,11 +4,10 @@
#include <game/worldobject.h>
class Camera;
-class Shader;
class CameraController : public WorldObject {
public:
- virtual void updateCamera(Camera *, Shader *) const = 0;
+ virtual void updateCamera(Camera *) const = 0;
};
#endif
diff --git a/gfx/followCameraController.cpp b/gfx/followCameraController.cpp
index 0034c3b..4db77cd 100644
--- a/gfx/followCameraController.cpp
+++ b/gfx/followCameraController.cpp
@@ -12,7 +12,7 @@
FollowCameraController::FollowCameraController(VehicleWPtr t, Mode m) : target(std::move(t)), mode(m) { }
void
-FollowCameraController::updateCamera(Camera * camera, Shader * shader) const
+FollowCameraController::updateCamera(Camera * camera) const
{
const auto [pos, rot] = [this]() {
const auto t {target.lock()};
@@ -37,6 +37,4 @@ FollowCameraController::updateCamera(Camera * camera, Shader * shader) const
camera->up = glm::normalize(up - north - east);
break;
}
-
- shader->setView(camera->GetViewProjection());
}
diff --git a/gfx/followCameraController.h b/gfx/followCameraController.h
index d57b59f..ef2000d 100644
--- a/gfx/followCameraController.h
+++ b/gfx/followCameraController.h
@@ -6,7 +6,6 @@
#include <gfx/camera_controller.h>
class Camera;
-class Shader;
class FollowCameraController : public CameraController {
public:
@@ -15,7 +14,7 @@ public:
void tick(TickDuration) override { }
- void updateCamera(Camera * camera, Shader * shader) const override;
+ void updateCamera(Camera * camera) const override;
private:
VehicleWPtr target;
diff --git a/gfx/manualCameraController.cpp b/gfx/manualCameraController.cpp
index 36f3312..f8cdbf8 100644
--- a/gfx/manualCameraController.cpp
+++ b/gfx/manualCameraController.cpp
@@ -48,7 +48,7 @@ ManualCameraController::handleInput(SDL_Event & e)
}
void
-ManualCameraController::updateCamera(Camera * camera, Shader * shader) const
+ManualCameraController::updateCamera(Camera * camera) const
{
if (motion) {
if (ctrl) {
@@ -59,7 +59,6 @@ ManualCameraController::updateCamera(Camera * camera, Shader * shader) const
camera->MoveRight(motion->xrel);
camera->SlideForward(motion->yrel);
}
- shader->setView(camera->GetViewProjection());
motion.reset();
}
}
diff --git a/gfx/manualCameraController.h b/gfx/manualCameraController.h
index 112ec5c..465f31f 100644
--- a/gfx/manualCameraController.h
+++ b/gfx/manualCameraController.h
@@ -8,7 +8,6 @@
#include <optional>
class Camera;
-class Shader;
class ManualCameraController : public CameraController, public InputHandler {
public:
@@ -16,7 +15,7 @@ public:
void tick(TickDuration) override { }
- void updateCamera(Camera * camera, Shader * shader) const override;
+ void updateCamera(Camera * camera) const override;
private:
bool ctrl {false}, mrb {false};