From 72f2bf3ff9f41a06541d49dc21a648974e1f1f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 22 Jun 2012 13:37:18 +0200 Subject: [PATCH] Support for setting shader program parameters. Updated call order documentation to be more precise. --- src/AbstractShaderProgram.h | 40 +++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 7b28acdc8..db40e8445 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -180,6 +180,38 @@ class MAGNUM_EXPORT AbstractShaderProgram { bool use(); protected: + /** + * @brief Program parameters + * + * @see setParameter() + */ + enum class Parameter: GLenum { + /** + * Allow retrieving program binary. Disabled by default. + * + * @requires_gl41 Extension @extension{ARB,get_program_binary} + */ + RetrievableBinary = GL_PROGRAM_BINARY_RETRIEVABLE_HINT, + + /** + * Allow the program to be bound to individual pipeline stages. + * Disabled by default. + * + * @requires_gl41 Extension @extension{ARB,separate_shader_objects} + */ + Separable = GL_PROGRAM_SEPARABLE + }; + + /** + * @brief Set program parameter + * + * @note This function should be called after attachShader() calls and + * before link(). + */ + inline void setParameter(Parameter parameter, bool value) { + glProgramParameteri(program, static_cast(parameter), value ? GL_TRUE : GL_FALSE); + } + /** * @brief Load shader * @return False if the shader wasn't successfully compiled, true @@ -202,8 +234,8 @@ class MAGNUM_EXPORT AbstractShaderProgram { * * Binds attribute to location which is be used later for binding * vertex buffers. Preferred usage is to - * @note This function should be called between attachShader() calls - * and link(). + * @note This function should be called after attachShader() calls and + * before link(). * @deprecated Preferred usage is to specify attribute location * explicitly in the shader instead of using this function. See * @ref AbstractShaderProgramAttributeLocation "class documentation" @@ -216,8 +248,8 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @param location Location * @param name Fragment output variable name * - * @note This function should be called between attachShader() calls - * and link(). + * @note This function should be called after attachShader() calls and + * before link(). * @deprecated Preferred usage is to specify attribute location * explicitly in the shader instead of using this function. See * @ref AbstractShaderProgramAttributeLocation "class documentation"