Browse Source

doc: improve shader backporting documentation.

pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
f92e21e5c7
  1. 36
      src/AbstractShaderProgram.h

36
src/AbstractShaderProgram.h

@ -132,10 +132,20 @@ 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, you can use functions If you don't have the required extension, declare the attributes without
bindAttributeLocation() and bindFragmentDataLocation() / `layout()` qualifier and use functions @ref bindAttributeLocation() and
bindFragmentDataLocationIndexed() between attaching the shaders and linking @ref bindFragmentDataLocation() / @ref bindFragmentDataLocationIndexed() between
the program: attaching the shaders and linking the program. Note that additional syntax
changes may be needed for GLSL 1.20 and GLSL ES 1.0.
@code
in vec4 position;
in vec3 normal;
in vec2 textureCoordinates;
@endcode
@code
out vec4 color;
out vec3 normal;
@endcode
@code @code
// Shaders attached... // Shaders attached...
@ -174,8 +184,14 @@ layout(location = 0) uniform mat4 transformation;
layout(location = 1) uniform mat4 projection; layout(location = 1) uniform mat4 projection;
@endcode @endcode
If you don't have the required extension, you can get uniform location using If you don't have the required extension, declare the uniforms without the
uniformLocation() after linking stage: `layout()` qualifier and get uniform location using @ref uniformLocation()
*after* linking stage. Note that additional syntax changes may be needed for
GLSL 1.20 and GLSL ES 1.0.
@code
uniform mat4 transformation;
uniform mat4 projection;
@endcode
@code @code
Int transformationUniform = uniformLocation("transformation"); Int transformationUniform = uniformLocation("transformation");
Int projectionUniform = uniformLocation("projection"); Int projectionUniform = uniformLocation("projection");
@ -199,7 +215,13 @@ layout(binding = 1) uniform sampler2D specularTexture;
@endcode @endcode
If you don't have the required extension (or if you want to change the layer If you don't have the required extension (or if you want to change the layer
later), you can set the texture layer uniform using setUniform(Int, Int): later), declare the uniforms without the `layout()` qualifier and set the
texture layer uniform using @ref setUniform(Int, Int). Note that additional
syntax changes may be needed for GLSL 1.20 and GLSL ES 1.0.
@code
uniform sampler2D diffuseTexture;
uniform sampler2D specularTexture;
@endcode
@code @code
setUniform(DiffuseTextureUniform, DiffuseTextureLayer); setUniform(DiffuseTextureUniform, DiffuseTextureLayer);
setUniform(SpecularTextureUniform, SpecularTextureLayer); setUniform(SpecularTextureUniform, SpecularTextureLayer);

Loading…
Cancel
Save