Graphics Reference
In-Depth Information
Note that macros cannot be defined with parameters (as they can be
in C++ macros). The #if , #else , and #elif directives can use the
defined test to see whether a macro is defined. The following macros are
predefined and their description is given next:
__LINE__ // Replaced with the current line number in a shader
__FILE__ // Always 0 in OpenGL ES 3.0
__VERSION__ // The OpenGL ES shading language version
// (e.g., 300)
GL_ES
// This will be defined for ES shaders to a value
// of 1
The #error directive will cause a compilation error to occur during shader
compilation, with a corresponding message being placed in the info log.
The #pragma directive is used to specify implementation-specific directives
to the compiler.
Another important directive in the preprocessor is #extension , which is
used to enable and set the behavior of extensions. When vendors (or groups
of vendors) extend the OpenGL ES Shading Language, they will create a
language extension specification (e.g., GL_NV_shadow_samplers_cube ).
The shader must instruct the compiler as to whether to allow extensions
to be used, and if not, which behavior should occur. This is done using the
#extension directive. The general format of #extension usage is shown in
the following code:
// Set behavior for an extension
#extension extension_name : behavior
// Set behavior for ALL extensions
#extension all : behavior
The first argument will be either the name of the extension (e.g.,
GL_NV_shadow_samplers_cube ) or all , which means that the behavior
applies to all extensions. The behavior has four possible options, as shown in
Table 5-5.
Table 5-5
Extension Behaviors
Extension Behavior
Description
require
The extension is required, so the preprocessor will
throw an error if the extension is not supported. If all
is specified, this will always throw an error.
enable
The extension is enabled, so the preprocessor will warn
if the extension is not supported. The language will
be processed as if the extension is enabled. If all is
specified, this will always throw an error.
 
 
Search WWH ::




Custom Search