OpenGL
From DaphneWiki
(→Texture Map Readers) |
(→Variable Types) |
||
Line 21: | Line 21: | ||
Samplers cannot be modified by the shader! | Samplers cannot be modified by the shader! | ||
Samplers are read using the texture lookup functions texture1D, texture2D, etc. | Samplers are read using the texture lookup functions texture1D, texture2D, etc. | ||
+ | ====Arrays==== | ||
+ | Arrays of any type can be created. | ||
+ | There are no pointers; to access an array, you must use square brackets. | ||
+ | Texture coordinates are accessed via the built-in array declared as: varying vec4 gl_TexCoord[]; |
Revision as of 06:34, 19 November 2007
Contents |
OpenGL Shading Language Reference
Variable Qualifiers
attribute
frequently changing values from application to vertex shader
uniform
infrequently changing values from application to any shader (vertex or fragment)
varying
interpolated variables from vertex shader to fragment shader
Built-In Variables
If it begins with "gl_" it is a built-in variable. Example is gl_FragColor.
Variable Types
Scalars (regular C-styled variables)
float, int, bool are all supported. Integers are fairly limited and don't behave like they do in C. See orange book, page 66.
Vectors
vec2, vec3, or vec4 (all floating point)
Matrices
mat2, mat3, mat4 (2x2, 3x3, 4x4 matrix respectively)
Texture Map Readers
sampler1D for 1D texture map, sampler2D for 2D texture map, higher dimensions are apparently supported. Samplers cannot be modified by the shader! Samplers are read using the texture lookup functions texture1D, texture2D, etc.
Arrays
Arrays of any type can be created. There are no pointers; to access an array, you must use square brackets. Texture coordinates are accessed via the built-in array declared as: varying vec4 gl_TexCoord[];