diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-12 19:35:58 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-12 19:35:58 +0000 |
commit | 51eb25ea0f1373ca0442b02049406af38eae3b33 (patch) | |
tree | 389169a5f60d58398554168b94a0c6003302fbf6 /gfx/gl | |
parent | Fix order or multiple to address reversed rotation (diff) | |
download | ilt-51eb25ea0f1373ca0442b02049406af38eae3b33.tar.bz2 ilt-51eb25ea0f1373ca0442b02049406af38eae3b33.tar.xz ilt-51eb25ea0f1373ca0442b02049406af38eae3b33.zip |
Add model support for point lights
Still invokes non-instanced point light shader
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/sceneShader.cpp | 27 | ||||
-rw-r--r-- | gfx/gl/sceneShader.h | 17 |
2 files changed, 5 insertions, 39 deletions
diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp index cdb8d2f..64bf171 100644 --- a/gfx/gl/sceneShader.cpp +++ b/gfx/gl/sceneShader.cpp @@ -1,5 +1,4 @@ #include "sceneShader.h" -#include <array> #include <gfx/gl/shaders/fs-landmass.h> #include <gfx/gl/shaders/fs-material.h> #include <gfx/gl/shaders/fs-pointLight.h> @@ -21,7 +20,8 @@ SceneShader::SceneShader() : basicInst {dynamicPointInst_vs, material_fs}, landmass {fixedPoint_vs, landmass_fs}, - absolute {fixedPoint_vs, material_fs}, spotLightInst {spotLight_vs, spotLight_gs, spotLight_fs} + absolute {fixedPoint_vs, material_fs}, spotLightInst {spotLight_vs, spotLight_gs, spotLight_fs}, + pointLightInst {pointLight_vs, pointLight_gs, pointLight_fs} { } @@ -29,7 +29,7 @@ void SceneShader::setViewProjection(const GlobalPosition3D & viewPoint, const glm::mat4 & viewProjection) const { for (const auto & prog : std::initializer_list<const SceneProgram *> { - &basic, &basicInst, &water, &landmass, &absolute, &pointLight, &spotLightInst}) { + &basic, &basicInst, &water, &landmass, &absolute, &pointLightInst, &spotLightInst}) { prog->setViewProjection(viewPoint, viewProjection); } } @@ -38,7 +38,7 @@ void SceneShader::setViewPort(const ViewPort & viewPort) const { for (const auto & prog : std::initializer_list<const SceneProgram *> { - &basic, &basicInst, &water, &landmass, &absolute, &pointLight, &spotLightInst}) { + &basic, &basicInst, &water, &landmass, &absolute, &pointLightInst, &spotLightInst}) { prog->setViewPort(viewPort); } } @@ -87,22 +87,3 @@ SceneShader::WaterProgram::use(float waveCycle) const Program::use(); glUniform1f(waveLoc, waveCycle); } - -SceneShader::PointLightShader::PointLightShader() : - SceneProgram {pointLight_vs, pointLight_gs, pointLight_fs}, colourLoc {*this, "colour"}, kqLoc {*this, "kq"}, - viewPointLoc {*this, "viewPoint"} -{ - VertexArrayObject {va}.addAttribs<Position3D>(b); -} - -void -SceneShader::PointLightShader::add(const Position3D & position, const RGB & colour, const float kq) const -{ - Program::use(); - glBindVertexArray(va); - glBindBuffer(GL_ARRAY_BUFFER, b); - glUniform3fv(colourLoc, 1, glm::value_ptr(colour)); - glUniform1f(kqLoc, kq); - glBufferData(GL_ARRAY_BUFFER, sizeof(Position3D), glm::value_ptr(position), GL_DYNAMIC_DRAW); - glDrawArrays(GL_POINTS, 0, 1); -} diff --git a/gfx/gl/sceneShader.h b/gfx/gl/sceneShader.h index 7e31cb8..813c1bf 100644 --- a/gfx/gl/sceneShader.h +++ b/gfx/gl/sceneShader.h @@ -51,27 +51,12 @@ class SceneShader { RequiredUniformLocation waveLoc; }; - class PointLightShader : public SceneProgram { - public: - PointLightShader(); - - void add(const Position3D & position, const RGB & colour, const float kq) const; - - private: - UniformLocation colourLoc; - UniformLocation kqLoc; - UniformLocation viewPointLoc; - glVertexArray va; - glBuffer b; - }; - public: SceneShader(); BasicProgram basic; WaterProgram water; - AbsolutePosProgram basicInst, landmass, absolute, spotLightInst; - PointLightShader pointLight; + AbsolutePosProgram basicInst, landmass, absolute, spotLightInst, pointLightInst; void setViewProjection(const GlobalPosition3D & viewPoint, const glm::mat4 & viewProjection) const; void setViewPort(const ViewPort & viewPort) const; |