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

#import <CC3GLSLVariable.h>

Inheritance diagram for CC3GLSLVariable:
Inheritance graph
[legend]

Instance Methods

(id) - copyAsClass:
 
(id) - copyWithZone:asClass:
 
(NSString *) - fullDescription
 
(id) - initInProgram:atIndex:
 
(void) - normalizeName
 
(void) - populateFrom:
 

Class Methods

(id) + variableInProgram:atIndex:
 

Properties

GLuint index
 
BOOL isGLStateKnown
 
GLint location
 
NSString * name
 
CC3ShaderProgramprogram
 
CC3GLSLVariableScope scope
 
GLenum semantic
 
GLuint semanticIndex
 
GLint size
 
GLuint storageElementCount
 
GLenum type
 
GLuint typeStorageElementCount
 

Detailed Description

Represents a variable used in a GLSL shader program.

Different subclasses are used for uniform variables and attribute variables.

A variable may contain an int or float scalar, an int or float vector, a float matrix, or an array of any of those types, as indicated by the type and size properties.

Method Documentation

- (id) copyAsClass: (Class)  aClass

Returns a newly allocated (retained) copy of this instance.

The new copy will be an instance of the specified class, whose content is copied from this instance.

Care should be taken when choosing the class to be instantiated. If the class is different than that of this instance, the populateFrom: method of that class must be compatible with the contents of this instance.

As with all copy behaviour, the returned instance is retained. It is the responsiblity of the invoker to manage the lifecycle of the returned instance and perform the corresponding invocation of the release method at the appropriate time.

Subclasses that extend copying should not override this method, but should override the populateFrom: method instead.

- (id) copyWithZone: (NSZone *)  zone
asClass: (Class)  aClass 

Returns a newly allocated (retained) copy of this instance.

The new copy will be an instance of the specified class, whose content is copied from this instance.

Care should be taken when choosing the class to be instantiated. If the class is different than that of this instance, the populateFrom: method of that class must be compatible with the contents of this instance.

As with all copy behaviour, the returned instance is retained. It is the responsiblity of the invoker to manage the lifecycle of the returned instance and perform the corresponding invocation of the release method at the appropriate time.

Subclasses that extend copying should not override this method, but should override the populateFrom: method instead.

- (NSString*) fullDescription

Returns a detailed description of this instance.

- (id) initInProgram: (CC3ShaderProgram *)  program
atIndex: (GLuint)  index 

Initializes this instance at the specified index within the specified program.

- (void) normalizeName

Ensures this variable has a valid name.

  • Removes the subscript suffix ([0]), if it exists.
  • Marks this variable as redundant, by setting the semantic to kCC3SemanticRedundant if a subscript other than ([0]) exists.

This method is invoked automatically when the instance is initialized. Normally, you will never need to invoke this method.

- (void) populateFrom: (CC3GLSLVariable *)  another

Template method that populates this instance from the specified other instance.

This method is invoked automatically during object copying via the copy or copyWithZone: method. In most situations, the application should use the copy method, and should never need to invoke this method directly.

Subclasses that add additional instance state (instance variables) should extend copying by overriding this method to copy that additional state. Superclass that override this method should be sure to invoke the superclass implementation to ensure that superclass state is copied as well.

+ (id) variableInProgram: (CC3ShaderProgram *)  program
atIndex: (GLuint)  index 

Allocates and initializes an autoreleased instance at the specified index within the specified program.

Property Documentation

- (GLuint) index
readnonatomicassign

The index of this variable within the GL program object.

This is distinct from the location property.

- (BOOL) isGLStateKnown
readwritenonatomicassign

Indicates whether the value of the variable in the shader program is known.

To maintain efficient performance, the value of this variable will be set in the shader program only if the value of this variable has been changed since the last time it was set in the GL engine.

Setting the value of this property to NO will cause the value in the GL engine to be set the next time the shader program is used, regardless of whether the value of this variable has been changed since the last time the shader program was used.

- (GLint) location
readnonatomicassign

The location of this variable within the GL program object.

This is distinct from the index property.

- (NSString*) name
readnonatomicretain

The name of this variable in the GLSL shader source code.

- (CC3ShaderProgram*) program
readnonatomicassign

The GL program object containing this variable.

- (CC3GLSLVariableScope) scope
readwritenonatomicassign

Indicates the scope of a GLSL variable.

GLSL variable are automatically populated prior to drawing. This property indicates when and how often the variable needs to be populated.

Most GLSL variables need to be populated anew as each node is drawn. But some variables, such as lighting or camera content only needs to be populated once each time the scene is drawn, and some other variables, such as bone matrices, need to be populated on each draw call.

- (GLenum) semantic
readwritenonatomicassign

A symbolic constant indicating the semantic meaning of this variable.

The value of this property 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.

The initial value of this property is kCC3SemanticNone.

- (GLuint) semanticIndex
readwritenonatomicassign

When the semantic refers to an element of a structure that may have multiple instances, this property indicates to which instance this variable refers.

This property is a zero-based index. For variables that do not appear in multiple structures, this property will always be zero.

As an example, there may be mulitple lights in a scene, each tracked in the GLSL by a structure, one element of which might be the diffuse color property. For the variable associated with the diffuse color of the third light, the value of the semantic property would be kCC3SemanticLightColorDiffuse and the value of this property would be 2.

On the other hand, for variables that represent an array of non-structure values, there will only be one instance of the variable, but the size property of that variable will indicate how many values are being managed by that single variable. For these types of variables, the value of this property will always be zero.

As an example of an array of scalar values. If a single GLSL variable is defined to track the ambient color of multiple lights (ie- defined as an array of vec4), the value of the semantic property would be kCC3SemanticLightColorDiffuse, the value of the size property would be the size of the array as defined in the GLSL, and the value of this property would be zero. In this case, the values of the diffuse colors of all lights will be set as a single array.

The initial value of this property is zero.

- (GLint) size
readnonatomicassign

Returns the size of the variable content, in units of the type indicated by the type property.

If the variable is declared as an array in the GLSL program, this property will return the size of that array, otherwise it will return the value 1.

- (GLuint) storageElementCount
readnonatomicassign

Returns the number of memory storage elements consumed by this variable.

If this variable represents an array (the size property returns a value greater than one), the value returned by this property indicates the number of storage elements required for the entire array.

Returns the result of multipying the typeStorageElementCount property by the size property.

- (GLenum) type
readnonatomicassign

Returns a symbolic constant indicating the type of content held by this variable.

The returned value depends on the type of variable being tracked, as determined by the subclass. See the notes for this property in each subclass for more specific information.

- (GLuint) typeStorageElementCount
readnonatomicassign

Returns the number of memory storage elements consumed by each instance of this variable.

The value returned is dependent on the type property:

  • scalar types consume 1 storage element per instance
  • vector types consume 2, 3 or 4 storage elements per instance
  • matrix types consume 4, 9 or 16 storage elements per instance

If this variable represents an array (the size property returns a value greater than one), the value returned by this property indicates the number of storage elements required for a single component of the array. By contrast, the storageElementCount property returns the total number of storage elements required for the entire array.


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