OpenGL Shading Language: Difference between revisions

Content deleted Content added
Undid revision 968635494 by 2600:1700:2761:4E0:A880:AAC2:EC9:F64D (talk) nevermind
m linking
Line 71:
Similar to the [[C (programming language)|C programming language]], GLSL supports loops and branching, for instance: if-else, for, switch, etc. Recursion is forbidden and checked for during compilation.
 
User-defined functions are supported and built-in functions are provided. The graphics card manufacturer may optimize built-in functions at the hardware level. Many of these functions are similar to those in the math library of the C programming language while others are specific to graphics programming. Most of the built-in functions and operators, can operate both on scalars and vectors (up to 4 elements), for one or both operands. Common built-in functions that are provided and are commonly used for graphics purposes are: {{code|mix}}, {{code|smoothstep}}, {{code|normalize}}, {{code|inveresqrt}}, {{code|clamp}}, {{code|length}}, {{code|distance}}, {{code|dot}}, {{code|cross}}, {{code|reflect}}, {{code|refract}} and vector {{code|min}} and {{code|max}}. Other functions like {{code|abs}}, {{code|sin}}, {{code|pow}}, etc, are provided but they can also all operate on vector quantities, i.e. {{code|pow(vec3(1.5, 2.0, 2.5), abs(vec3(0.1, -0.2, 0.3)))}}. GLSL supports [[function overloading]] (for both built-in functions and operators, and user-defined functions), so there might be multiple function definitions with the same name, having different number of parameters or parameter types. Each of them can have own independent return type.
 
=== Preprocessor ===