gfm



class  GLProgram;

OpenGL Program wrapper.


this(OpenGL gl);

Creates an empty program.

Throws
OpenGLException on error.

this(OpenGL gl, GLShader[] shaders...);

Creates a program from a set of compiled shaders.

Throws
OpenGLException on error.

this(OpenGL gl, string[] sourceLines);

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

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

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

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.



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

Warning:
THIS FUNCTION REWRITES YOUR SHADER A BIT. 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!
Throws
OpenGLException on error.

this(OpenGL gl, string wholeSource);

Ditto, except with lines in a single string.


void  attach(GLShader[] compiledShaders...);

Attaches OpenGL shaders to this program.

Throws
OpenGLException on error.

void  link();

Links this OpenGL program.

Throws
OpenGLException on error.

void  use();

Uses this program for following draw calls.

Throws
OpenGLException on error.

void  unuse();

Unuses this program.

Throws
OpenGLException on error.

const(char)[]  getLinkLog();

Gets the linking report.

Returns
Log output of the GLSL linker. Can return null!
Throws
OpenGLException on error.

GLUniform  uniform(string name);

Gets an  uniform by name.

Returns
A GLUniform with this name. This GLUniform might be created on demand if

the name hasn't been found. So it might be a "fake"  uniform.
See Also
GLUniform.

GLAttribute  attrib(string name);

Gets an attribute by name.

Returns
A GLAttribute retrieved by name.
Throws
OpenGLException on error.

const pure nothrow GLuint  handle();

Returns
Wrapped OpenGL resource  handle.

class  GLAttribute;

Represent an OpenGL program attribute. Owned by a GLProgram.

See Also
GLProgram.

this(OpenGL gl, string name);

Creates a fake disabled attribute, designed to cope with attribute

that have been optimized out by the OpenGL driver, or those which do not exist.