## javax.media.j3d
Class ShaderProgram

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

Direct Known Subclasses:
  CgShaderProgram, GLSLShaderProgram

    public abstract class ShaderProgram

extends NodeComponent

The ShaderProgram node component object is the abstract base class for programmable shader programs. Each concrete instance of a ShaderProgram is a container for a set of Shader objects. The set of Shaders contained in the ShaderProgram is a complete program for the Graphics Pipeline Unit (GPU) of the graphics accelerator. It is specified using the shader language defined by the ShaderProgram. The currently defined shader languages are: Cg and GLSL.

NOTE: Applications should not extend this class.

Since:
  Java 3D 1.4
See Also:
  `Shader`, `ShaderAppearance.setShaderProgram(javax.media.j3d.ShaderProgram)`

Field Summary
`static int` `ALLOW_NAMES_READ` Specifies that this ShaderProgram object allows reading its shader or vertex attribute names.
`static int` `ALLOW_SHADERS_READ` Specifies that this ShaderProgram object allows reading its shaders.

Method Summary
`abstract java.lang.String[]` `getShaderAttrNames()` Retrieves the shader attribute names array from this ShaderProgram object.
`abstract Shader[]` `getShaders()` Retrieves the array of shaders from this shader program.
`abstract java.lang.String[]` `getVertexAttrNames()` Retrieves the vertex attribute names array from this ShaderProgram object.
`abstract void` `setShaderAttrNames(java.lang.String[] shaderAttrNames)` Sets the shader attribute names array for this ShaderProgram object.
`abstract void` `setShaders(Shader[] shaders)` Copies the specified array of shaders into this shader program.
`abstract void` `setVertexAttrNames(java.lang.String[] vertexAttrNames)` Sets the vertex attribute names array for this ShaderProgram object.

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_SHADERS_READ

    public static final int ALLOW_SHADERS_READ

  Specifies that this ShaderProgram object allows reading its shaders.

  See Also:
    Constant Field Values

### ALLOW_NAMES_READ

    public static final int ALLOW_NAMES_READ

  Specifies that this ShaderProgram object allows reading its shader or vertex attribute names.

  See Also:
    Constant Field Values

Method Detail

### setVertexAttrNames

    public abstract void setVertexAttrNames(java.lang.String[] vertexAttrNames)

  Sets the vertex attribute names array for this ShaderProgram object. Each element in the array specifies the shader attribute name that is bound to the corresponding numbered vertex attribute within a GeometryArray object that uses this shader program. Array element 0 specifies the name of GeometryArray vertex attribute 0, array element 1 specifies the name of GeometryArray vertex attribute 1, and so forth. The array of names may be null or empty (0 length), but the elements of the array must be non-null.

  Parameters:
    `vertexAttrNames` - array of vertex attribute names for this shader program. A copy of this array is made.
  Throws:
    `RestrictedAccessException` - if the method is called when this object is part of live or compiled scene graph.
    `java.lang.NullPointerException` - if any element in the vertexAttrNames array is null.

### getVertexAttrNames

    public abstract java.lang.String[] getVertexAttrNames()

  Retrieves the vertex attribute names array from this ShaderProgram object.

  Returns:
    a copy of this ShaderProgram's array of vertex attribute names.
  Throws:
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### setShaderAttrNames

    public abstract void setShaderAttrNames(java.lang.String[] shaderAttrNames)

  Sets the shader attribute names array for this ShaderProgram object. Each element in the array specifies a shader attribute name that may be set via a ShaderAttribute object. Only those attributes whose names that appear in the shader attribute names array can be set for a given shader program. The array of names may be null or empty (0 length), but the elements of the array must be non-null.

  TODO: finish this.

  Parameters:
    `shaderAttrNames` - array of shader attribute names for this shader program. A copy of this array is made.
  Throws:
    `RestrictedAccessException` - if the method is called when this object is part of live or compiled scene graph.
    `java.lang.NullPointerException` - if any element in the shaderAttrNames array is null.

### getShaderAttrNames

    public abstract java.lang.String[] getShaderAttrNames()

  Retrieves the shader attribute names array from this ShaderProgram object.

  Returns:
    a copy of this ShaderProgram's array of shader attribute names.
  Throws:
    `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### setShaders

    public abstract void setShaders(Shader[] shaders)

  Copies the specified array of shaders into this shader program. This method makes a shallow copy of the array. The array of shaders may be null or empty (0 length), but the elements of the array must be non-null. The shading language of each shader in the array must match the subclass. Subclasses may impose additional restrictions.

  Parameters:
    `shaders` - array of Shader objects to be copied into this ShaderProgram
  Throws:
    `RestrictedAccessException` - if the method is called when this object is part of live or compiled scene graph.
    `java.lang.IllegalArgumentException` - if the shading language of any shader in the shaders array doesn't match the type of the subclass.
    `java.lang.NullPointerException` - if any element in the shaders array is null.

### getShaders

    public abstract Shader[] getShaders()

  Retrieves the array of shaders from this shader program. A shallow copy of the array is returned. The return value may be null.

  Returns:
    a copy of this ShaderProgram's array of Shader objects
  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.