com.jme.scene.state
Class GLSLShaderObjectsState

java.lang.Object
  extended bycom.jme.scene.state.RenderState
      extended bycom.jme.scene.state.GLSLShaderObjectsState
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
LWJGLShaderObjectsState

public abstract class GLSLShaderObjectsState
extends RenderState

Implementation of the GL_ARB_shader_objects extension.

Author:
Thomas Hourdel
See Also:
Serialized Form

Field Summary
 java.util.ArrayList attribs
           
 java.util.ArrayList uniforms
           
 
Fields inherited from class com.jme.scene.state.RenderState
RS_ALPHA, RS_ATTRIBUTE, RS_CULL, RS_DITHER, RS_FOG, RS_FRAGMENT_PROGRAM, RS_GLSL_SHADER_OBJECTS, RS_LIGHT, RS_MATERIAL, RS_MAX_STATE, RS_SHADE, RS_STENCIL, RS_TEXTURE, RS_VERTEX_PROGRAM, RS_WIREFRAME, RS_ZBUFFER
 
Constructor Summary
GLSLShaderObjectsState()
           
 
Method Summary
 void clearAttributes()
          clearAttributes clears all attribute values from this state.
 void clearUniforms()
          clearUniforms clears all uniform values from this state.
 int getType()
          Defined by the subclass, this returns an int identifying the renderstate.
abstract  boolean isSupported()
          isSupported determines if the ARB_shader_objects extension is supported by current graphics configuration.
abstract  void load(java.net.URL vert, java.net.URL frag)
          load loads the shader object from the specified file.
abstract  void relinkProgram()
          relinkProgram instructs openGL to relink the associated program and sets the attributes.
 void setAttribute(java.lang.String var, byte value1, byte value2, byte value3, byte value4)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, float value)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, float value1, float value2)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, float value1, float value2, float value3)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, float value1, float value2, float value3, float value4)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, short value)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, short value1, short value2)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, short value1, short value2, short value3)
          Set an attribute value for this shader object.
 void setAttribute(java.lang.String var, short value1, short value2, short value3, short value4)
          Set an attribute value for this shader object.
 void setAttributePointer(java.lang.String var, int size, boolean normalized, boolean unsigned, int stride, java.nio.ByteBuffer data)
          Set an attribute pointer value for this shader object.
 void setAttributePointer(java.lang.String var, int size, boolean normalized, boolean unsigned, int stride, java.nio.IntBuffer data)
          Set an attribute pointer value for this shader object.
 void setAttributePointer(java.lang.String var, int size, boolean normalized, boolean unsigned, int stride, java.nio.ShortBuffer data)
          Set an attribute pointer value for this shader object.
 void setAttributePointer(java.lang.String var, int size, boolean normalized, int stride, java.nio.FloatBuffer data)
          Set an attribute pointer value for this shader object.
 void setUniform(java.lang.String var, float value)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, float[] value, boolean transpose)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, float value1, float value2)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, float value1, float value2, float value3)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, float value1, float value2, float value3, float value4)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, int value)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, int value1, int value2)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, int value1, int value2, int value3)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, int value1, int value2, int value3, int value4)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, Matrix3f value, boolean transpose)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, Matrix4f value, boolean transpose)
          Set an uniform value for this shader object.
 void setUniform(java.lang.String var, Texture sampler)
          Set an uniform value for the shader object.
 
Methods inherited from class com.jme.scene.state.RenderState
apply, extract, isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uniforms

public java.util.ArrayList uniforms

attribs

public java.util.ArrayList attribs
Constructor Detail

GLSLShaderObjectsState

public GLSLShaderObjectsState()
Method Detail

isSupported

public abstract boolean isSupported()
isSupported determines if the ARB_shader_objects extension is supported by current graphics configuration.

Returns:
if ARB shader objects are supported

relinkProgram

public abstract void relinkProgram()
relinkProgram instructs openGL to relink the associated program and sets the attributes. This should be used after setting ShaderAttributes.


setUniform

public void setUniform(java.lang.String var,
                       int value)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value - the new value

setUniform

public void setUniform(java.lang.String var,
                       float value)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value - the new value

setUniform

public void setUniform(java.lang.String var,
                       int value1,
                       int value2)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value1 - the new value
value2 - the new value

setUniform

public void setUniform(java.lang.String var,
                       float value1,
                       float value2)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value1 - the new value
