Portal:OpenGL Shading Language/Core Language: Difference between revisions
m Link typo. |
Slightly shorter. |
||
Line 1: | Line 1: | ||
The '''Core Language''' of GLSL is grammatically very similar to C, with some elements from C++. It contains the same looping and conditional keywords as C/C++ | The '''Core Language''' of GLSL is grammatically very similar to C, with some elements from C++. It contains the same looping and conditional keywords as C/C++. | ||
One big difference is that GLSL shaders must start with a [[Core_Language_%28GLSL%29#Version|version declaration]], which tells the compiler what version of the language to compile the rest. A shader that does not begin with a version declaration will be assumed to be the (very ancient) version 1.10. | One big difference is that GLSL shaders must start with a [[Core_Language_%28GLSL%29#Version|version declaration]], which tells the compiler what version of the language to compile the rest. A shader that does not begin with a version declaration will be assumed to be the (very ancient) version 1.10. | ||
Another large difference between C/C++ and GLSL is how [[Core_Language_%28GLSL%29#Functions|functions]] work. The general syntax is similar, but the parameter passing conventions are quite different, allowing functions to have dedicated output parameters without pointers. A more difficult issue is that GLSL does not support ''recursion'' at all; a function must never call itself or call another function that calls itself. | Another large difference between C/C++ and GLSL is how [[Core_Language_%28GLSL%29#Functions|functions]] work. The general syntax is similar, but the parameter passing conventions are quite different, allowing functions to have dedicated output parameters without pointers. A more difficult issue is that GLSL does not support ''recursion'' at all; a function must never call itself or call another function that calls itself. |
Latest revision as of 04:31, 25 July 2013
The Core Language of GLSL is grammatically very similar to C, with some elements from C++. It contains the same looping and conditional keywords as C/C++.
One big difference is that GLSL shaders must start with a version declaration, which tells the compiler what version of the language to compile the rest. A shader that does not begin with a version declaration will be assumed to be the (very ancient) version 1.10.
Another large difference between C/C++ and GLSL is how functions work. The general syntax is similar, but the parameter passing conventions are quite different, allowing functions to have dedicated output parameters without pointers. A more difficult issue is that GLSL does not support recursion at all; a function must never call itself or call another function that calls itself.