Shader Preprocessor

The first step in compilation of a GLSL shader is parsing by the preprocessor. Similar to the “C” preprocessor, there are a number of directives for creating conditional compilation blocks and defining values. However, unlike the “C” preprocessor, there is no file inclusion (#include).

Preprocessor Directives

Table 2.9 lists the preprocessor directives accepted by the GLSL preprocessor and their functions.

Table 2.9. GLSL Preprocessor Directives

Image
Macro Definition

The GLSL preprocessor allows macro definition in much the same manner as the “C” preprocessor, with the exception of the string substitution and concatenation facilities. ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.