summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-14 11:38:09 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-14 11:38:09 +0000
commit08128c14ec49a2b357e830c832ccd0a8e63c175d (patch)
tree6634dea4e5d8bac32bdcf1c2ea68000874c61a5a /gfx/gl
parentWe only need 3x3 matrix for model rotation spec (diff)
downloadilt-08128c14ec49a2b357e830c832ccd0a8e63c175d.tar.bz2
ilt-08128c14ec49a2b357e830c832ccd0a8e63c175d.tar.xz
ilt-08128c14ec49a2b357e830c832ccd0a8e63c175d.zip
Add traits wrapper for setting uniforms
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/sceneRenderer.cpp12
-rw-r--r--gfx/gl/sceneShader.cpp12
-rw-r--r--gfx/gl/shadowMapper.cpp13
-rw-r--r--gfx/gl/uiShader.cpp3
-rw-r--r--gfx/gl/uiShader.h3
5 files changed, 23 insertions, 20 deletions
diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp
index c856279..4ae4297 100644
--- a/gfx/gl/sceneRenderer.cpp
+++ b/gfx/gl/sceneRenderer.cpp
@@ -143,11 +143,11 @@ SceneRenderer::DirectionalLightProgram::setDirectionalLight(const RGB & c, const
const GlobalPosition3D & p, const std::span<const glm::mat4x4> lvp,
const std::span<const TextureRelRegion> shadowMapRegions, std::size_t maps) const
{
- glUniform3fv(colourLoc, 1, glm::value_ptr(c));
+ glUniform(colourLoc, c);
const auto nd = glm::normalize(d);
- glUniform3fv(directionLoc, 1, glm::value_ptr(nd));
- glUniform3iv(lightPointLoc, 1, glm::value_ptr(p));
- glUniform1ui(lightViewProjectionCountLoc, static_cast<GLuint>(maps));
- glUniformMatrix4fv(lightViewProjectionLoc, static_cast<GLsizei>(maps), GL_FALSE, glm::value_ptr(lvp.front()));
- glUniform4fv(lightViewShadowMapRegionLoc, static_cast<GLsizei>(maps), glm::value_ptr(shadowMapRegions.front()));
+ glUniform(directionLoc, nd);
+ glUniform(lightPointLoc, p);
+ glUniform(lightViewProjectionCountLoc, static_cast<GLuint>(maps));
+ glUniform(lightViewProjectionLoc, lvp);
+ glUniform(lightViewShadowMapRegionLoc, shadowMapRegions);
}
diff --git a/gfx/gl/sceneShader.cpp b/gfx/gl/sceneShader.cpp
index dc77793..1b3b27c 100644
--- a/gfx/gl/sceneShader.cpp
+++ b/gfx/gl/sceneShader.cpp
@@ -47,8 +47,8 @@ void
SceneShader::SceneProgram::setViewProjection(const GlobalPosition3D & viewPoint, const glm::mat4 & viewProjection) const
{
glUseProgram(*this);
- glUniformMatrix4fv(viewProjectionLoc, 1, GL_FALSE, glm::value_ptr(viewProjection));
- glUniform3iv(viewPointLoc, 1, glm::value_ptr(viewPoint));
+ glUniform(viewProjectionLoc, viewProjection);
+ glUniform(viewPointLoc, viewPoint);
}
void
@@ -56,7 +56,7 @@ SceneShader::SceneProgram::setViewPort(const ViewPort & viewPort) const
{
if (viewPortLoc >= 0) {
glUseProgram(*this);
- glUniform4iv(viewPortLoc, 1, glm::value_ptr(viewPort));
+ glUniform(viewPortLoc, viewPort);
}
}
@@ -68,8 +68,8 @@ SceneShader::BasicProgram::BasicProgram() :
void
SceneShader::BasicProgram::setModel(Location const & location) const
{
- glUniformMatrix3fv(modelLoc, 1, GL_FALSE, glm::value_ptr(location.getRotationTransform()));
- glUniform3iv(modelPosLoc, 1, glm::value_ptr(location.pos));
+ glUniform(modelLoc, location.getRotationTransform());
+ glUniform(modelPosLoc, location.pos);
}
void
@@ -85,5 +85,5 @@ void
SceneShader::WaterProgram::use(float waveCycle) const
{
Program::use();
- glUniform1f(waveLoc, waveCycle);
+ glUniform(waveLoc, waveCycle);
}
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp
index 5dc555a..ae374fe 100644
--- a/gfx/gl/shadowMapper.cpp
+++ b/gfx/gl/shadowMapper.cpp
@@ -4,6 +4,7 @@
#include "gfx/gl/shaders/vs-shadowDynamicPoint.h"
#include "gfx/gl/shaders/vs-shadowDynamicPointInst.h"
#include "gfx/gl/shaders/vs-shadowFixedPoint.h"
+#include "gl_traits.h"
#include "location.h"
#include "maths.h"
#include "sceneProvider.h"
@@ -174,8 +175,8 @@ void
ShadowMapper::FixedPoint::setViewProjection(const GlobalPosition3D viewPoint, const glm::mat4 & viewProjection) const
{
use();
- glUniformMatrix4fv(viewProjectionLoc, 1, GL_FALSE, glm::value_ptr(viewProjection));
- glUniform3iv(viewPointLoc, 1, glm::value_ptr(viewPoint));
+ glUniform(viewProjectionLoc, viewProjection);
+ glUniform(viewPointLoc, viewPoint);
}
void
@@ -194,8 +195,8 @@ void
ShadowMapper::DynamicPoint::setViewProjection(const GlobalPosition3D viewPoint, const glm::mat4 & viewProjection) const
{
glUseProgram(*this);
- glUniformMatrix4fv(viewProjectionLoc, 1, GL_FALSE, glm::value_ptr(viewProjection));
- glUniform3iv(viewPointLoc, 1, glm::value_ptr(viewPoint));
+ glUniform(viewProjectionLoc, viewProjection);
+ glUniform(viewPointLoc, viewPoint);
}
void
@@ -208,6 +209,6 @@ ShadowMapper::DynamicPoint::use(const Location & location) const
void
ShadowMapper::DynamicPoint::setModel(const Location & location) const
{
- glUniformMatrix3fv(modelLoc, 1, GL_FALSE, glm::value_ptr(location.getRotationTransform()));
- glUniform3iv(modelPosLoc, 1, glm::value_ptr(location.pos));
+ glUniform(modelLoc, location.getRotationTransform());
+ glUniform(modelPosLoc, location.pos);
}
diff --git a/gfx/gl/uiShader.cpp b/gfx/gl/uiShader.cpp
index dc4f4dc..cf53e2c 100644
--- a/gfx/gl/uiShader.cpp
+++ b/gfx/gl/uiShader.cpp
@@ -1,4 +1,5 @@
#include "uiShader.h"
+#include "gl_traits.h"
#include <gfx/gl/program.h>
#include <gfx/gl/shader.h>
#include <gfx/gl/shaders/fs-uiShader.h>
@@ -26,5 +27,5 @@ void
UIShader::TextProgram::use(const RGB & colour) const
{
Program::use();
- glUniform3fv(colorLoc, 1, glm::value_ptr(colour));
+ glUniform(colorLoc, colour);
}
diff --git a/gfx/gl/uiShader.h b/gfx/gl/uiShader.h
index 362e90c..99c5e17 100644
--- a/gfx/gl/uiShader.h
+++ b/gfx/gl/uiShader.h
@@ -1,6 +1,7 @@
#pragma once
#include "config/types.h"
+#include "gl_traits.h"
#include "program.h"
#include <cstddef>
#include <glad/gl.h>
@@ -21,7 +22,7 @@ private:
{
const RequiredUniformLocation uiProjectionLoc {*this, "uiProjection"};
glUseProgram(*this);
- glUniformMatrix4fv(uiProjectionLoc, 1, GL_FALSE, glm::value_ptr(vp));
+ glUniform(uiProjectionLoc, vp);
}
};