stevensona/shader-toy

Compilation error when using #define

Closed this issue · 1 comments

Compilation fails when using the following code

#define test
#ifdef test
void mainImage( out vec4 fragColor, in vec2 fragCoord )
#endif
{
    fragColor = vec4(1.0);
}

This is unfortunately just a shortcoming of our preprocessing, see this comment for details. As a result in a case like this we simply fail to recognize that there is a mainImage function. You can get around this by either enabling the option "Shader Toy Strict Compatibility" or adding the #StrictCompatibility directive at the beginning of your shader. If you use that shader outside of this extension make sure to wrap it in #ifdef SHADER_TOY:

#ifdef SHADER_TOY
#StrictCompatibility
#endif

#ifdef test
void mainImage( out vec4 fragColor, in vec2 fragCoord )
#endif
{
    fragColor = vec4(1.0);
}