Helper functions and objects for shader and program compiling and linking.
GL Load must have been successfully initialized for these functions to work.
- Todo:
- Add a function for program binary uploading.
|
These functions generate shaders from text strings. They will throw exceptions in the event of compilation failure.
|
GLuint | glutil::CompileShader (GLenum shaderType, boost::string_ref shaderText) |
| Creates a shader object and compiles it with the given text string. More...
|
|
GLuint | glutil::CompileShader (GLenum shaderType, refs::array_ref< const char * > shaderList) |
| As CompileShader(GLenum, const char *), but with a list of strings.
|
|
GLuint | glutil::CompileShader (GLenum shaderType, const std::vector< std::string > &shaderList) |
| As CompileShader(GLenum, const char *), but with a list of strings.
|
|
|
These functions take one or more shader objects and link them together into a program. In the event of a linker error, they will throw an exception.
All shader objects are detached from the program that is returned.
|
GLuint | glutil::LinkProgram (GLuint shaderOne, GLuint shaderTwo) |
| Links the two shader objects into a single program. More...
|
|
GLuint | glutil::LinkProgram (GLuint program, GLuint shaderOne, GLuint shaderTwo) |
| As LinkProgram(GLuint, GLuint), except that it is given a program to do the linking within.
|
|
GLuint | glutil::LinkProgram (boost::string_ref vertexShader, boost::string_ref fragmentShader) |
| Creates a program from two shader strings, one for a vertex shader and one for a fragment shader. More...
|
|
GLuint | glutil::LinkProgram (GLuint program, boost::string_ref vertexShader, boost::string_ref fragmentShader) |
| As LinkProgram(boost::string_ref, boost::string_ref), except that it is given a program to do the linking within.
|
|
GLuint | glutil::LinkProgram (GLuint shader, bool isSeparable=false) |
| Takes a single shader and links it into a program. More...
|
|
GLuint | glutil::LinkProgram (refs::array_ref< GLuint > shaders, bool isSeparable=false) |
| As LinkProgram(GLuint, bool), only with a list of shaders.
|
|
GLuint | glutil::LinkProgram (GLuint program, refs::array_ref< GLuint > shaders) |
| Takes a program and links a number of shaders to it. More...
|
|
GLuint glutil::CompileShader |
( |
GLenum |
shaderType, |
|
|
boost::string_ref |
shaderText |
|
) |
| |
Creates a shader object and compiles it with the given text string.
This function compiles a single string of shader text to produce an OpenGL shader object for the given shader stage.
- Parameters
-
shaderType | The shader stage that the shader object is created for. |
shaderText | The GLSL shader text string. |
- Returns
- The successfully compiled shader object.
- Exceptions
-
CompileLinkException | Thrown if the shader compilation fails. The shader object will be destroyed, and the error log will be stored in the exception. |
GLuint glutil::LinkProgram |
( |
GLuint |
shaderOne, |
|
|
GLuint |
shaderTwo |
|
) |
| |
Links the two shader objects into a single program.
This is a convenience function for the common case of pairing a vertex shader with a fragment shader. It takes the two shaders and links them together into a freshly-created program object.
This function does not allow the user the chance to set pre-link parameters, like transform-feedback, vertex attributes, fragment data locations, or the like. Most of these can be hooked in via features like explicit_attrib_location and similar extensions.
- Exceptions
-
CompileLinkException | Thrown if the linking fails. The program will be destroyed, and the error log will be stored in the exception. |
GLuint glutil::LinkProgram |
( |
boost::string_ref |
vertexShader, |
|
|
boost::string_ref |
fragmentShader |
|
) |
| |
Creates a program from two shader strings, one for a vertex shader and one for a fragment shader.
This is a convenience function for the common case of pairing a vertex shader with a fragment shader. It takes the two shaders by string and links them together into a freshly-created program object.
This function does not allow the user the chance to set pre-link parameters, like transform-feedback, vertex attributes, fragment data locations, or the like. Most of these can be hooked in via features like explicit_attrib_location and similar extensions.
- Exceptions
-
CompileLinkException | Thrown if the shader compilation or program linking fails. In all cases, any previously created shader/program objects will be destroyed. |
GLuint glutil::LinkProgram |
( |
GLuint |
shader, |
|
|
bool |
isSeparable = false |
|
) |
| |
Takes a single shader and links it into a program.
This function is generally only useful when using separable programs.
- Parameters
-
shader | The shader to link. |
isSeparable | If true, then the program will be linked with the GL_SEPARABLE_PROGRAM option. |
- Returns
- The successfully linked program object.
- Exceptions
-
CompileLinkException | Thrown if the linking fails. The program will be destroyed, and the error log will be stored in the exception. |
SeparateShaderNotSupported | If isSeparable is true, thrown when the current GL implementation does not support ARB_separate_shader_objects or GL 4.1 or above. |
GLuint glutil::LinkProgram |
( |
GLuint |
program, |
|
|
refs::array_ref< GLuint > |
shaders |
|
) |
| |
Takes a program and links a number of shaders to it.
- Note
- If a CompileLinkException is thrown, the program object will be destroyed.
- Exceptions
-
CompileLinkException | Thrown if the linking fails. The program will be destroyed, and the error log will be stored in the exception. |
GLuint glutil::MakeSeparableProgram |
( |
GLenum |
shaderType, |
|
|
const char * |
shaderText |
|
) |
| |
Creates a single-stage separable program from the given shader text.
- Parameters
-
shaderType | The shader stage that the shader object is created for. |
shaderText | The GLSL shader text string. |
- Returns
- The successfully linked separable program object.
- Exceptions
-
CompileLinkException | Thrown if the compiling/linking fails. The program will be destroyed, and the error log will be stored in the exception. |
SeparateShaderNotSupported | Thrown when the current GL implementation does not support ARB_separate_shader_objects or GL 4.1 or above. |
GLuint glutil::MakeSeparableProgram |
( |
GLenum |
shaderType, |
|
|
const std::string & |
shaderText |
|
) |
| |
Creates a single-stage separable program from the given shader text.
- Parameters
-
shaderType | The shader stage that the shader object is created for. |
shaderText | The GLSL shader text string. |
- Returns
- The successfully linked separable program object.
- Exceptions
-
CompileLinkException | Thrown if the compiling/linking fails. The program will be destroyed, and the error log will be stored in the exception. |
SeparateShaderNotSupported | Thrown when the current GL implementation does not support ARB_separate_shader_objects or GL 4.1 or above. |