void GLSLProgram::setUniform1f(const std::string& uniform, float a) { glUniform1f(getUniformLocation(uniform), a); }
void shader::setUniform(const char *name, const mat3 &m) { int loc = getUniformLocation(name); if( loc >= 0 ) { glUniformMatrix3fv(loc, 1, GL_FALSE, &m[0][0]); } }
Uniform ShaderProgram::operator[](const char *name) { return Uniform(this->id, getUniformLocation(std::string(name))); }
void OpenGLShader::setVec4f(std::string s, glm::vec4 v) { int loc = getUniformLocation(s); glUniform4f(loc, v.x, v.y, v.z, v.w); }
void shader::setUniform(const char *name, float x, float y, float z) { int loc = getUniformLocation(name); if( loc >= 0 ) { glUniform3f(loc,x,y,z); } }
void ShaderObject::setUniformValue( std::string VariableName, int Value ) { glUniform1i( getUniformLocation( VariableName ), Value ); }
void OpenGLShader::setInt(std::string s, int v) { int loc = getUniformLocation(s); glUniform1i(loc, v); }
void ofShader::setUniform2f(const char* name, float v1, float v2) { if(bLoaded) glUniform2f(getUniformLocation(name), v1, v2); }
void ofShader::setUniform4f(const char* name, float v1, float v2, float v3, float v4) { if(bLoaded) glUniform4f(getUniformLocation(name), v1, v2, v3, v4); }
void ofShader::setUniform2i(const char* name, int v1, int v2) { if(bLoaded) glUniform2i(getUniformLocation(name), v1, v2); }
void ofShader::setUniform4i(const char* name, int v1, int v2, int v3, int v4) { if(bLoaded) glUniform4i(getUniformLocation(name), v1, v2, v3, v4); }
void GLSLProgram::setUniformMatrix4fv(const std::string& uniform, const glm::mat4& matrix) { //glUniform4fv(<#GLint location#>, <#GLsizei count#>, <#const GLfloat *value#>) glUniformMatrix4fv(getUniformLocation(uniform), 1, GL_FALSE, &(matrix[0][0])); }
void GLSLProgram::setUniform1i(const std::string& uniform, GLint a) { glUniform1i(getUniformLocation(uniform), a); }
void GLSLProgram::setUniform2fv(const std::string& uniform, GLsizei count, const float* val) { glUniform2fv(getUniformLocation(uniform), count, val); }
void Z3DShaderProgram::setUniformValueArray(const QString &name, const glm::mat4 *values, int count, bool transpose) { GLint l = getUniformLocation(name); setUniformValueArray(l, values, count, transpose); }
void ofShader::setUniform4fv(const char* name, float* v, int count) { if(bLoaded) glUniform4fv(getUniformLocation(name), count, v); }
void ShaderObject::setUniformValue( std::string VariableName, Vector4 Value ) { glUniform4f( getUniformLocation( VariableName ), Value.X, Value.Y, Value.Z, Value.W ); }
void Z3DShaderProgram::setUniformValue(const QString &name, GLfloat value) { GLint l = getUniformLocation(name); setUniformValue(l, value); }
void ShaderObject::setUniformValue( std::string VariableName, float Value1, float Value2 ) { glUniform2f( getUniformLocation( VariableName ), Value1, Value2 ); }
void Z3DShaderProgram::setUniformValue(const QString &name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { GLint l = getUniformLocation(name); setUniformValue(l, x, y, z, w); }
void OpenGLShader::setFloat(std::string s, float v) { int loc = getUniformLocation(s); glUniform1f(loc, v); }
void Z3DShaderProgram::setUniformValue(const QString &name, GLuint v1, GLuint v2, GLuint v3, GLuint v4) { GLint l = getUniformLocation(name); setUniformValue(l, v1, v2, v3, v4); }
void OpenGLShader::setMat4f(std::string s, glm::mat4 v) { int loc = getUniformLocation(s); glUniformMatrix4fv(loc, 1, GL_FALSE, glm::value_ptr(v)); }
void Z3DShaderProgram::setUniformValue(const QString &name, const glm::uvec4 &value) { GLint l = getUniformLocation(name); setUniformValue(l, value); }
void shader::setUniform(const char *name, const vec4 &v) { int loc = getUniformLocation(name); if( loc >= 0 ) { glUniform4f(loc,v.x,v.y,v.z,v.w); } }
void Z3DShaderProgram::setUniformValueArray(const QString &name, const glm::uvec4 *values, int count) { GLint l = getUniformLocation(name); setUniformValueArray(l, values, count); }
void shader::setUniform( const char *name, bool val) { int loc = getUniformLocation(name); if( loc >= 0 ) { glUniform1i(loc, val); } }
void Z3DShaderProgram::setUniformValue(const QString &name, const glm::mat4 &value, bool transpose) { GLint l = getUniformLocation(name); setUniformValue(l, value, transpose); }
DefaultShader::DefaultShader(GL3ShaderManager *manager) : Shader(manager, "shaders/default.vert", "shaders/default.frag") { _lightEnabledLoc = getUniformLocation("lightEnabled"); _ambientColorLoc = getUniformLocation("ambientLightColor"); _diffuseColorLoc = getUniformLocation("diffuseLightColor"); _diffuseDirectionLoc = getUniformLocation("diffuseLightDirection"); _modelMatrixLoc = getUniformLocation("modelMatrix"); _viewMatrixLoc = getUniformLocation("viewMatrix"); _projectionMatrixLoc = getUniformLocation("projectionMatrix"); _fogEnabledLoc = getUniformLocation("fogEnabled"); _fogStartDistanceLoc = getUniformLocation("fogStartDistance"); _fogEndDistanceLoc = getUniformLocation("fogEndDistance"); GLint tmp; glUseProgram(getProgramLocation()); tmp = getUniformLocation("textureSampler"); glUniform1i(tmp, 0); tmp = getUniformLocation("fogSampler"); glUniform1i(tmp, 1); }
//-------------------------------------------------------------- void ofShader::setUniformMatrix4f(const string & name, const ofMatrix4x4 & m, int count) const{ if(bLoaded) { int loc = getUniformLocation(name); if (loc != -1) glUniformMatrix4fv(loc, count, GL_FALSE, m.getPtr()); } }