## javax.media.j3d
Class ShaderAttributeSet

    java.lang.Object
      javax.media.j3d.SceneGraphObject
          javax.media.j3d.NodeComponent
              javax.media.j3d.ShaderAttributeSet

    public class ShaderAttributeSet

extends NodeComponent

The ShaderAttributeSet object provides uniform attributes to shader programs. Uniform attributes (variables) are those attributes whose values are constant during the rendering of a primitive. Their values may change from primitive to primitive, but are constant for each vertex (for vertex shaders) or fragment (for fragment shaders) of a single primitive. Examples of uniform attributes include a transformation matrix, a texture map, lights, lookup tables, etc. The ShaderAttributeSet object contains a set of ShaderAttribute objects. Each ShaderAttribute object defines the value of a single uniform shader variable. The set of attributes is unique with respect to attribute names: no two attributes in the set will have the same name.

There are two ways in which values can be specified for uniform attributes: explicitly, by providing a value; and implicitly, by defining a binding between a Java 3D system attribute and a uniform attribute. This functionality is provided by two subclasses of ShaderAttribute: ShaderAttributeObject, which is used to specify explicitly defined attributes; and ShaderAttributeBinding, which is used to specify implicitly defined, automatically tracked attributes.

Depending on the shading language (and profile) being used, several Java 3D state attributes are automatically made available to the shader program as pre-defined uniform attributes. The application doesn't need to do anything to pass these attributes in to the shader program. The implementation of each shader language (e.g., Cg, GLSL) defines its own bindings from Java 3D attribute to uniform variable name. A list of these attributes for each shader language can be found in the concrete subclass of ShaderProgram for that shader language.

Since:
  Java 3D 1.4
See Also:
  `ShaderAttribute`, `ShaderProgram`, `ShaderAppearance.setShaderAttributeSet(javax.media.j3d.ShaderAttributeSet)`

Field Summary
`static int` `ALLOW_ATTRIBUTES_READ` Specifies that this ShaderAttributeSet object allows reading its attributes.
`static int` `ALLOW_ATTRIBUTES_WRITE` Specifies that this ShaderAttributeSet object allows writing its attributes.

Constructor Summary
`ShaderAttributeSet()` Constructs an empty ShaderAttributeSet object.

Method Summary
`void` `clear()` Removes all shader attributes from the attributes set.
`ShaderAttribute` `get(java.lang.String attrName)` Retrieves the shader attribute with the specified `attrName` from the attributes set.
`ShaderAttribute[]` `getAll()` Returns a shallow copy of the attributes set.
`void` `put(ShaderAttribute attr)` Adds the specified shader attribute to the attributes set.
`void` `remove(ShaderAttribute attr)` Removes the specified shader attribute from the attributes set.
`void` `remove(java.lang.String attrName)` Removes the shader attribute with the specified `attrName` from the attributes set.
`int` `size()` Returns the number of elements in the attributes set.

Methods inherited from class javax.media.j3d.NodeComponent
`cloneNodeComponent, cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree`

Methods inherited from class javax.media.j3d.SceneGraphObject
`clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### ALLOW_ATTRIBUTES_READ

    public static final int ALLOW_ATTRIBUTES_READ

  Specifies that this ShaderAttributeSet object allows reading its attributes.

  See Also:
    Constant Field Values

### ALLOW_ATTRIBUTES_WRITE

    public static final int ALLOW_ATTRIBUTES_WRITE

  Specifies that this ShaderAttributeSet object allows writing its attributes.

  See Also:
    Constant Field Values

Constructor Detail

### ShaderAttributeSet

    public ShaderAttributeSet()

  Constructs an empty ShaderAttributeSet object. The attributes set is initially empty.

Method Detail

### put

    public void put(ShaderAttribute attr)

  Adds the specified shader attribute to the attributes set. The newly specified attribute replaces an attribute with the same name, if one already exists in the attributes set.

  Parameters:
    `attr` - the shader attribute to be added to the set
  Throws:
    `java.lang.NullPointerException` - if attr is null
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### get

    public ShaderAttribute get(java.lang.String attrName)

  Retrieves the shader attribute with the specified `attrName` from the attributes set. If attrName does not exist in the attributes set, null is returned.

  Parameters:
    `attrName` - the name of the shader attribute to be retrieved
  Returns:
    a the shader attribute associated with the specified attribute name, or null if the name is not in the attributes set
  Throws:
    `java.lang.NullPointerException` - if attrName is null
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### remove

    public void remove(java.lang.String attrName)

  Removes the shader attribute with the specified `attrName` from the attributes set. If attrName does not exist in the attributes set then nothing happens.

  Parameters:
    `attrName` - the name of the shader attribute to be removed
  Throws:
    `java.lang.NullPointerException` - if attrName is null
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### remove

    public void remove(ShaderAttribute attr)

  Removes the specified shader attribute from the attributes set. If the attribute does not exist in the attributes set then nothing happens. Note that this method will not remove a shader object other than the one specified, even if it has the same name as the specified attribute. Applications that wish to remove an attribute by name should use `removeAttribute(String)`.

  Parameters:
    `attr` - the shader attribute to be removed
  Throws:
    `java.lang.NullPointerException` - if attr is null
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### clear

    public void clear()

  Removes all shader attributes from the attributes set. The attributes set will be empty following this call.

  Throws:
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### getAll

    public ShaderAttribute[] getAll()

  Returns a shallow copy of the attributes set.

  Returns:
    a shallow copy of the attributes set
  Throws:
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### size

    public int size()

  Returns the number of elements in the attributes set.

  Returns:
    the number of elements in the attributes set
  Throws:
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.