| Support Forum G3D Web Page |
Uniform and macro arguments for a G3D::Shader. More...
Inherits G3D::ReferenceCountedObject.
Inherited by G3D::Args.
Classes | |
| class | Arg |
| This contains the value of a uniform or macro argument passed to shader and its type Macro variables can only be a subset of the possible values. More... | |
| class | GPUAttribute |
| https://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribDivisor.xml More... | |
| class | MacroArgPair |
| union | Scalar |
| 8-byte storage used for all argument types More... | |
| class | UnboundArgument |
| Thrown when an argument is not bound. More... | |
Public Types | |
| typedef Table< String, Arg > | ArgTable |
Public Member Functions | |
| UniformTable () | |
| UniformTable (const Any &any) | |
Supports matrix, color, vector, float, string (as macro), boolean, int, and double arguments. More... | |
| UniformTable (const UniformTable &other) | |
| virtual | ~UniformTable () |
| void | append (const UniformTable &other, const String &prefix="") |
Sets all arguments from other on this. More... | |
| void | append (const shared_ptr< UniformTable > &other, const String &prefix="") |
| void | appendToPreamble (const String &extra) |
| void | clearUniform (const String &s) |
| void | clearUniformBindings () |
| bool | getMacro (const String &name, String &value) const |
| Get the value of the macro arg name, and return its value in value, returns true if the macro arg exists. More... | |
| const GPUAttributeTable & | gpuAttributeTable () const |
| bool | hasPreambleOrMacros () const |
| bool | hasUniform (const String &s) const |
| String | macro (const String &name) const |
| Returns the empty string if the macro is not bound. More... | |
| String | preamble () const |
| String | preambleAndMacroString () const |
| The preamble with macro arg definitions appended. More... | |
| void | setArrayUniform (const String &name, int index, const shared_ptr< BindlessTextureHandle > &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, int val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, float val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Vector2 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Vector3 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Vector4 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Color1 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Color3 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Color4 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Matrix2 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Matrix3 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Matrix4 &val, bool optional=false) |
| void | setArrayUniform (const String &name, int index, const Matrix2x3 &val, bool optional=false) |
| Becomes a GLSL mat3x2. More... | |
| void | setArrayUniform (const String &name, int index, const CoordinateFrame &val, bool optional=false) |
| Becomes a GLSL mat4x3. More... | |
| void | setAttributeArray (const String &name, const AttributeArray &val, int instanceDivisor=0) |
| void | setImageUniform (const String &name, const shared_ptr< Texture > &val, Access access=Access::READ_WRITE, int mipLevel=0, bool optional=false) |
| Uses the texture as the corresponding image type in the shader. More... | |
| void | setImageUniform (const String &name, const shared_ptr< BufferTexture > &val, Access access=Access::READ_WRITE, bool optional=false) |
| Uses the texture as the corresponding *imageBuffer type in the shader. More... | |
| void | setMacro (const String &name, const String &value) |
| void | setMacro (const String &name, const char *value) |
| void | setMacro (const String &name, bool val) |
| false becomes 0 and true becomes 1 More... | |
| void | setMacro (const String &name, int val) |
| void | setMacro (const String &name, uint32 val) |
| void | setMacro (const String &name, double val) |
| void | setMacro (const String &name, float val) |
| void | setMacro (const String &name, const Vector2 &val) |
| void | setMacro (const String &name, const Vector3 &val) |
| void | setMacro (const String &name, const Vector4 &val) |
| void | setMacro (const String &name, const Color1 &val) |
| Becomes float in GLSL. More... | |
| void | setMacro (const String &name, const Color3 &val) |
| void | setMacro (const String &name, const Color4 &val) |
| void | setMacro (const String &name, const Vector2int32 &val) |
| void | setMacro (const String &name, const Vector2uint32 &val) |
| void | setMacro (const String &name, const Vector3int32 &val) |
| void | setMacro (const String &name, const Vector2int16 &val) |
| void | setMacro (const String &name, const Vector3int16 &val) |
| void | setMacro (const String &name, const Vector4int16 &val) |
| void | setMacro (const String &name, const Vector4uint16 &val) |
| void | setMacro (const String &name, const Matrix2 &val) |
| void | setMacro (const String &name, const Matrix3 &val) |
| void | setMacro (const String &name, const Matrix4 &val) |
| void | setMacro (const String &name, const CoordinateFrame &val) |
| Becomes mat3x4 in GLSL. More... | |
| void | setMacro (const String &name, const Matrix &val) |
| void | setPreamble (const String &preamble) |
| Arbitrary string to append to beginning of the shader. More... | |
| void | setUniform (const String &name, bool val, bool optional) |
| void | setUniform (const String &name, bool val) |
| void | setUniform (const String &name, int val, bool optional=false) |
| void | setUniform (const String &name, float val, bool optional=false) |
| void | setUniform (const String &name, uint32 val, bool optional=false) |
| void | setUniform (const String &name, double val, bool optional=false) |
| void | setUniform (const String &name, uint64 val, bool optional=false) |
| void | setUniform (const String &name, const Vector2 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector3 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector4 &val, bool optional=false) |
| void | setUniform (const String &name, const Color1 &val, bool optional=false) |
| Becomes float in GLSL. More... | |
| void | setUniform (const String &name, const Color3 &val, bool optional=false) |
| void | setUniform (const String &name, const Color4 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector2int32 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector2uint32 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector3int32 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector2int16 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector3int16 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector4int16 &val, bool optional=false) |
| void | setUniform (const String &name, const Vector4uint16 &val, bool optional=false) |
| void | setUniform (const String &name, const Matrix2 &val, bool optional=false) |
| void | setUniform (const String &name, const Matrix3 &val, bool optional=false) |
| void | setUniform (const String &name, const Matrix4 &val, bool optional=false) |
| void | setUniform (const String &name, const Matrix2x3 &val, bool optional=false) |
| Becomes a GLSL mat3x2. More... | |
| void | setUniform (const String &name, const Matrix &val, bool optional=false) |
| void | setUniform (const String &name, const CoordinateFrame &val, bool optional=false) |
| Becomes a GLSL mat4x3. More... | |
| void | setUniform (const String &name, const shared_ptr< Texture > &val, const Sampler &settings, bool optional=false) |
| void | setUniform (const String &name, const shared_ptr< BufferTexture > &val, bool optional) |
| void | setUniform (const String &name, const shared_ptr< BufferTexture > &val) |
| void | setUniform (const String &name, const shared_ptr< BindlessTextureHandle > &val, bool optional=false) |
| const Arg & | uniform (const String &name) const |
| Returns the uniform value bound to this name or throws UnboundArgument. More... | |
| const UniformTable::ArgTable & | uniformTable () const |
Protected Types | |
| typedef Table< String, GPUAttribute > | GPUAttributeTable |
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... | |
Protected Attributes | |
| SmallArray< MacroArgPair, 12 > | m_macroArgs |
| We use a SmallArray to avoid heap allocation for every arg instance. More... | |
| String | m_preamble |
| GPUAttributeTable | m_streamArgs |
| Must be empty if m_immediateModeArgs is non-empty. More... | |
| ArgTable | m_uniformArgs |
Friends | |
| class | Shader |
Uniform and macro arguments for a G3D::Shader.
This provides a mechanism for support classes like UniversalMaterial to provide additional arguments to a Shader. AttributeArrays are usually set on Args and not UniformTable, however per-instance attributes may need to be specified for an ArticulatedModel::Pose or related support class.
| typedef Table<String, Arg> G3D::UniformTable::ArgTable |
|
protected |
| G3D::UniformTable::UniformTable | ( | ) |
| G3D::UniformTable::UniformTable | ( | const Any & | any | ) |
Supports matrix, color, vector, float, string (as macro), boolean, int, and double arguments.
Example:
|
virtual |
|
inline |
| void G3D::UniformTable::append | ( | const UniformTable & | other, |
| const String & | prefix = "" |
||
| ) |
Sets all arguments from other on this.
| prefix | If specified, prefix each uniform and macro name with this prefix. |
Referenced by append(), and UniformTable().
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
Get the value of the macro arg name, and return its value in value, returns true if the macro arg exists.
Referenced by macro().
|
inline |
|
inline |
|
inline |
Returns the empty string if the macro is not bound.
|
inline |
| String G3D::UniformTable::preambleAndMacroString | ( | ) | const |
The preamble with macro arg definitions appended.
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const shared_ptr< BindlessTextureHandle > & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| int | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| float | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Vector2 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Vector3 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Vector4 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Color1 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Color3 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Color4 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Matrix2 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Matrix3 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Matrix4 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const Matrix2x3 & | val, | ||
| bool | optional = false |
||
| ) |
Becomes a GLSL mat3x2.
| void G3D::UniformTable::setArrayUniform | ( | const String & | name, |
| int | index, | ||
| const CoordinateFrame & | val, | ||
| bool | optional = false |
||
| ) |
Becomes a GLSL mat4x3.
| void G3D::UniformTable::setAttributeArray | ( | const String & | name, |
| const AttributeArray & | val, | ||
| int | instanceDivisor = 0 |
||
| ) |
| instanceDivisor | Set to 0 for regular indexed rendering and 1 to increment once per instance. https://www.opengl.org/sdk/docs/man3/xhtml/glVertexAttribDivisor.xml |
| void G3D::UniformTable::setImageUniform | ( | const String & | name, |
| const shared_ptr< Texture > & | val, | ||
| Access | access = Access::READ_WRITE, |
||
| int | mipLevel = 0, |
||
| bool | optional = false |
||
| ) |
Uses the texture as the corresponding image type in the shader.
| void G3D::UniformTable::setImageUniform | ( | const String & | name, |
| const shared_ptr< BufferTexture > & | val, | ||
| Access | access = Access::READ_WRITE, |
||
| bool | optional = false |
||
| ) |
Uses the texture as the corresponding *imageBuffer type in the shader.
Referenced by setMacro().
|
inline |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| bool | val | ||
| ) |
false becomes 0 and true becomes 1
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| int | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| double | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| float | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const Vector2int32 & | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const Vector2uint32 & | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const Vector3int32 & | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const Vector2int16 & | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const Vector3int16 & | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const Vector4int16 & | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const Vector4uint16 & | val | ||
| ) |
| void G3D::UniformTable::setMacro | ( | const String & | name, |
| const CoordinateFrame & | val | ||
| ) |
Becomes mat3x4 in GLSL.
| void G3D::UniformTable::setPreamble | ( | const String & | preamble | ) |
Arbitrary string to append to beginning of the shader.
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| bool | val, | ||
| bool | optional | ||
| ) |
Referenced by setUniform().
|
inline |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| int | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| float | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| double | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector2 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector3 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector4 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Color1 & | val, | ||
| bool | optional = false |
||
| ) |
Becomes float in GLSL.
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Color3 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Color4 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector2int32 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector2uint32 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector3int32 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector2int16 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector3int16 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector4int16 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Vector4uint16 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Matrix2 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Matrix3 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Matrix4 & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Matrix2x3 & | val, | ||
| bool | optional = false |
||
| ) |
Becomes a GLSL mat3x2.
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const Matrix & | val, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const CoordinateFrame & | val, | ||
| bool | optional = false |
||
| ) |
Becomes a GLSL mat4x3.
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const shared_ptr< Texture > & | val, | ||
| const Sampler & | settings, | ||
| bool | optional = false |
||
| ) |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const shared_ptr< BufferTexture > & | val, | ||
| bool | optional | ||
| ) |
|
inline |
| void G3D::UniformTable::setUniform | ( | const String & | name, |
| const shared_ptr< BindlessTextureHandle > & | val, | ||
| bool | optional = false |
||
| ) |
Returns the uniform value bound to this name or throws UnboundArgument.
|
inline |
|
friend |
|
protected |
We use a SmallArray to avoid heap allocation for every arg instance.
Referenced by hasPreambleOrMacros().
|
protected |
Referenced by appendToPreamble(), hasPreambleOrMacros(), and preamble().
|
protected |
Must be empty if m_immediateModeArgs is non-empty.
Referenced by gpuAttributeTable(), and G3D::Args::hasStreamArgs().
|
protected |
Referenced by clearUniform(), clearUniformBindings(), hasUniform(), and uniformTable().
1.8.15