Browse Source

Use ArrayView instead of separate data/size params for shader uniforms.

The previous AbstractShaderProgram::setUniform(Int, UnsignedInt, T*)
function is now alias to the new one, is marked as deprecated and will
be removed in some future release.
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
41f5b95eba
  1. 138
      src/Magnum/AbstractShaderProgram.cpp
  2. 107
      src/Magnum/AbstractShaderProgram.h
  3. 3
      src/Magnum/Test/AbstractShaderProgramGLTest.cpp

138
src/Magnum/AbstractShaderProgram.cpp

@ -407,8 +407,8 @@ Int AbstractShaderProgram::uniformLocationInternal(const Containers::ArrayView<c
return location;
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Float* const values) {
(this->*Context::current()->state().shaderProgram->uniform1fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Float> values) {
(this->*Context::current()->state().shaderProgram->uniform1fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLfloat* const values) {
@ -435,8 +435,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<2, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniform2fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniform2fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) {
@ -463,8 +463,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<3, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniform3fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniform3fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) {
@ -491,8 +491,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<4, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniform4fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniform4fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) {
@ -519,11 +519,11 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Int* const values) {
(this->*Context::current()->state().shaderProgram->uniform1ivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Int> values) {
(this->*Context::current()->state().shaderProgram->uniform1ivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLint* const values) {
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLint* values) {
use();
glUniform1iv(location, count, values);
}
@ -547,8 +547,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<2, Int>* const values) {
(this->*Context::current()->state().shaderProgram->uniform2ivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Int>> values) {
(this->*Context::current()->state().shaderProgram->uniform2ivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) {
@ -575,8 +575,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<3, Int>* const values) {
(this->*Context::current()->state().shaderProgram->uniform3ivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Int>> values) {
(this->*Context::current()->state().shaderProgram->uniform3ivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) {
@ -603,8 +603,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<4, Int>* const values) {
(this->*Context::current()->state().shaderProgram->uniform4ivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Int>> values) {
(this->*Context::current()->state().shaderProgram->uniform4ivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) {
@ -632,8 +632,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
#endif
#ifndef MAGNUM_TARGET_GLES2
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const UnsignedInt* const values) {
(this->*Context::current()->state().shaderProgram->uniform1uivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const UnsignedInt> values) {
(this->*Context::current()->state().shaderProgram->uniform1uivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLuint* const values) {
@ -651,8 +651,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<2, UnsignedInt>* const values) {
(this->*Context::current()->state().shaderProgram->uniform2uivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, UnsignedInt>> values) {
(this->*Context::current()->state().shaderProgram->uniform2uivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLuint>* const values) {
@ -670,8 +670,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<3, UnsignedInt>* const values) {
(this->*Context::current()->state().shaderProgram->uniform3uivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, UnsignedInt>> values) {
(this->*Context::current()->state().shaderProgram->uniform3uivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLuint>* const values) {
@ -689,8 +689,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<4, UnsignedInt>* const values) {
(this->*Context::current()->state().shaderProgram->uniform4uivImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, UnsignedInt>> values) {
(this->*Context::current()->state().shaderProgram->uniform4uivImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLuint>* const values) {
@ -710,8 +710,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Double* const values) {
(this->*Context::current()->state().shaderProgram->uniform1dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Double> values) {
(this->*Context::current()->state().shaderProgram->uniform1dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLdouble* const values) {
@ -727,8 +727,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniform1dvEXT(_id, location, count, values);
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<2, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniform2dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<2, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniform2dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLdouble>* const values) {
@ -744,8 +744,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniform2dvEXT(_id, location, count, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<3, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniform3dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<3, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniform3dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLdouble>* const values) {
@ -761,8 +761,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniform3dvEXT(_id, location, count, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<4, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniform4dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::Vector<4, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniform4dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLdouble>* const values) {
@ -779,8 +779,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 2, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 2, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) {
@ -807,8 +807,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 3, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 3, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) {
@ -835,8 +835,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 4, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 4, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) {
@ -864,8 +864,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
#endif
#ifndef MAGNUM_TARGET_GLES2
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 3, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x3fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 3, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x3fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* const values) {
@ -883,8 +883,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 2, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x2fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 2, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x2fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* const values) {
@ -902,8 +902,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 4, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x4fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 4, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x4fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* const values) {
@ -921,8 +921,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 2, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x2fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 2, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x2fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* const values) {
@ -940,8 +940,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 4, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x4fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 4, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x4fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* const values) {
@ -959,8 +959,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
}
#endif
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 3, Float>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x3fvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 3, Float>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x3fvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* const values) {
@ -980,8 +980,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 2, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 2, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* const values) {
@ -997,8 +997,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix2dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 3, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 3, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* const values) {
@ -1014,8 +1014,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix3dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 4, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 4, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* const values) {
@ -1031,8 +1031,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix4dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 3, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x3dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 3, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x3dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* const values) {
@ -1048,8 +1048,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix2x3dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 2, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x2dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 2, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x2dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* const values) {
@ -1065,8 +1065,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix3x2dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 4, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x4dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<2, 4, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix2x4dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* const values) {
@ -1082,8 +1082,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix2x4dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 2, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x2dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 2, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x2dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* const values) {
@ -1099,8 +1099,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix4x2dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 4, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x4dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<3, 4, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix3x4dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* const values) {
@ -1116,8 +1116,8 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
glProgramUniformMatrix3x4dvEXT(_id, location, count, GL_FALSE, values[0].data());
}
void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 3, Double>* const values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x3dvImplementation)(location, count, values);
void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView<const Math::RectangularMatrix<4, 3, Double>> values) {
(this->*Context::current()->state().shaderProgram->uniformMatrix4x3dvImplementation)(location, values.size(), values);
}
void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* const values) {

107
src/Magnum/AbstractShaderProgram.h

@ -387,7 +387,6 @@ comes in handy.
@see @ref portability-shaders
@todo Use Containers::ArrayView for setting uniform arrays?
@todo `GL_NUM_{PROGRAM,SHADER}_BINARY_FORMATS` + `GL_{PROGRAM,SHADER}_BINARY_FORMATS` (vector), (@extension{ARB,ES2_compatibility})
*/
class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
@ -878,40 +877,39 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @param value Value
*
* Convenience alternative for setting one value, see
* @ref setUniform(Int, UnsignedInt, const Float*) for more
* @ref setUniform(Int, Containers::ArrayView<const Float>) for more
* information.
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T> inline void setUniform(Int location, const T& value);
#else
void setUniform(Int location, Float value) {
setUniform(location, 1, &value);
setUniform(location, {&value, 1});
}
void setUniform(Int location, Int value) {
setUniform(location, 1, &value);
setUniform(location, {&value, 1});
}
#ifndef MAGNUM_TARGET_GLES2
void setUniform(Int location, UnsignedInt value) {
setUniform(location, 1, &value);
setUniform(location, {&value, 1});
}
#endif
#ifndef MAGNUM_TARGET_GLES
void setUniform(Int location, Double value) {
setUniform(location, 1, &value);
setUniform(location, {&value, 1});
}
#endif
template<std::size_t size, class T> void setUniform(Int location, const Math::Vector<size, T>& value) {
setUniform(location, 1, &value);
setUniform(location, {&value, 1});
}
template<std::size_t cols, std::size_t rows, class T> void setUniform(Int location, const Math::RectangularMatrix<cols, rows, T>& value) {
setUniform(location, 1, &value);
setUniform(location, {&value, 1});
}
#endif
/**
* @brief Set uniform values
* @param location Uniform location
* @param count Value count
* @param values Values
*
* If neither @extension{ARB,separate_shader_objects} (part of OpenGL
@ -922,76 +920,87 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @see @ref setUniform(Int, const T&), @fn_gl{UseProgram}, @fn_gl{Uniform}
* or @fn_gl{ProgramUniform}/@fn_gl_extension{ProgramUniform,EXT,direct_state_access}.
*/
void setUniform(Int location, UnsignedInt count, const Float* values);
void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Float>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Float>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Float>* values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Float> values);
void setUniform(Int location, Containers::ArrayView<const Math::Vector<2, Float>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<3, Float>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<4, Float>> values); /**< @overload */
/** @copydoc setUniform(Int, UnsignedInt, const Float*) */
void setUniform(Int location, UnsignedInt count, const Int* values);
void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Int>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Int>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Int>* values); /**< @overload */
/** @copydoc setUniform(Int, Containers::ArrayView<const Float>) */
void setUniform(Int location, Containers::ArrayView<const Int> values);
void setUniform(Int location, Containers::ArrayView<const Math::Vector<2, Int>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<3, Int>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<4, Int>> values); /**< @overload */
#ifndef MAGNUM_TARGET_GLES2
/**
* @copydoc setUniform(Int, UnsignedInt, const Float*)
* @copydoc setUniform(Int, Containers::ArrayView<const Float>)
* @requires_gl30 Extension @extension{EXT,gpu_shader4}
* @requires_gles30 Only signed integers are available in OpenGL ES 2.0.
* @requires_webgl20 Only signed integers are available in WebGL 1.0.
*/
void setUniform(Int location, UnsignedInt count, const UnsignedInt* values);
void setUniform(Int location, UnsignedInt count, const Math::Vector<2, UnsignedInt>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<3, UnsignedInt>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<4, UnsignedInt>* values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const UnsignedInt> values);
void setUniform(Int location, Containers::ArrayView<const Math::Vector<2, UnsignedInt>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<3, UnsignedInt>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<4, UnsignedInt>> values); /**< @overload */
#endif
#ifndef MAGNUM_TARGET_GLES
/**
* @copydoc setUniform(Int, UnsignedInt, const Float*)
* @copydoc setUniform(Int, Containers::ArrayView<const Float>)
* @requires_gl40 Extension @extension{ARB,gpu_shader_fp64}
* @requires_gl Only floats are available in OpenGL ES or WebGL.
*/
void setUniform(Int location, UnsignedInt count, const Double* values);
void setUniform(Int location, UnsignedInt count, const Math::Vector<2, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<3, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::Vector<4, Double>* values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Double> values);
void setUniform(Int location, Containers::ArrayView<const Math::Vector<2, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<3, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::Vector<4, Double>> values); /**< @overload */
#endif
/** @copydoc setUniform(Int, UnsignedInt, const Float*) */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 2, Float>* values);
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 3, Float>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 4, Float>* values); /**< @overload */
/** @copydoc setUniform(Int, Containers::ArrayView<const Float>) */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<2, 2, Float>> values);
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<3, 3, Float>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<4, 4, Float>> values); /**< @overload */
#ifndef MAGNUM_TARGET_GLES2
/**
* @copydoc setUniform(Int, UnsignedInt, const Float*)
* @copydoc setUniform(Int, Containers::ArrayView<const Float>)
* @requires_gles30 Only square matrices are available in OpenGL ES 2.0.
* @requires_webgl20 Only square matrices are available in WebGL 1.0.
*/
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 3, Float>* values);
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 2, Float>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 4, Float>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 2, Float>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 4, Float>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 3, Float>* values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<2, 3, Float>> values);
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<3, 2, Float>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<2, 4, Float>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<4, 2, Float>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<3, 4, Float>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<4, 3, Float>> values); /**< @overload */
#endif
#ifndef MAGNUM_TARGET_GLES
/**
* @copydoc setUniform(Int, UnsignedInt, const Float*)
* @copydoc setUniform(Int, Containers::ArrayView<const Float>)
* @requires_gl40 Extension @extension{ARB,gpu_shader_fp64}
* @requires_gl Only floats are available in OpenGL ES or WebGL.
*/
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 2, Double>* values);
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 3, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 4, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 3, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 2, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<2, 4, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 2, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<3, 4, Double>* values); /**< @overload */
void setUniform(Int location, UnsignedInt count, const Math::RectangularMatrix<4, 3, Double>* values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<2, 2, Double>> values);
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<3, 3, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<4, 4, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<2, 3, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<3, 2, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<2, 4, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<4, 2, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<3, 4, Double>> values); /**< @overload */
void setUniform(Int location, Containers::ArrayView<const Math::RectangularMatrix<4, 3, Double>> values); /**< @overload */
#endif
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Set uniform values
* @deprecated Use @ref setUniform(Int, Containers::ArrayView<const Float>)
* and similar instead.
*/
template<class T> CORRADE_DEPRECATED("use setUniform(Int, Containers::ArrayView<const T>) instead") void setUniform(Int location, UnsignedInt count, const T* values) {
setUniform(location, {values, count});
}
#endif
private:

3
src/Magnum/Test/AbstractShaderProgramGLTest.cpp

@ -371,12 +371,13 @@ void AbstractShaderProgramGLTest::uniformArray() {
MAGNUM_VERIFY_NO_ERROR();
/* Testing also implicit conversion to base type (Vector4[] -> Math::Vector<4, Float>[]) */
constexpr Vector4 values[] = {
{0.5f, 1.0f, 0.4f, 0.0f},
{0.0f, 0.1f, 0.7f, 0.3f},
{0.9f, 0.8f, 0.3f, 0.1f}
};
shader.setUniform(shader.additionsUniform, 3, values);
shader.setUniform(shader.additionsUniform, values);
MAGNUM_VERIFY_NO_ERROR();
}

Loading…
Cancel
Save