From bc81eb92d8b06abc7289246102aec3c5b8be6055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 22 Jul 2014 22:13:12 +0200 Subject: [PATCH] Added AbstractShaderProgram::attachShaders(). Convenience overload to attachShader(), allowing the user to specify more than one shader at once. Just a complement to initializer-list versions of compile() and link(), but without any performance difference. --- src/Magnum/AbstractShaderProgram.cpp | 4 ++++ src/Magnum/AbstractShaderProgram.h | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index 2daf03574..dabc8b881 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -262,6 +262,10 @@ void AbstractShaderProgram::attachShader(Shader& shader) { glAttachShader(_id, shader.id()); } +void AbstractShaderProgram::attachShaders(std::initializer_list> shaders) { + for(Shader& s: shaders) attachShader(s); +} + void AbstractShaderProgram::bindAttributeLocation(UnsignedInt location, const std::string& name) { glBindAttribLocation(_id, location, name.data()); } diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index 0957857e1..9da0dc74f 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -614,6 +614,15 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { */ void attachShader(Shader& shader); + /** + * @brief Attach shaders + * + * Convenience overload to the above, allowing the user to specify more + * than one shader at once. Other than that there is no other + * (performance) difference when using this function. + */ + void attachShaders(std::initializer_list> shaders); + /** * @brief Bind attribute to given location * @param location Location