Browse Source

Doc++

pull/132/head
Vladimír Vondruš 10 years ago
parent
commit
6849acb5c0
  1. 47
      src/Magnum/AbstractShaderProgram.h

47
src/Magnum/AbstractShaderProgram.h

@ -136,8 +136,8 @@ The preferred workflow is to specify attribute location for vertex shader input
attributes and fragment shader output attributes explicitly in the shader code, attributes and fragment shader output attributes explicitly in the shader code,
e.g.: e.g.:
@code @code
// GLSL 3.30, or // GLSL 3.30, GLSL ES 3.00 or
#extension GL_ARB_explicit_attrib_location: enable #extension GL_ARB_explicit_attrib_location: require
layout(location = 0) in vec4 position; layout(location = 0) in vec4 position;
layout(location = 1) in vec3 normal; layout(location = 1) in vec3 normal;
layout(location = 2) in vec2 textureCoordinates; layout(location = 2) in vec2 textureCoordinates;
@ -151,8 +151,8 @@ layout(location = 0, index = 0) out vec4 color;
layout(location = 1, index = 1) out vec3 normal; layout(location = 1, index = 1) out vec3 normal;
@endcode @endcode
If you don't have the required extension, declare the attributes without If you don't have the required version/extension, declare the attributes
`layout()` qualifier and use functions @ref bindAttributeLocation() and without `layout()` qualifier and use functions @ref bindAttributeLocation() and
@ref bindFragmentDataLocation() / @ref bindFragmentDataLocationIndexed() between @ref bindFragmentDataLocation() / @ref bindFragmentDataLocationIndexed() between
attaching the shaders and linking the program. Note that additional syntax attaching the shaders and linking the program. Note that additional syntax
changes may be needed for GLSL 1.20 and GLSL ES. changes may be needed for GLSL 1.20 and GLSL ES.
@ -178,7 +178,7 @@ bindFragmentDataLocationIndexed(NormalOutput, 1, "normal");
// Link... // Link...
@endcode @endcode
@see @ref Mesh::maxVertexAttributes(), @ref AbstractFramebuffer::maxDrawBuffers() @see @ref maxVertexAttributes(), @ref AbstractFramebuffer::maxDrawBuffers()
@requires_gl30 Extension @extension{EXT,gpu_shader4} for using @requires_gl30 Extension @extension{EXT,gpu_shader4} for using
@ref bindFragmentDataLocation(). @ref bindFragmentDataLocation().
@requires_gl33 Extension @extension{ARB,blend_func_extended} for using @requires_gl33 Extension @extension{ARB,blend_func_extended} for using
@ -208,15 +208,15 @@ bindFragmentDataLocationIndexed(NormalOutput, 1, "normal");
The preferred workflow is to specify uniform locations directly in the shader The preferred workflow is to specify uniform locations directly in the shader
code, e.g.: code, e.g.:
@code @code
// GLSL 4.30, or // GLSL 4.30, GLSL ES 3.10 or
#extension GL_ARB_explicit_uniform_location: enable #extension GL_ARB_explicit_uniform_location: require
layout(location = 0) uniform mat4 projectionMatrix; layout(location = 0) uniform mat4 projectionMatrix;
layout(location = 1) uniform mat4 transformationMatrix; layout(location = 1) uniform mat4 transformationMatrix;
layout(location = 2) uniform mat3 normalMatrix; layout(location = 2) uniform mat3 normalMatrix;
@endcode @endcode
If you don't have the required extension, declare the uniforms without the If you don't have the required version/extension, declare the uniforms without
`layout()` qualifier, get uniform location using @ref uniformLocation() *after* the `layout()` qualifier, get uniform location using @ref uniformLocation() *after*
linking stage and then use the queried location in uniform setting functions. linking stage and then use the queried location in uniform setting functions.
Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES. Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES.
@code @code
@ -244,16 +244,16 @@ Int normalMatrixUniform = uniformLocation("normalMatrix");
The preferred workflow is to specify texture binding unit directly in the The preferred workflow is to specify texture binding unit directly in the
shader code, e.g.: shader code, e.g.:
@code @code
// GLSL 4.20, or // GLSL 4.20, GLSL ES 3.10 or
#extension GL_ARB_shading_language_420pack: enable #extension GL_ARB_shading_language_420pack: require
layout(binding = 0) uniform sampler2D diffuseTexture; layout(binding = 0) uniform sampler2D diffuseTexture;
layout(binding = 1) uniform sampler2D specularTexture; layout(binding = 1) uniform sampler2D specularTexture;
@endcode @endcode
If you don't have the required extension, declare the uniforms without the If you don't have the required version/extension, declare the uniforms without
`binding` qualifier and set the texture binding unit using the `binding` qualifier and set the texture binding unit using
@ref setUniform(Int, const T&) "setUniform(Int, Int)". Note that additional @ref setUniform(Int, const T&) "setUniform(Int, Int)". Note that additional
syntax changes may be needed for GLSL 1.20 and GLSL ES 1.0. syntax changes may be needed for GLSL ES.
@code @code
uniform sampler2D diffuseTexture; uniform sampler2D diffuseTexture;
uniform sampler2D specularTexture; uniform sampler2D specularTexture;
@ -280,7 +280,7 @@ The preferred workflow is to specify output binding points directly in the
shader code, e.g.: shader code, e.g.:
@code @code
// GLSL 4.40, or // GLSL 4.40, or
#extension GL_ARB_enhanced_layouts: enable #extension GL_ARB_enhanced_layouts: require
layout(xfb_buffer = 0, xfb_stride = 32) out block { layout(xfb_buffer = 0, xfb_stride = 32) out block {
layout(xfb_offset = 0) vec3 position; layout(xfb_offset = 0) vec3 position;
layout(xfb_offset = 16) vec3 normal; layout(xfb_offset = 16) vec3 normal;
@ -288,8 +288,8 @@ layout(xfb_buffer = 0, xfb_stride = 32) out block {
layout(xfb_buffer = 1) out vec3 velocity; layout(xfb_buffer = 1) out vec3 velocity;
@endcode @endcode
If you don't have the required extension, declare the uniforms without the If you don't have the required version/extension, declare the uniforms without
`xfb_*` qualifier and set the binding points using @ref setTransformFeedbackOutputs(). the `xfb_*` qualifier and set the binding points using @ref setTransformFeedbackOutputs().
Equivalent setup for the previous code would be the following: Equivalent setup for the previous code would be the following:
@code @code
out block { out block {
@ -310,14 +310,17 @@ setTransformFeedbackOutputs({
@see @ref TransformFeedback::maxInterleavedComponents(), @see @ref TransformFeedback::maxInterleavedComponents(),
@ref TransformFeedback::maxSeparateAttributes(), @ref TransformFeedback::maxSeparateAttributes(),
@ref TransformFeedback::maxSeparateComponents() @ref TransformFeedback::maxSeparateComponents()
@requires_gl40 Extension @extension{ARB,transform_feedback2}
@requires_gl40 Extension @extension{ARB,transform_feedback3} for using @requires_gl40 Extension @extension{ARB,transform_feedback3} for using
`gl_NextBuffer` or `gl_SkipComponents#` names in `gl_NextBuffer` or `gl_SkipComponents#` names in
@ref setTransformFeedbackOutputs() function. @ref setTransformFeedbackOutputs() function.
@requires_gl44 Extension @extension{ARB,enhanced_layouts} for explicit @requires_gl44 Extension @extension{ARB,enhanced_layouts} for explicit
transform feedback output specification instead of using transform feedback output specification instead of using
@ref setTransformFeedbackOutputs(). @ref setTransformFeedbackOutputs().
@requires_gles30 Transform feedback is not available in OpenGL ES 2.0.
@requires_gl Explicit transform feedback output specification is not available @requires_gl Explicit transform feedback output specification is not available
in OpenGL ES or WebGL. in OpenGL ES or WebGL.
@requires_webgl20 Transform feedback is not available in WebGL 1.0.
@anchor AbstractShaderProgram-rendering-workflow @anchor AbstractShaderProgram-rendering-workflow
## Rendering workflow ## Rendering workflow
@ -858,7 +861,9 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @brief Get uniform location * @brief Get uniform location
* @param name Uniform name * @param name Uniform name
* *
* @see @fn_gl{GetUniformLocation} * If given uniform is not found in the linked shader, a warning is
* printed and `-1` is returned.
* @see @ref setUniform(), @fn_gl{GetUniformLocation}
* @deprecated_gl Preferred usage is to specify uniform location * @deprecated_gl Preferred usage is to specify uniform location
* explicitly in the shader instead of using this function. See * explicitly in the shader instead of using this function. See
* @ref AbstractShaderProgram-uniform-location "class documentation" * @ref AbstractShaderProgram-uniform-location "class documentation"
@ -881,6 +886,7 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* Convenience alternative for setting one value, see * Convenience alternative for setting one value, see
* @ref setUniform(Int, Containers::ArrayView<const Float>) for more * @ref setUniform(Int, Containers::ArrayView<const Float>) for more
* information. * information.
* @see @ref uniformLocation()
*/ */
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
template<class T> inline void setUniform(Int location, const T& value); template<class T> inline void setUniform(Int location, const T& value);
@ -919,8 +925,9 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject {
* @es_extension{EXT,separate_shader_objects} OpenGL ES extension nor * @es_extension{EXT,separate_shader_objects} OpenGL ES extension nor
* OpenGL ES 3.1 is available, the shader is marked for use before the * OpenGL ES 3.1 is available, the shader is marked for use before the
* operation. * operation.
* @see @ref setUniform(Int, const T&), @fn_gl{UseProgram}, @fn_gl{Uniform} * @see @ref setUniform(Int, const T&), @ref uniformLocation(),
* or @fn_gl{ProgramUniform}/@fn_gl_extension{ProgramUniform,EXT,direct_state_access}. * @fn_gl{UseProgram}, @fn_gl{Uniform} or @fn_gl{ProgramUniform}/
* @fn_gl_extension{ProgramUniform,EXT,direct_state_access}.
*/ */
void setUniform(Int location, Containers::ArrayView<const Float> values); 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<2, Float>> values); /**< @overload */

Loading…
Cancel
Save