Package 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
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Specifies that this ShaderProgram object allows reading its shader or vertex attribute names.static final int
Specifies that this ShaderProgram object allows reading its shaders. -
Method Summary
Modifier and TypeMethodDescriptionabstract String[]
Retrieves the shader attribute names array from this ShaderProgram object.abstract Shader[]
Retrieves the array of shaders from this shader program.abstract String[]
Retrieves the vertex attribute names array from this ShaderProgram object.abstract void
setShaderAttrNames
(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
(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
-
Field Details
-
ALLOW_SHADERS_READ
public static final int ALLOW_SHADERS_READSpecifies that this ShaderProgram object allows reading its shaders.- See Also:
-
ALLOW_NAMES_READ
public static final int ALLOW_NAMES_READSpecifies that this ShaderProgram object allows reading its shader or vertex attribute names.- See Also:
-
-
Method Details
-
setVertexAttrNames
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.NullPointerException
- if any element in the vertexAttrNames array is null.
-
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
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.NullPointerException
- if any element in the shaderAttrNames array is null.
-
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
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.IllegalArgumentException
- if the shading language of any shader in the shaders array doesn't match the type of the subclass.NullPointerException
- if any element in the shaders array is null.
-
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
-