value2 - the new value

setUniform

public void setUniform(java.lang.String var,
                       int value1,
                       int value2,
                       int value3)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value1 - the new value
value2 - the new value
value3 - the new value

setUniform

public void setUniform(java.lang.String var,
                       float value1,
                       float value2,
                       float value3)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value1 - the new value
value2 - the new value
value3 - the new value

setUniform

public void setUniform(java.lang.String var,
                       int value1,
                       int value2,
                       int value3,
                       int value4)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value1 - the new value
value2 - the new value
value3 - the new value
value4 - the new value

setUniform

public void setUniform(java.lang.String var,
                       float value1,
                       float value2,
                       float value3,
                       float value4)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value1 - the new value
value2 - the new value
value3 - the new value
value4 - the new value

setUniform

public void setUniform(java.lang.String var,
                       float[] value,
                       boolean transpose)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value - the new value (a float buffer of size 4)
transpose - transpose the matrix ?

setUniform

public void setUniform(java.lang.String var,
                       Matrix3f value,
                       boolean transpose)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value - the new value
transpose - transpose the matrix ?

setUniform

public void setUniform(java.lang.String var,
                       Matrix4f value,
                       boolean transpose)
Set an uniform value for this shader object.

Parameters:
var - uniform variable to change
value - the new value
transpose - transpose the matrix ?

setUniform

public void setUniform(java.lang.String var,
                       Texture sampler)
Set an uniform value for the shader object.

Parameters:
var - uniform variable to change
sampler - the new value

clearUniforms

public void clearUniforms()
clearUniforms clears all uniform values from this state.


setAttribute

public void setAttribute(java.lang.String var,
                         short value)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         float value)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         short value1,
                         short value2)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value1 - the new value
value2 - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         float value1,
                         float value2)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value1 - the new value
value2 - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         short value1,
                         short value2,
                         short value3)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value1 - the new value
value2 - the new value
value3 - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         float value1,
                         float value2,
                         float value3)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value1 - the new value
value2 - the new value
value3 - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         short value1,
                         short value2,
                         short value3,
                         short value4)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value1 - the new value
value2 - the new value
value3 - the new value
value4 - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         float value1,
                         float value2,
                         float value3,
                         float value4)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value1 - the new value
value2 - the new value
value3 - the new value
value4 - the new value

setAttribute

public void setAttribute(java.lang.String var,
                         byte value1,
                         byte value2,
                         byte value3,
                         byte value4)
Set an attribute value for this shader object.

Parameters:
var - attribute variable to change
value1 - the new value
value2 - the new value
value3 - the new value
value4 - the new value

setAttributePointer

public void setAttributePointer(java.lang.String var,
                                int size,
                                boolean normalized,
                                int stride,
                                java.nio.FloatBuffer data)
Set an attribute pointer value for this shader object.

Parameters:
var - attribute variable to change

setAttributePointer

public void setAttributePointer(java.lang.String var,
                                int size,
                                boolean normalized,
                                boolean unsigned,
                                int stride,
                                java.nio.ByteBuffer data)
Set an attribute pointer value for this shader object.

Parameters:
var - attribute variable to change

setAttributePointer

public void setAttributePointer(java.lang.String var,
                                int size,
                                boolean normalized,
                                boolean unsigned,
                                int stride,
                                java.nio.IntBuffer data)
Set an attribute pointer value for this shader object.

Parameters:
var - attribute variable to change

setAttributePointer

public void setAttributePointer(java.lang.String var,
                                int size,
                                boolean normalized,
                                boolean unsigned,
                                int stride,
                                java.nio.ShortBuffer data)
Set an attribute pointer value for this shader object.

Parameters:
var - attribute variable to change

clearAttributes

public void clearAttributes()
clearAttributes clears all attribute values from this state.


getType

public int getType()
Description copied from class: RenderState
Defined by the subclass, this returns an int identifying the renderstate. For example, RS_CULL or RS_TEXTURE.

Specified by:
getType in class RenderState
Returns:
RS_SHADER_OBJECTS
See Also:
RenderState.getType()

load

public abstract void load(java.net.URL vert,
                          java.net.URL frag)
load loads the shader object from the specified file. The program must be in ASCII format. We delegate the loading to each implementation because we do not know in what format the underlying API wants the data.

Parameters:
vert - text file containing the vertex shader object
frag - text file containing the fragment shader object