Add the following preprocessor directives to include conditionals in your shader code. This is most useful when you only want to run a block of code under certain conditions; for example, to execute code only during a specified shader stage; or, if to specify the version of OGSFX that should be used to compile the shaders.
#version versionNumber
If specified, this directive must be the very first line of the file. It specifies the version of OGSFX that should be used to compile/link the shaders.
OGSFX GLSL OpenGL version
#version 100 #version 150 OpenGL 3.2
#version 150 #version 150 OpenGL 3.2
#version 330 #version 330 OpenGL 3.3 * default for Windows and Linux
#version 400 #version 400 OpenGL 4.0
#version 410 #version 410 OpenGL 4.1
#version 420 #version 420 OpenGL 4.2 * default for OS/X
#version 430 #version 430 OpenGL 4.3
#pragma pragmaName : Boolean
Currently, only the following pragma are available:
#pragma Usecb : true // Use constant buffers (default - true)
#pragma OptimizeUniforms : true // Optimize uniforms by packing them into a single constant buffer (default - true)
#error "Should not be there!"
This directive causes the implementation to write a diagnostic message to the shader’s information log. The message will be the tokens following the #error
directive, up to the first new-line. The implementation must then consider the shader to be ill-formed.
#include "resources.ogsfh"
The #include
directive instructs the preprocessor to treat the contents of the specified file as if it exists in the source program, at the point where the directive appears.
#if
, #ifdef
, #ifndef
, #else
, #elif
, and #endif
are defined to operate as are standard for ANSI C preprocessors.
#define
and #undef
are defined as are standard for ANSI C preprocessors for macro definitions, both with and without macro parameters.
Expressions following #if
and #elif
are restricted to expressions operating on literal integer constants, plus identifiers consumed by the defined operator. Character constants are not supported.
#vertexshader
#pixelshader
#geometryshader
#tessevalshader
#tesscontrolshader
#endshader
These directives can be used to enable code for a specified shader stage: All code delimited by the pair #vertexshader ... #endshader
is compiled only on the vertex shader. Similarly, code delimited by #pixelshader ... #endshader
or #geometryshader ... #endshader
is compiled only on the pixel or geometry shader.