Support Forum G3D Web Page |
A wrapper around an actual openGL shader program object. More...
Inherits G3D::ReferenceCountedObject.
Classes | |
class | AttributeDeclaration |
Vertex Attribute (stream) variable declaration discovered in the program. More... | |
class | UniformDeclaration |
Uniform variable declaration discovered in the program. More... | |
Public Types | |
typedef Table< String, AttributeDeclaration > | AttributeDeclarationTable |
typedef Table< String, UniformDeclaration > | UniformDeclarationTable |
Public Member Functions | |
ShaderProgram () | |
void | addActiveAttributesFromProgram () |
Called from the constructor. More... | |
void | addActiveUniformsFromProgram () |
Called from the constructor. More... | |
void | addUniformsFromCode (const String &code, const Args &args) |
Finds any uniform variables in the code string, and adds them to the uniform table. More... | |
void | addUniformsFromSource (const Array< PreprocessedShaderSource > &preprocessedSource, const Args &args) |
Finds any uniform variables in the code for all shader stages that are not already in the uniform list that OpenGL returned and adds them to the uniform declaration table. More... | |
void | addVertexAttributesFromSource (const Array< PreprocessedShaderSource > &preprocessedSource, const Args &args) |
Finds any vertex attribute variables in the code for the vertex shader that are not already in the attribute list that OpenGL returned and adds them to the attribute declaration table. More... | |
void | compile (const Array< PreprocessedShaderSource > &preprocessedSource, const String &preambleAndMacroArgs, const Args &args, const Table< int, String > &indexToNameTable, Array< String > &code) |
Compile using the current macro args, preamble, and source code. More... | |
bool | containsNonDummyUniform (const String &name) |
True if and only if the uniform declaration table contains a non-dummy entry name. More... | |
GLuint | glShaderProgramObject () |
The underlying OpenGL Program Object. More... | |
void | init (const Array< PreprocessedShaderSource > &preprocessedSource, const String &preambleAndMacroArgs, const Args &args, const Table< int, String > &indexToNameTable) |
Compile and link the shader, and set up the formal parameter lists. More... | |
bool | isOk () |
False if and only if there was an error in compilation or linking. More... | |
void | link () |
Link the program object. More... | |
void | printUniformDeclarations () const |
Used for error reporting. More... | |
Static Public Member Functions | |
static shared_ptr< ShaderProgram > | create (const Array< PreprocessedShaderSource > &preprocessedSource, const String &preambleAndMacroArgs, const Args &args, const Table< int, String > &indexToNameTable) |
Compile and link the shader, returning a reference to it. More... | |
Public Attributes | |
AttributeDeclarationTable | attributeDeclarationTable |
GLuint | glProgramObject |
The underlying OpenGL Program Object. More... | |
GLuint | glShaderObject [STAGE_COUNT] |
The underlying OpenGL Shader Objects for all possible shader stages. More... | |
String | messages |
Warning and error messages generated during compilation and/or linking. More... | |
bool | ok |
False if compilation and/or linking failed. More... | |
UniformDeclarationTable | uniformDeclarationTable |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Friends | |
class | Shader |
A wrapper around an actual openGL shader program object.
Contains the shader objects and declarations of variables found by querying the program object
|
inline |
void G3D::Shader::ShaderProgram::addActiveAttributesFromProgram | ( | ) |
Called from the constructor.
void G3D::Shader::ShaderProgram::addActiveUniformsFromProgram | ( | ) |
Called from the constructor.
Finds any uniform variables in the code string, and adds them to the uniform table.
args | used to evaluate pragmas in array bounds |
void G3D::Shader::ShaderProgram::addUniformsFromSource | ( | const Array< PreprocessedShaderSource > & | preprocessedSource, |
const Args & | args | ||
) |
Finds any uniform variables in the code for all shader stages that are not already in the uniform list that OpenGL returned and adds them to the uniform declaration table.
This causes ShaderProgram to surpress warnings about setting variables that have been compiled away–those warnings are annoying when temporarily commenting out code.
args | used to evaluate pragmas in array bounds |
void G3D::Shader::ShaderProgram::addVertexAttributesFromSource | ( | const Array< PreprocessedShaderSource > & | preprocessedSource, |
const Args & | args | ||
) |
Finds any vertex attribute variables in the code for the vertex shader that are not already in the attribute list that OpenGL returned and adds them to the attribute declaration table.
This causes ShaderProgram to surpress warnings about setting variables that have been compiled away–those warnings are annoying when temporarily commenting out code.
void G3D::Shader::ShaderProgram::compile | ( | const Array< PreprocessedShaderSource > & | preprocessedSource, |
const String & | preambleAndMacroArgs, | ||
const Args & | args, | ||
const Table< int, String > & | indexToNameTable, | ||
Array< String > & | code | ||
) |
Compile using the current macro args, preamble, and source code.
code | Code after the G3D preprocessor, preamble and macroArgs, for use in reporting link errors. |
bool G3D::Shader::ShaderProgram::containsNonDummyUniform | ( | const String & | name | ) |
True if and only if the uniform declaration table contains a non-dummy entry name.
|
static |
Compile and link the shader, returning a reference to it.
indexToNameTable | is for converting file indices to filenames, for useful error/warning messages |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
inline |
The underlying OpenGL Program Object.
void G3D::Shader::ShaderProgram::init | ( | const Array< PreprocessedShaderSource > & | preprocessedSource, |
const String & | preambleAndMacroArgs, | ||
const Args & | args, | ||
const Table< int, String > & | indexToNameTable | ||
) |
Compile and link the shader, and set up the formal parameter lists.
|
inline |
False if and only if there was an error in compilation or linking.
void G3D::Shader::ShaderProgram::link | ( | ) |
Link the program object.
void G3D::Shader::ShaderProgram::printUniformDeclarations | ( | ) | const |
Used for error reporting.
|
friend |
AttributeDeclarationTable G3D::Shader::ShaderProgram::attributeDeclarationTable |
GLuint G3D::Shader::ShaderProgram::glProgramObject |
The underlying OpenGL Program Object.
Referenced by glShaderProgramObject().
GLuint G3D::Shader::ShaderProgram::glShaderObject[STAGE_COUNT] |
The underlying OpenGL Shader Objects for all possible shader stages.
String G3D::Shader::ShaderProgram::messages |
Warning and error messages generated during compilation and/or linking.
bool G3D::Shader::ShaderProgram::ok |
False if compilation and/or linking failed.
Referenced by isOk().
UniformDeclarationTable G3D::Shader::ShaderProgram::uniformDeclarationTable |