GLProgram.this

Compiles N times the same GLSL source and link to a program.

<p> The same input is compiled 1 to 6 times, each time prepended with a #define specific to a shader type. </p>

  • VERTEX_SHADER
  • FRAGMENT_SHADER
  • GEOMETRY_SHADER
  • TESS_CONTROL_SHADER
  • TESS_EVALUATION_SHADER
  • COMPUTE_SHADER

<p> Each of these macros are alternatively set to 1 while the others are set to 0. If such a macro isn't used in any preprocessor directive of your source, this shader stage is considered unused.</p>

<p>For conformance reasons, any #version directive on the first line will stay at the top.</p>

Warning: <b>THIS FUNCTION REWRITES YOUR SHADER A BIT.</b> Expect slightly wrong lines in GLSL compiler's error messages.

Example of a combined shader source:

#version 110
uniform vec4 color;

#if VERTEX_SHADER

void main()
{
    gl_Vertex = ftransform();
}

#elif FRAGMENT_SHADER

void main()
{
    gl_FragColor = color;
}

#endif

Limitations:

  • All of #preprocessor directives should not have whitespaces before the #.
  • sourceLines elements should be individual lines!
  1. this()
  2. this(GLShader[] shaders)
  3. this(string[] sourceLines)
    class GLProgram
    this
    (
    string[] sourceLines
    )
  4. this(string wholeSource)

Throws

OpenGLException on error.

Meta