1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
/* The ARB_shading_language_420pack says:
*
* "Named compile-time constants or read-only variables can be declared using
* the const qualifier. The const qualifier can be used with any of the
* non-void transparent basic data types, as well as with structures and arrays
* of these. It is an error to write to a const variable outside of its
* declaration, so they must be initialized when declared. For example,
*
* const vec3 zAxis = vec3 (0.0, 0.0, 1.0);
* const float ceiling = a + b; // a and b not necessarily constants"
*
* Verify that const variables can be initialized with non-constant expressions.
*/
[require]
GLSL >= 1.30
GL_ARB_shading_language_420pack
[vertex shader passthrough]
[fragment shader]
#extension GL_ARB_shading_language_420pack: enable
uniform vec4 color;
out vec4 frag_color;
void main() {
const vec4 const_color = color + vec4(-1.0, 1.0, 0.0, 0.0);
frag_color = const_color;
}
[test]
uniform vec4 color 1.0 0.0 0.0 1.0
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
|