|
HDK
|
#include <GlslProgram.h>
Classes | |
| struct | Input |
Public Member Functions | |
| virtual | ~GlslProgram () |
| Destructor. More... | |
Shader code setup | |
| void | setStages (ShaderPtr shader) |
| void | addStage (const string &stage, const string &sourceCode) |
| const string & | getStageSourceCode (const string &stage) const |
| ShaderPtr | getShader () const |
| Return the shader, if any, used to generate this program. More... | |
Program building | |
| void | build () |
| bool | hasBuiltData () |
| Return true if built shader program data is present. More... | |
| void | clearBuiltData () |
Program activation | |
| bool | bind () |
| bool | hasActiveAttributes () const |
| Return true if the program has active attributes. More... | |
| bool | hasUniform (const string &name) |
| Return true if a uniform with the given name is present. More... | |
| void | bindUniform (const string &name, ConstValuePtr value, bool errorIfMissing=true) |
| Bind a value to the uniform with the given name. More... | |
| void | bindAttribute (const GlslProgram::InputMap &inputs, MeshPtr mesh) |
| void | bindPartition (MeshPartitionPtr partition) |
| Bind input geometry partition (indexing) More... | |
| void | bindMesh (MeshPtr mesh) |
| Bind input geometry streams. More... | |
| void | unbindGeometry () |
| Unbind any bound geometry. More... | |
| void | bindTextures (ImageHandlerPtr imageHandler) |
| Bind any input textures. More... | |
| void | bindLighting (LightHandlerPtr lightHandler, ImageHandlerPtr imageHandler) |
| Bind lighting. More... | |
| void | bindViewInformation (CameraPtr camera) |
| Bind view information. More... | |
| void | bindTimeAndFrame (float time=1.0f, float frame=1.0f) |
| Bind time and frame. More... | |
| void | unbind () const |
| Unbind the program. Equivalent to binding no program. More... | |
Utilities | |
| void | printUniforms (std::ostream &outputStream) |
| Print all uniforms to the given stream. More... | |
| void | printAttributes (std::ostream &outputStream) |
| Print all attributes to the given stream. More... | |
Static Public Member Functions | |
| static GlslProgramPtr | create () |
| Create a GLSL program instance. More... | |
Static Public Attributes | |
| static unsigned int | UNDEFINED_OPENGL_RESOURCE_ID |
| static int | UNDEFINED_OPENGL_PROGRAM_LOCATION |
Protected Member Functions | |
| GlslProgram () | |
| const InputMap & | updateUniformsList () |
| const InputMap & | updateAttributesList () |
| ConstValuePtr | findUniformValue (const string &uniformName, const InputMap &uniformList) |
| ImagePtr | bindTexture (unsigned int uniformType, int uniformLocation, const FilePath &filePath, ImageHandlerPtr imageHandler, const ImageSamplingProperties &imageProperties) |
| void | bindUniformLocation (int location, ConstValuePtr value) |
Static Protected Member Functions | |
| static int | mapTypeToOpenGLType (TypeDesc type) |
Program introspection | |
| using | InputPtr = std::shared_ptr< Input > |
| Program input structure shared pointer type. More... | |
| using | InputMap = std::unordered_map< string, InputPtr > |
| Program input shaded pointer map type. More... | |
| const InputMap & | getUniformsList () |
| const InputMap & | getAttributesList () |
| void | findInputs (const string &variable, const InputMap &variableList, InputMap &foundList, bool exactMatch) |
A class representing an executable GLSL program.
There are two main interfaces which can be used. One which takes in a HwShader and one which allows for explicit setting of shader stage code.
Definition at line 31 of file GlslProgram.h.
| using GlslProgram::InputMap = std::unordered_map<string, InputPtr> |
Program input shaded pointer map type.
Definition at line 127 of file GlslProgram.h.
| using GlslProgram::InputPtr = std::shared_ptr<Input> |
Program input structure shared pointer type.
Definition at line 125 of file GlslProgram.h.
|
virtual |
Destructor.
|
protected |
Set the code stages based on a list of stage strings. Refer to the ordering of stages as defined by a HwShader.
| stage | Name of the shader stage. |
| sourceCode | Source code of the shader stage. |
| bool GlslProgram::bind | ( | ) |
Bind the program.
| void GlslProgram::bindAttribute | ( | const GlslProgram::InputMap & | inputs, |
| MeshPtr | mesh | ||
| ) |
| void GlslProgram::bindLighting | ( | LightHandlerPtr | lightHandler, |
| ImageHandlerPtr | imageHandler | ||
| ) |
Bind lighting.
| void GlslProgram::bindPartition | ( | MeshPartitionPtr | partition | ) |
Bind input geometry partition (indexing)
|
protected |
| void GlslProgram::bindTextures | ( | ImageHandlerPtr | imageHandler | ) |
Bind any input textures.
| void GlslProgram::bindUniform | ( | const string & | name, |
| ConstValuePtr | value, | ||
| bool | errorIfMissing = true |
||
| ) |
Bind a value to the uniform with the given name.
|
protected |
| void GlslProgram::build | ( | ) |
Build shader program data from the source code set for each shader stage.
An exception is thrown if the program cannot be built. The exception will contain a list of compilation errors.
| void GlslProgram::clearBuiltData | ( | ) |
Build shader program data from the source code set for each shader stage.
An exception is thrown if the program cannot be built. The exception will contain a list of compilation errors.
|
inlinestatic |
Create a GLSL program instance.
Definition at line 35 of file GlslProgram.h.
| void GlslProgram::findInputs | ( | const string & | variable, |
| const InputMap & | variableList, | ||
| InputMap & | foundList, | ||
| bool | exactMatch | ||
| ) |
Find the locations in the program which starts with a given variable name
| variable | Variable to search for |
| variableList | List of program inputs to search |
| foundList | Returned list of found program inputs. Empty if none found. |
| exactMatch | Search for exact variable name match. |
|
protected |
| const InputMap& GlslProgram::getAttributesList | ( | ) |
Get list of program input attributes. The program must have been created successfully first. An exception is thrown if the parsing of the program for attribute cannot be performed.
|
inline |
Return the shader, if any, used to generate this program.
Definition at line 61 of file GlslProgram.h.
Get source code string for a given stage.
| const InputMap& GlslProgram::getUniformsList | ( | ) |
Get list of program input uniforms. The program must have been created successfully first. An exception is thrown if the parsing of the program for uniforms cannot be performed.
| bool GlslProgram::hasActiveAttributes | ( | ) | const |
Return true if the program has active attributes.
| bool GlslProgram::hasBuiltData | ( | ) |
Return true if built shader program data is present.
| bool GlslProgram::hasUniform | ( | const string & | name | ) |
Return true if a uniform with the given name is present.
| void GlslProgram::printAttributes | ( | std::ostream & | outputStream | ) |
Print all attributes to the given stream.
| void GlslProgram::printUniforms | ( | std::ostream & | outputStream | ) |
Print all uniforms to the given stream.
Set up code stages to validate based on an input hardware shader.
| shader | Hardware shader to use |
| void GlslProgram::unbind | ( | ) | const |
Unbind the program. Equivalent to binding no program.
| void GlslProgram::unbindGeometry | ( | ) |
Unbind any bound geometry.
|
protected |
|
protected |
|
static |
Definition at line 213 of file GlslProgram.h.
|
static |
Definition at line 212 of file GlslProgram.h.