j3d.org Aviatrix3D

org.j3d.aviatrix3d
Class VertexShader

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.NodeComponent
          extended byorg.j3d.aviatrix3d.ShaderProgram
              extended byorg.j3d.aviatrix3d.VertexShader

public class VertexShader
extends ShaderProgram

Node that handles Vertex shader implementation

The implementation is relatively simple using just a bind program call followed by the parameter setting. If the application needs greater control than this, such as multi-pass rendering, then derive this class and change the render-loop code to do what is required.

Parameters follow the OpenGL model. There are 96 evironment parameters and 96 local parameters. Both can be set through this class, though this may change in a future design revision, to make environment parameters into a global setting.

Though OpenGL can take the attributes as doubles, this is not supported by this API currently.

Version:
$Revision: 1.8 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.ShaderProgram
programChanged, programId, programString
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
liveCount
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, updateHandler, WRITE_TIMING_MSG
 
Constructor Summary
VertexShader()
          Constructs a Vertex shader with default values.
VertexShader(int attrListSize, int paramListSize)
          Create a vertext shader instance with a guaranteed maximum parameter list size.
 
Method Summary
 void renderState(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Set up the rendering state now.
 void restoreState(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Restore all openGL state.
 void setEnvironmentParam(int idx, float[] value)
          Set the environment parameter as a float array.
 void setLocalParam(int idx, float[] value)
          Set the local parameter as a float array.
 void setVertexAttribute(int idx, float[] value)
          Set the vertex attribute as a float array.
 
Methods inherited from class org.j3d.aviatrix3d.ShaderProgram
getProgramString, setProgramString
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, hasChanged, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VertexShader

public VertexShader()
Constructs a Vertex shader with default values. The internal arrays for vertex attributes will be 16 and environment and local parameters to 96.


VertexShader

public VertexShader(int attrListSize,
                    int paramListSize)
             throws InvalidWriteTimingException
Create a vertext shader instance with a guaranteed maximum parameter list size. If an attempt is made to read/set past this, an exception will generated. This ID is the maximum parameter index that will be used and the maxium number actually used.

Parameters:
paramListSize - The maximum number of environment and local parameters that will be used.
attrListSize - The maximum number of vertex attributes that will be used
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method
Method Detail

setEnvironmentParam

public void setEnvironmentParam(int idx,
                                float[] value)
                         throws InvalidWriteTimingException
Set the environment parameter as a float array.

Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

setLocalParam

public void setLocalParam(int idx,
                          float[] value)
                   throws InvalidWriteTimingException
Set the local parameter as a float array.

Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

setVertexAttribute

public void setVertexAttribute(int idx,
                               float[] value)
                        throws InvalidWriteTimingException
Set the vertex attribute as a float array.

Throws:
InvalidWriteTimingException

renderState

public void renderState(net.java.games.jogl.GL gl,
                        net.java.games.jogl.GLU glu)
Set up the rendering state now.

Overrides:
renderState in class NodeComponent
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

restoreState

public void restoreState(net.java.games.jogl.GL gl,
                         net.java.games.jogl.GLU glu)
Description copied from class: NodeComponent
Restore all openGL state.

Overrides:
restoreState in class NodeComponent
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

j3d.org Aviatrix3D

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - j3d.org