adding position in shader

This commit is contained in:
Clément Le Bihan
2021-06-17 18:22:59 +02:00
parent d0f3214aef
commit bc8504a026
4 changed files with 23 additions and 2 deletions
+16
View File
@@ -6,6 +6,7 @@
#include <utility>
#include "Exceptions/RayError.hpp"
#include "Vector/Vector3.hpp"
namespace RAY
{
@@ -38,6 +39,7 @@ namespace RAY
SetShaderValue(*this->_rayLibShader, this->_shaderIndexVars[varName], &value, SHADER_UNIFORM_FLOAT);
}
void Shader::setShaderUniformVar(const std::string &varName, int value)
{
if (this->_shaderIndexVars.find(varName) == this->_shaderIndexVars.end()) {
@@ -60,4 +62,18 @@ namespace RAY
{
EndShaderMode();
}
void Shader::setShaderUniformVar(const std::string &varName, const RAY::Vector3 &vector)
{
if (this->_shaderIndexVars.find(varName) == this->_shaderIndexVars.end()) {
int varShaderIndex = GetShaderLocation(*this->_rayLibShader, varName.c_str());
if (varShaderIndex < 0) {
throw Exception::WrongInputError("The loaded shader doesn't have a variable called: " + varName);
}
this->_shaderIndexVars[varName] = varShaderIndex;
}
SetShaderValue(*this->_rayLibShader, this->_shaderIndexVars[varName], &vector, SHADER_UNIFORM_VEC3);
}
}
+3
View File
@@ -9,6 +9,7 @@
#include <map>
#include <raylib.h>
#include "Utils/Cache.hpp"
#include "Vector/Vector3.hpp"
namespace RAY
{
@@ -46,6 +47,8 @@ namespace RAY
//! @note Throw if the var is not found
void setShaderUniformVar(const std::string &varName, int value);
void setShaderUniformVar(const std::string &varName, const RAY::Vector3 &vector);
void setLocation(::ShaderLocationIndex, const std::string &name);
//! @brief ctor if no vertexfile in needed set it to nullptr