diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-27 13:09:34 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-11-27 13:09:34 +0000 |
commit | f43b88dfe55d107541562da04117e2929a89d3f2 (patch) | |
tree | 4d1ff7181d21a72f11aa90d5a4225bbce0561bb7 | |
parent | SceneRenderer is a graphics component, not a UI one (diff) | |
download | ilt-f43b88dfe55d107541562da04117e2929a89d3f2.tar.bz2 ilt-f43b88dfe55d107541562da04117e2929a89d3f2.tar.xz ilt-f43b88dfe55d107541562da04117e2929a89d3f2.zip |
Split SceneProvider out
-rw-r--r-- | gfx/gl/sceneProvider.cpp | 9 | ||||
-rw-r--r-- | gfx/gl/sceneProvider.h | 12 | ||||
-rw-r--r-- | gfx/gl/sceneRenderer.cpp | 7 | ||||
-rw-r--r-- | gfx/gl/sceneRenderer.h | 17 | ||||
-rw-r--r-- | test/test-render.cpp | 2 | ||||
-rw-r--r-- | ui/gameMainWindow.cpp | 2 | ||||
-rw-r--r-- | ui/gameMainWindow.h | 2 |
7 files changed, 29 insertions, 22 deletions
diff --git a/gfx/gl/sceneProvider.cpp b/gfx/gl/sceneProvider.cpp new file mode 100644 index 0000000..d73ac3c --- /dev/null +++ b/gfx/gl/sceneProvider.cpp @@ -0,0 +1,9 @@ +#include "sceneProvider.h" +#include "sceneRenderer.h" + +void +SceneProvider::environment(const SceneShader &, const SceneRenderer & renderer) const +{ + renderer.setAmbientLight({0.5F, 0.5F, 0.5F}); + renderer.setDirectionalLight({0.6F, 0.6F, 0.6F}, {1, 0, -1}); +} diff --git a/gfx/gl/sceneProvider.h b/gfx/gl/sceneProvider.h new file mode 100644 index 0000000..a966f9c --- /dev/null +++ b/gfx/gl/sceneProvider.h @@ -0,0 +1,12 @@ +#pragma once + +class SceneRenderer; +class SceneShader; + +class SceneProvider { +public: + virtual ~SceneProvider() = default; + virtual void content(const SceneShader &) const = 0; + virtual void environment(const SceneShader &, const SceneRenderer &) const; + virtual void lights(const SceneShader &) const = 0; +}; diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index a97387e..a06a163 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -131,10 +131,3 @@ SceneRenderer::DirectionalLightProgram::setDirectionalLight(const glm::vec3 & c, const auto nd = glm::normalize(d); glUniform3fv(directionLoc, 1, glm::value_ptr(nd)); } - -void -SceneRenderer::SceneProvider::environment(const SceneShader &, const SceneRenderer & renderer) const -{ - renderer.setAmbientLight({0.5F, 0.5F, 0.5F}); - renderer.setDirectionalLight({0.6F, 0.6F, 0.6F}, {1, 0, -1}); -} diff --git a/gfx/gl/sceneRenderer.h b/gfx/gl/sceneRenderer.h index f40b894..736b15a 100644 --- a/gfx/gl/sceneRenderer.h +++ b/gfx/gl/sceneRenderer.h @@ -1,22 +1,15 @@ #pragma once -#include "gfx/gl/camera.h" -#include "gfx/gl/program.h" -#include "gfx/gl/sceneShader.h" -#include "lib/glArrays.h" +#include "camera.h" +#include "glArrays.h" +#include "program.h" +#include "sceneProvider.h" +#include "sceneShader.h" #include <functional> #include <glm/fwd.hpp> class SceneRenderer { public: - class SceneProvider { - public: - virtual ~SceneProvider() = default; - virtual void content(const SceneShader &) const = 0; - virtual void environment(const SceneShader &, const SceneRenderer &) const; - virtual void lights(const SceneShader &) const = 0; - }; - explicit SceneRenderer(glm::ivec2 size, GLuint output); void render(const SceneProvider &) const; diff --git a/test/test-render.cpp b/test/test-render.cpp index 9e3ffa0..5a75419 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -55,7 +55,7 @@ public: } }; -class TestScene : public SceneRenderer::SceneProvider { +class TestScene : public SceneProvider { Terrain terrain {[]() { auto gd = std::make_shared<GeoData>(GeoData::Limits {{0, 0}, {100, 100}}); gd->generateRandom(); diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index 99bee48..7a47a25 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -58,7 +58,7 @@ void GameMainWindow::environment(const SceneShader & s, const SceneRenderer & r) const { // default for now - SceneRenderer::SceneProvider::environment(s, r); + SceneProvider::environment(s, r); } void GameMainWindow::lights(const SceneShader & shader) const diff --git a/ui/gameMainWindow.h b/ui/gameMainWindow.h index 03364f2..f3fc21f 100644 --- a/ui/gameMainWindow.h +++ b/ui/gameMainWindow.h @@ -5,7 +5,7 @@ #include "window.h" #include <cstddef> -class GameMainWindow : public Window, SceneRenderer, public SceneRenderer::SceneProvider { +class GameMainWindow : public Window, SceneRenderer, public SceneProvider { public: GameMainWindow(size_t w, size_t h); |