# Class CgShaderProgram

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

public class CgShaderProgram extends ShaderProgram
The CgShaderProgram object is a concrete implementation of a ShaderProgram node component for NVIDIA's Cg shader language.

Since:
  Java 3D 1.4
See Also:
  - `SourceCodeShader`

## Field Summary

### Fields inherited from class ShaderProgram

`ALLOW_NAMES_READ, ALLOW_SHADERS_READ`

## Constructor Summary

Constructors
Constructor
Description
`CgShaderProgram()`
Constructs a Cg shader program node component.

## Method Summary

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

### Methods inherited from class NodeComponent

`cloneNodeComponent, cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree`

### Methods inherited from class SceneGraphObject

`clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### CgShaderProgram

public CgShaderProgram()
Constructs a Cg shader program node component.
TODO: ADD MORE DOCUMENTATION HERE.

## Method Details

### setVertexAttrNames

public void setVertexAttrNames(String[] vertexAttrNames)
Description copied from class: `ShaderProgram`
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.

Specified by:
  `setVertexAttrNames` in class `ShaderProgram`
Parameters:
  `vertexAttrNames` - array of vertex attribute names for this shader program. A copy of this array is made.

### getVertexAttrNames

public String[] getVertexAttrNames()
Description copied from class: `ShaderProgram`
Retrieves the vertex attribute names array from this ShaderProgram object.

Specified by:
  `getVertexAttrNames` in class `ShaderProgram`
Returns:
  a copy of this ShaderProgram's array of vertex attribute names.

### setShaderAttrNames

public void setShaderAttrNames(String[] shaderAttrNames)
Description copied from class: `ShaderProgram`
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.

Specified by:
  `setShaderAttrNames` in class `ShaderProgram`
Parameters:
  `shaderAttrNames` - array of shader attribute names for this shader program. A copy of this array is made.

### getShaderAttrNames

public String[] getShaderAttrNames()
Description copied from class: `ShaderProgram`
Retrieves the shader attribute names array from this ShaderProgram object.

Specified by:
  `getShaderAttrNames` in class `ShaderProgram`
Returns:
  a copy of this ShaderProgram's array of shader attribute names.

### setShaders

public 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 be `SHADING_LANGUAGE_CG`. Each shader in the array must be a SourceCodeShader. There must be no more than one vertex shader and one fragment shader in the array.

Specified by:
  `setShaders` in class `ShaderProgram`
Parameters:
  `shaders` - array of Shader objects to be copied into this ShaderProgram
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
  `IllegalArgumentException` - if the shading language of any shader in the shaders array is not `SHADING_LANGUAGE_CG`.
  `IllegalArgumentException` - if there are more than one vertex shader or more than one fragment shader in the shaders array.
  `ClassCastException` - if any shader in the shaders array is not a SourceCodeShader.

### getShaders

public Shader[] getShaders()
Description copied from class: `ShaderProgram`
Retrieves the array of shaders from this shader program. A shallow copy of the array is returned. The return value may be null.

Specified by:
  `getShaders` in class `ShaderProgram`
Returns:
  a copy of this ShaderProgram's array of Shader objects