#import <CC3ShaderSemantics.h>
Instance Methods | |
(BOOL) | - configureVariable: |
(NSString *) | - nameOfSemantic: |
(BOOL) | - populateUniform:withVisitor: |
Instance Methods inherited from <CC3Object> | |
(id) | - asWeakReference |
(NSString *) | - fullDescription |
(id) | - resolveWeakReference |
Defines the behaviour required for an object that manages the semantics for a CC3ShaderProgram.
Each CC3ShaderProgram delegates to an object that implements this protocol when it needs to populate the current value of a uniform variable from content within the 3D scene.
- (BOOL) configureVariable: | (CC3GLSLVariable *) | variable |
Configures the specified GLSL variable.
Implementers should attempt to match the specified uniform variable with a semantic and, if found, should set the semantic property on the specified variable, and return YES. If an impementation cannot determine the appropriate semantic, it should avoid setting the semantic property of the uniform and should return NO.
Implementers should also set the scope property of the specified variable. Typically this is derived from the semantic.
In addition, implementers may perform additional configuration behaviour for the specified variable.
Returns whether the variable was successfully configured. When delegating to superclasses or other delegates, implementers can use this return code to determine whether or not to continue attempting to configure the specified variable.
This method is invoked automatically after the GLSL program has been compiled and linked.
Reimplemented in CC3ShaderSemanticsByVarName, and CC3ShaderSemanticsBase.
- (NSString*) nameOfSemantic: | (GLenum) | semantic |
Returns a string description of the specified semantic.
Reimplemented in CC3ShaderSemanticsBase.
- (BOOL) populateUniform: | (CC3GLSLUniform *) | uniform | |
withVisitor: | (CC3NodeDrawingVisitor *) | visitor | |
Populates the specified uniform, if possible, and returns whether the uniform was populated.
The semantic, semanticIndex and size properties of the specified uniform can be used to determine what content is expected by the GLSL program for that uniform. The implementation then retrieves the required content from the scene content accessed via the specified visitor.
To permit access to content within the scene, the specified visitor contains several convenience properties for accessing typical content, including currentMeshNode, currentMaterial, textureCount, camera, and scene properties, and a lightAt: method.
Implementers of this method can use the various set... methods on the specified uniform to set the content into the specified uniform variable. The implementor does not need to manage the current value of the uniform, as it is managed automatically, and the GL engine is only updated if the value has changed.
Implementers should return YES if a value was set into the specified uniform variable, and NO if otherwise. When delegating to superclasses or other delegates, implementers can use this return value to determine whether or not to continue attempting to determine and set the value of the uniform variable.
This method is invoked automatically on every rendering loop. Keep it tight.
Reimplemented in CC3ShaderSemanticsBase.