v2.0.2
Instance Methods | List of all members
CC3ShaderSemanticsByVarName Class Reference

#import <CC3ShaderSemantics.h>

Inheritance diagram for CC3ShaderSemanticsByVarName:
Inheritance graph
[legend]

Instance Methods

(void) - __deprecated
 
(void) - __deprecated
 
(void) - addVariableConfiguration:
 
(BOOL) - configureVariable:
 
(void) - mapVarName:toSemantic:
 
(void) - mapVarName:toSemantic:at:
 
(void) - populateWithDefaultVariableNameMappings
 
- Instance Methods inherited from CC3ShaderSemanticsBase
(NSString *) - nameOfSemantic:
 
(BOOL) - populateUniform:withVisitor:
 

Additional Inherited Members

- Class Methods inherited from CC3ShaderSemanticsBase
(id) + semanticsDelegate
 

Detailed Description

CC3ShaderSemanticsByVarName extends CC3ShaderSemanticsBase to add the assignment of semantics to uniform and attribute variables based on matching specific variable names within the GLSL source code.

Since the semantics are determined by GLSL variable name, it is critical that the GLSL shader code use very specific attribute and uniform variable names.

Method Documentation

- (void) __deprecated
Deprecated:
Populates this instance with the default Cocos3D mappings between variable names and semantics that are based on uniforms collected together into structures.

Structure-based mapping provides an organized approach to managing uniform names, but are not compatible with current OSX implementations of GLSL. Current OSX drivers do not handle structure-based uniforms correctly.

If you have developed GLSL shaders under iOS, that use this structure-based approach to uniform naming, you can use this method to populate a semantic mapping that supports this approach. For new iOS applications, and for all OSX applications, you should use the semantic uniform name mappings defined by the populateWithDefaultVariableNameMappings method.

Provided by category CC3ShaderSemanticsByVarName(DefaultMappings).

- (void) __deprecated
Deprecated:
Populates this instance with the default Cocos3D mappings initially included with early versions of Cocos3D 2.0.

These legacy mappings use less efficient uniform mappings, including use of the array-of-structures paradigm. For GLSL under OpenGL ES, each element of each structure in an array of structures is assigned to its own uniform variable for the purpose of managing and populating the uniforms. This can significantly increase the number of actual uniforms, and results in a corresponding increase in the overhead of managing and populating the larger number of uniforms.

It recommended that the array-of-structure approach offered by this method be avoided. It is provided here to provide backwards compatibility for shaders already developed using these legacy mappings.

Provided by category CC3ShaderSemanticsByVarName(DefaultMappings).

- (void) addVariableConfiguration: (CC3GLSLVariableConfiguration *)  varConfig

Adds the specified variable configuration to the configuration lookup.

Configurations added via this method are used to configure the variables submitted to the configureVariable: method.

Configurations are added to the lookup by name. If a configuration with the same name already exists in the lookup, it is replaced with the specified configuration.

- (BOOL) configureVariable: (CC3GLSLVariable *)  variable

This implementation uses the name property of the specified variable to look up a configuration, and sets the semantic property of the specified variable to that of the retrieved configuration.

Returns YES if a configuration was found and the semantic was assigned, or NO if a configuration could not be found for the variable.

Implements CC3ShaderSemanticsBase.

- (void) mapVarName: (NSString *)  name
toSemantic: (GLenum)  semantic 

Adds a variable configruation that maps the specified variable name to the specified semantic at semantic index zero.

This is a convenience method that invokes the mapVarName:toSemantic:at: method, passing a value of zero for the semanticIndex argument. See the description of that method for more info.

- (void) mapVarName: (NSString *)  name
toSemantic: (GLenum)  semantic
at: (GLuint)  semanticIndex 

Adds a variable configruation that maps the specified variable name to the specified semantic and semantic index.

This implementation creates an instance of CC3GLSLVariableConfiguration configured with the specified name, semantic and semantic index, and invokes the addVariableConfiguration: method.

The value of the semantic parameter is typically one of values in the CC3Semantic enumeration, but an application can define and use additional semantics beyond the values defined by CC3Semantic. Additional semantics defined by the application should fall with the range defined by the kCC3SemanticAppBase and kCC3SemanticMax constants, inclusively.

- (void) populateWithDefaultVariableNameMappings

Populates this instance with the default Cocos3D mappings between variable names and semantics.

An application wishing to add additional semantic mappings, or override any of the default mappings can invoke this method, and then invoke the mapVarName:toSemantic: or addVariableConfiguration: methods to add or change any of the mappings.

An application wishing to define a completely different semantic mapping may instantiate an instance of this class, will avoid invoking this method, and will typically add its own population methods in a class extension category.

Provided by category CC3ShaderSemanticsByVarName(DefaultMappings).


The documentation for this class was generated from the following file: