void Shader::setUniformArray(const std::string& name, const Glsl::Mat4* matrixArray, std::size_t length) { const std::size_t matrixSize = 4 * 4; std::vector<float> contiguous(matrixSize * length); for (std::size_t i = 0; i < length; ++i) priv::copyMatrix(matrixArray[i].array, matrixSize, &contiguous[matrixSize * i]); UniformBinder binder(*this, name); if (binder.location != -1) glCheck(GLEXT_glUniformMatrix4fv(binder.location, length, GL_FALSE, &contiguous[0])); }
void Shader::setParameter(const std::string& name, const Transform& transform) { if (m_shaderProgram) { ensureGlContext(); // Enable program GLEXT_GLhandle program; glCheck(program = GLEXT_glGetHandle(GLEXT_GL_PROGRAM_OBJECT)); glCheck(GLEXT_glUseProgramObject(castToGlHandle(m_shaderProgram))); // Get parameter location and assign it new values GLint location = getParamLocation(name); if (location != -1) { glCheck(GLEXT_glUniformMatrix4fv(location, 1, GL_FALSE, transform.getMatrix())); } // Disable program glCheck(GLEXT_glUseProgramObject(program)); } }
void Shader::setUniform(const std::string& name, const Glsl::Mat4& matrix) { UniformBinder binder(*this, name); if (binder.location != -1) glCheck(GLEXT_glUniformMatrix4fv(binder.location, 1, GL_FALSE, matrix.array)); }