GLProgram.this

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

<p> The same input is compiled 1 to 5 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

<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:

1 #version 110
2 uniform vec4 color;
3 
4 #if VERTEX_SHADER
5 
6 void main()
7 {
8     gl_Vertex = ftransform();
9 }
10 
11 #elif FRAGMENT_SHADER
12 
13 void main()
14 {
15     gl_FragColor = color;
16 }
17 
18 #endif

Limitations:

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

Throws

OpenGLException on error.

Meta