|
Aviatrix3D 2.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.aviatrix3d.SceneGraphObject org.j3d.aviatrix3d.NodeComponent org.j3d.aviatrix3d.ShaderArguments
public class ShaderArguments
Representation of a set of arguments (uniform variables) that can be passed to a shader program.
Arguments are separate from the program so that the same program can be used amongst a number of primitives, but with different setup information if needed.
If changing the value of an existing argument, no consistency checks are made on whether the old type and new type match.
The external data passed to the ComponentRenderable calls shall be an
Integer
instance that represents the GL program identifier
generated for the shader program this instance is working with.
Internationalisation Resource Names
Field Summary | |
---|---|
static int |
FLOAT_UNIFORM_TYPE
The uniform data type is a float array |
static int |
INT_UNIFORM_TYPE
The uniform data type is an int array |
static int |
MATRIX_UNIFORM_TYPE
The uniform data type is a matrix array |
static int |
SAMPLER_UNIFORM_TYPE
The uniform data type is an int array |
Fields inherited from class org.j3d.aviatrix3d.NodeComponent |
---|
lastParent, liveCount, parentList |
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler |
Constructor Summary | |
---|---|
ShaderArguments()
Constructs a Shader with default values. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
Compares this object with the specified object for order. |
int |
compareTo(ShaderArguments sh)
Compares this object with the specified object for order. |
boolean |
equals(java.lang.Object o)
Compare this object for equality to the given object. |
boolean |
equals(ShaderArguments sh)
Compares this object with the specified object to check for equivalence. |
void |
getUniform(java.lang.String name,
float[] data)
Get the value of a uniform using a float array. |
void |
getUniform(java.lang.String name,
int[] data)
Get the value of a uniform using an int array. |
int |
getUniformCount(java.lang.String name)
Get the number of items declared for a uniform value. |
int |
getUniformSize(java.lang.String name)
Get the data vector size for the given uniform name. |
int |
getUniformType(java.lang.String name)
Get the data type of this uniform. |
void |
postRender(javax.media.opengl.GL gl,
java.lang.Object programId)
|
void |
removeUniform(java.lang.String name)
Remove the given uniform name from the settable argument list. |
void |
render(javax.media.opengl.GL gl,
java.lang.Object programId)
Assign the uniform values to the shader now. |
void |
setUniform(java.lang.String name,
int size,
float[] data,
int count)
Set the value of an float array uniform variable. |
void |
setUniform(java.lang.String name,
int size,
int[] data,
int count)
Set the value of an int array uniform variable. |
void |
setUniformMatrix(java.lang.String name,
int size,
float[] data,
int count,
boolean columnMajor)
Set the value of an matrix uniform variable. |
void |
setUniformSampler(java.lang.String name,
int textureUnitId)
Convenience method to set the uniform name as a sampler for the given texture unit number. |
Methods inherited from class org.j3d.aviatrix3d.NodeComponent |
---|
addParent, getParents, numParents, removeParent |
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INT_UNIFORM_TYPE
public static final int FLOAT_UNIFORM_TYPE
public static final int MATRIX_UNIFORM_TYPE
public static final int SAMPLER_UNIFORM_TYPE
Constructor Detail |
---|
public ShaderArguments()
Method Detail |
---|
public void render(javax.media.opengl.GL gl, java.lang.Object programId)
render
in interface ComponentRenderable
gl
- The GL context to write the values throughprogramId
- the ID of the program to make GL calls withpublic void postRender(javax.media.opengl.GL gl, java.lang.Object programId)
postRender
in interface ComponentRenderable
public int compareTo(java.lang.Object o) throws java.lang.ClassCastException
compareTo
in interface java.lang.Comparable
o
- The objec to be compared
java.lang.ClassCastException
- The specified object's type prevents it from
being compared to this Objectpublic boolean equals(java.lang.Object o)
equals
in interface Renderable
equals
in class java.lang.Object
o
- The object to be compared
public void setUniform(java.lang.String name, int size, float[] data, int count) throws InvalidWriteTimingException
name
- The name of the uniform to be setsize
- A value of 1, 2, 3 or 4 depending on how many itemsdata
- The value(s) to be setcount
- The number of the values to set
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data changed callback methodpublic void setUniform(java.lang.String name, int size, int[] data, int count) throws InvalidWriteTimingException
name
- The name of the uniform to be setsize
- A value of 1, 2, 3 or 4 depending on how many itemsdata
- The value(s) to be setcount
- The number of the values to set
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data changed callback methodpublic void setUniformMatrix(java.lang.String name, int size, float[] data, int count, boolean columnMajor) throws InvalidWriteTimingException
name
- The name of the uniform to be setsize
- A value of 2, 3 or 4 depending on the matrix size (eg 2x2)data
- The value(s) to be setcount
- The number of the values to set
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data changed callback methodpublic void setUniformSampler(java.lang.String name, int textureUnitId) throws InvalidWriteTimingException
name
- The name of the uniform to be settextureUnitId
- The ID of the texture unit to assign to the sampler
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data changed callback methodpublic int getUniformType(java.lang.String name)
If the uniform name provided has not been set yet, this will return -1.
name
- The name of the uniform to fetch the size of
public int getUniformSize(java.lang.String name)
size
parameter, this will return the value set
there. If the uniform name is used on a sampler (texture ID), this will
always return 1. If the uniform represents a matrix type, then this still
return 2, 3 or 4. Use the getUniformType(String)
method to
determine the underlying data type this represents.
If the uniform name provided has not been set yet, this will return -1.
name
- The name of the uniform to fetch the size of
public int getUniformCount(java.lang.String name)
name
- The name of the uniform to be set
public void getUniform(java.lang.String name, float[] data) throws InvalidDataTypeException
getUniformType(String)
.
The provided array must be big enough to contain all of the data. The length of the array must at least be:
int size = getUniformSize(name) * getUniformCount(name) *
(getUniformType(name) == MATRIX_UNIFORM_TYPE ? getUniformSize(name) : 1);
If the uniform name is not known, nothing happens.
name
- The name of the uniform to be setdata
- An array to copy values to
InvalidDataTypeException
- Attempt to fetch an int type
java.lang.ArrayIndexOutOfBoundsException
- The provided array is too shortpublic void getUniform(java.lang.String name, int[] data) throws InvalidDataTypeException
getUniformType(String)
.
The provided array must be big enough to contain all of the data. The length of the array must at least be:
int size = getUniformSize(name) * getUniformCount(name);
If the uniform name is not known, nothing happens.
name
- The name of the uniform to be setdata
- An array to copy values to
InvalidDataTypeException
- Attempt to fetch an int type
java.lang.ArrayIndexOutOfBoundsException
- The provided array is too shortpublic void removeUniform(java.lang.String name) throws InvalidWriteTimingException
name
- The name of the uniform variable to be removed.
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data changed callback methodpublic int compareTo(ShaderArguments sh)
sh
- The argument instance to be compared
public boolean equals(ShaderArguments sh)
sh
- The shader instance to be compared
|
Aviatrix3D 2.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |