Package com.ardor3d.renderer.state
Class GLSLShaderObjectsState
java.lang.Object
com.ardor3d.renderer.state.RenderState
com.ardor3d.renderer.state.GLSLShaderObjectsState
- All Implemented Interfaces:
Savable
Implementation of the GL_ARB_shader_objects extension.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ardor3d.renderer.state.RenderState
RenderState.StateStack, RenderState.StateType
-
Field Summary
Modifier and TypeFieldDescriptionprotected ByteBuffer
int
OpenGL id for the attached compute shader.optional name for our compute shader, used for debugging details.int
OpenGL id for the attached fragment shader.optional name for our fragment shader, used for debugging details.protected ByteBuffer
int
OpenGL id for the attached geometry shader.optional name for our geometry shader, used for debugging details.protected ByteBuffer
The Mesh this shader currently operates on during renderingboolean
int
OpenGL id for this programprotected List
<ShaderVariable> Storage for shader attribute valuesOptional logic for setting shadervariables based on the current geom.protected List
<ShaderVariable> Storage for shader uniform valuesprotected ByteBuffer
int
OpenGL id for the attached tessellation control shader.optional name for our tessellation control shader, used for debugging details.int
OpenGL id for the attached tessellation evaluation shader.optional name for our tessellation evaluation shader, used for debugging details.protected ByteBuffer
int
OpenGL id for the attached vertex shader.optional name for our vertex shader, used for debugging details.protected ByteBuffer
Fields inherited from class com.ardor3d.renderer.state.RenderState
_quickCompare
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Check if we are keeping the size limits in terms of attribute locations on the card.void
clearAttributes
clears all attribute values from this state.void
clearUniforms
clears all uniform values from this state.getAttributeByName
(String attributeName) Retrieves a shader attribute by name.Gets the currently loaded compute shader.Gets the currently loaded fragment shader.Gets the currently loaded geometry shader.Gets all shader attribute variables.Gets all shader uniforms variables.Gets the currently loaded tessellation control shader.Gets the currently loaded tessellation evaluation shader.getType()
getUniformByName
(String uniformName) Retrieves a shader uniform by name.Gets the currently loaded vertex shader.boolean
protected ByteBuffer
load
(InputStream in) void
read
(InputCapsule capsule) void
setAttributePointer
(String name, int size, boolean normalized, boolean unsigned, int stride, ByteBufferData data) Set an attribute pointer value for this shader object.void
setAttributePointer
(String name, int size, boolean normalized, boolean unsigned, int stride, IntBufferData data) Set an attribute pointer value for this shader object.void
setAttributePointer
(String name, int size, boolean normalized, boolean unsigned, int stride, ShortBufferData data) Set an attribute pointer value for this shader object.void
setAttributePointer
(String name, int size, boolean normalized, int stride, FloatBufferData data) Set an attribute pointer value for this shader object.void
setAttributePointerMatrix
(String name, int size, boolean normalized, FloatBufferData data) Set an attribute pointer value for this shader object.void
setComputeShader
(InputStream stream) void
setComputeShader
(InputStream stream, String name) void
setComputeShader
(String shader) Set the contents for our compute shadervoid
setComputeShader
(String shader, String name) Set the contents for our compute shadervoid
setComputeShader
(ByteBuffer shader) Set the contents for our compute shadervoid
setComputeShader
(ByteBuffer shader, String name) Set the contents for our compute shadervoid
setFragmentShader
(InputStream stream) void
setFragmentShader
(InputStream stream, String name) void
setFragmentShader
(String shader) Set the contents for our fragment shadervoid
setFragmentShader
(String shader, String name) Set the contents for our fragment shadervoid
setFragmentShader
(ByteBuffer shader) Set the contents for our fragment shadervoid
setFragmentShader
(ByteBuffer shader, String name) Set the contents for our fragment shadervoid
setGeometryShader
(InputStream stream) void
setGeometryShader
(InputStream stream, String name) void
setGeometryShader
(String shader) Set the contents for our geometry shadervoid
setGeometryShader
(String shader, String name) Set the contents for our geometry shadervoid
setGeometryShader
(ByteBuffer shader) Set the contents for our geometry shadervoid
setGeometryShader
(ByteBuffer shader, String name) Set the contents for our geometry shadervoid
void
setShaderDataLogic
(GLSLShaderDataLogic shaderDataLogic) Logic to handle setting mesh-specific data to a shader before renderingvoid
void
setTessellationControlShader
(InputStream stream, String name) void
setTessellationControlShader
(String shader) Set the contents for our tessellation control shadervoid
setTessellationControlShader
(String shader, String name) Set the contents for our tessellation control shadervoid
Set the contents for our tessellation control shadervoid
setTessellationControlShader
(ByteBuffer shader, String name) Set the contents for our tessellation control shadervoid
void
setTessellationEvaluationShader
(InputStream stream, String name) void
Set the contents for our tessellation evaluation shadervoid
setTessellationEvaluationShader
(String shader, String name) Set the contents for our tessellation evaluation shadervoid
Set the contents for our tessellation evaluation shadervoid
setTessellationEvaluationShader
(ByteBuffer shader, String name) Set the contents for our tessellation evaluation shadervoid
setUniform
(String name, boolean value) Set an uniform value for this shader object.void
setUniform
(String name, boolean value1, boolean value2) Set an uniform value for this shader object.void
setUniform
(String name, boolean value1, boolean value2, boolean value3) Set an uniform value for this shader object.void
setUniform
(String name, boolean value1, boolean value2, boolean value3, boolean value4) Set an uniform value for this shader object.void
setUniform
(String name, float value) Set an uniform value for this shader object.void
setUniform
(String name, float[] value) Set an uniform value for this shader object.void
setUniform
(String name, float value1, float value2) Set an uniform value for this shader object.void
setUniform
(String name, float value1, float value2, float value3) Set an uniform value for this shader object.void
setUniform
(String name, float value1, float value2, float value3, float value4) Set an uniform value for this shader object.void
setUniform
(String name, int value) Set an uniform value for this shader object.void
setUniform
(String name, int[] value) Set an uniform value for this shader object.void
setUniform
(String name, int value1, int value2) Set an uniform value for this shader object.void
setUniform
(String name, int value1, int value2, int value3) Set an uniform value for this shader object.void
setUniform
(String name, int value1, int value2, int value3, int value4) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyColorRGBA value) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyMatrix3 value, boolean rowMajor) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyMatrix4[] values, boolean rowMajor) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyMatrix4 value, boolean rowMajor) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyQuaternion value) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyVector2 value) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyVector3 value) Set an uniform value for this shader object.void
setUniform
(String name, ReadOnlyVector4 value) Set an uniform value for this shader object.void
setUniform
(String name, FloatBuffer value, int size) Set an uniform value for this shader object.void
setUniform
(String name, IntBuffer value) Set an uniform value for this shader object.void
setUniformMatrix4
(String name, FloatBuffer value) Set an uniform value for this shader object.void
setUseAttributeVBO
(boolean useAttributeVBO) void
setVertexShader
(InputStream stream) void
setVertexShader
(InputStream stream, String name) void
setVertexShader
(String shader) Set the contents for our vertex shadervoid
setVertexShader
(String shader, String name) Set the contents for our vertex shadervoid
setVertexShader
(ByteBuffer shader) Set the contents for our vertex shadervoid
setVertexShader
(ByteBuffer shader, String name) Set the contents for our vertex shadervoid
write
(OutputCapsule capsule) Methods inherited from class com.ardor3d.renderer.state.RenderState
createState, extract, getClassTag, isEnabled, needsRefresh, setEnabled, setNeedsRefresh, setQuickCompares
-
Field Details
-
_shaderUniforms
Storage for shader uniform values -
_shaderAttributes
Storage for shader attribute values -
_vertShader
-
_fragShader
-
_geomShader
-
_tessControlShader
-
_tessEvalShader
-
_compShader
-
_shaderDataLogic
Optional logic for setting shadervariables based on the current geom. Note: If this object does not implement Savable, it will be ignored during write. -
_mesh
The Mesh this shader currently operates on during rendering -
_needSendShader
public boolean _needSendShader -
_programID
public int _programIDOpenGL id for this program. * -
_vertexShaderID
public int _vertexShaderIDOpenGL id for the attached vertex shader. -
_fragmentShaderID
public int _fragmentShaderIDOpenGL id for the attached fragment shader. -
_geometryShaderID
public int _geometryShaderIDOpenGL id for the attached geometry shader. -
_tessellationControlShaderID
public int _tessellationControlShaderIDOpenGL id for the attached tessellation control shader. -
_tessellationEvaluationShaderID
public int _tessellationEvaluationShaderIDOpenGL id for the attached tessellation evaluation shader. -
_computeShaderID
public int _computeShaderIDOpenGL id for the attached compute shader. -
_vertexShaderName
optional name for our vertex shader, used for debugging details. -
_fragmentShaderName
optional name for our fragment shader, used for debugging details. -
_geometryShaderName
optional name for our geometry shader, used for debugging details. -
_tessellationControlShaderName
optional name for our tessellation control shader, used for debugging details. -
_tessellationEvaluationShaderName
optional name for our tessellation evaluation shader, used for debugging details. -
_computeShaderName
optional name for our compute shader, used for debugging details.
-
-
Constructor Details
-
GLSLShaderObjectsState
public GLSLShaderObjectsState()
-
-
Method Details
-
getVertexShader
Gets the currently loaded vertex shader.- Returns:
- the currently loaded vertex shader
-
getFragmentShader
Gets the currently loaded fragment shader.- Returns:
- the currently loaded fragment shader
-
getGeometryShader
Gets the currently loaded geometry shader.- Returns:
- the currently loaded geometry shader
-
getTessellationControlShader
Gets the currently loaded tessellation control shader.- Returns:
- the currently loaded tessellation control shader
-
getTessellationEvaluationShader
Gets the currently loaded tessellation evaluation shader.- Returns:
- the currently loaded tessellation evaluation shader
-
getComputeShader
Gets the currently loaded compute shader.- Returns:
- the currently loaded compute shader
-
setVertexShader
- Throws:
IOException
-
setVertexShader
- Throws:
IOException
-
setFragmentShader
- Throws:
IOException
-
setFragmentShader
- Throws:
IOException
-
setGeometryShader
- Throws:
IOException
-
setGeometryShader
- Throws:
IOException
-
setTessellationControlShader
- Throws:
IOException
-
setTessellationControlShader
- Throws:
IOException
-
setTessellationEvaluationShader
- Throws:
IOException
-
setTessellationEvaluationShader
- Throws:
IOException
-
setComputeShader
- Throws:
IOException
-
setComputeShader
- Throws:
IOException
-
load
- Throws:
IOException
-
setVertexShader
Set the contents for our vertex shader- Parameters:
shader
- the shader contents.
-
setVertexShader
Set the contents for our vertex shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setFragmentShader
Set the contents for our fragment shader- Parameters:
shader
- the shader contents.
-
setFragmentShader
Set the contents for our fragment shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setGeometryShader
Set the contents for our geometry shader- Parameters:
shader
- the shader contents.
-
setGeometryShader
Set the contents for our geometry shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setTessellationControlShader
Set the contents for our tessellation control shader- Parameters:
shader
- the shader contents.
-
setTessellationControlShader
Set the contents for our tessellation control shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setTessellationEvaluationShader
Set the contents for our tessellation evaluation shader- Parameters:
shader
- the shader contents.
-
setTessellationEvaluationShader
Set the contents for our tessellation evaluation shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setComputeShader
Set the contents for our compute shader- Parameters:
shader
- the shader contents.
-
setComputeShader
Set the contents for our compute shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setVertexShader
Set the contents for our vertex shader- Parameters:
shader
- the shader contents.
-
setVertexShader
Set the contents for our vertex shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setFragmentShader
Set the contents for our fragment shader- Parameters:
shader
- the shader contents.
-
setFragmentShader
Set the contents for our fragment shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setGeometryShader
Set the contents for our geometry shader- Parameters:
shader
- the shader contents.
-
setGeometryShader
Set the contents for our geometry shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setTessellationControlShader
Set the contents for our tessellation control shader- Parameters:
shader
- the shader contents.
-
setTessellationControlShader
Set the contents for our tessellation control shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setTessellationEvaluationShader
Set the contents for our tessellation evaluation shader- Parameters:
shader
- the shader contents.
-
setTessellationEvaluationShader
Set the contents for our tessellation evaluation shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
setComputeShader
Set the contents for our compute shader- Parameters:
shader
- the shader contents.
-
setComputeShader
Set the contents for our compute shader- Parameters:
shader
- the shader contents.name
- a label for this shader, displayer upon shader errors.
-
getShaderUniforms
Gets all shader uniforms variables.- Returns:
- all shader uniforms variables
-
getUniformByName
Retrieves a shader uniform by name.- Parameters:
uniformName
- the name of the shader uniform- Returns:
- the shader uniform
-
getShaderAttributes
Gets all shader attribute variables.- Returns:
- all shader attribute variables
-
getAttributeByName
Retrieves a shader attribute by name.- Parameters:
attributeName
- the attribute name- Returns:
- the shader attribute
-
setMesh
- Parameters:
mesh
- the mesh
-
setShaderDataLogic
Logic to handle setting mesh-specific data to a shader before rendering- Parameters:
shaderDataLogic
- the mesh-specific data logic
-
getShaderDataLogic
-
isUseAttributeVBO
public boolean isUseAttributeVBO() -
setUseAttributeVBO
public void setUseAttributeVBO(boolean useAttributeVBO) - Parameters:
useAttributeVBO
- if true, and we support VBO, we'll use VBO for shader attributes.
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuevalue4
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuevalue4
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuevalue4
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new float datasize
- the number of components per entry (must be 1, 2, 3, or 4)
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new value
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new valuerowMajor
- true if is this in row major order
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalue
- the new valuerowMajor
- true if is this in row major order
-
setUniformMatrix4
Set an uniform value for this shader object.- Parameters:
name
- uniform Matrix4 variable to changevalue
- the new value, assumed row major
-
setUniform
Set an uniform value for this shader object.- Parameters:
name
- uniform variable to changevalues
- the new valuesrowMajor
- true if is this in row major order
-
clearUniforms
public void clearUniforms()clearUniforms
clears all uniform values from this state. -
setAttributePointer
public void setAttributePointer(String name, int size, boolean normalized, int stride, FloatBufferData data) Set an attribute pointer value for this shader object.- Parameters:
name
- attribute variable to changesize
- Specifies the number of values for each element of the generic vertex attribute array. Must be 1, 2, 3, or 4.normalized
- Specifies whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed.stride
- Specifies the byte offset between consecutive attribute values. If stride is 0 (the initial value), the attribute values are understood to be tightly packed in the array.data
- The actual data to use as attribute pointer
-
setAttributePointerMatrix
public void setAttributePointerMatrix(String name, int size, boolean normalized, FloatBufferData data) Set an attribute pointer value for this shader object.- Parameters:
name
- attribute variable to changesize
- the number of rows and cols in the matrix. Must be 2, 3, or 4.normalized
- Specifies whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed.data
- The actual data to use as attribute pointer
-
setAttributePointer
public void setAttributePointer(String name, int size, boolean normalized, boolean unsigned, int stride, ByteBufferData data) Set an attribute pointer value for this shader object.- Parameters:
name
- attribute variable to changesize
- Specifies the number of values for each element of the generic vertex attribute array. Must be 1, 2, 3, or 4.normalized
- Specifies whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed.unsigned
- Specifies wheter the data is signed or unsignedstride
- Specifies the byte offset between consecutive attribute values. If stride is 0 (the initial value), the attribute values are understood to be tightly packed in the array.data
- The actual data to use as attribute pointer
-
setAttributePointer
public void setAttributePointer(String name, int size, boolean normalized, boolean unsigned, int stride, IntBufferData data) Set an attribute pointer value for this shader object.- Parameters:
name
- attribute variable to changesize
- Specifies the number of values for each element of the generic vertex attribute array. Must be 1, 2, 3, or 4.normalized
- Specifies whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed.unsigned
- Specifies wheter the data is signed or unsignedstride
- Specifies the byte offset between consecutive attribute values. If stride is 0 (the initial value), the attribute values are understood to be tightly packed in the array.data
- The actual data to use as attribute pointer
-
setAttributePointer
public void setAttributePointer(String name, int size, boolean normalized, boolean unsigned, int stride, ShortBufferData data) Set an attribute pointer value for this shader object.- Parameters:
name
- attribute variable to changesize
- Specifies the number of values for each element of the generic vertex attribute array. Must be 1, 2, 3, or 4.normalized
- Specifies whether fixed-point data values should be normalized or converted directly as fixed-point values when they are accessed.unsigned
- Specifies wheter the data is signed or unsignedstride
- Specifies the byte offset between consecutive attribute values. If stride is 0 (the initial value), the attribute values are understood to be tightly packed in the array.data
- The actual data to use as attribute pointer
-
clearAttributes
public void clearAttributes()clearAttributes
clears all attribute values from this state. -
getType
- Specified by:
getType
in classRenderState
- Returns:
- An statetype enum value for the subclass.
- See Also:
-
checkAttributeSizeLimits
public void checkAttributeSizeLimits()Check if we are keeping the size limits in terms of attribute locations on the card. -
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classRenderState
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classRenderState
- Throws:
IOException
-
createStateRecord
- Specified by:
createStateRecord
in classRenderState
-