|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme.scene.state.RenderState
com.jme.scene.state.GLSLShaderObjectsState
public abstract class GLSLShaderObjectsState
Implementation of the GL_ARB_shader_objects extension.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.jme.scene.state.RenderState |
---|
RenderState.StateType |
Field Summary | |
---|---|
protected java.lang.String |
fragShader
|
protected Geometry |
geom
The Geometry this shader currently operates on during rendering |
protected static boolean |
glslSupported
|
protected static boolean |
glslSupportedDetected
|
protected boolean |
needSendShader
|
protected java.util.HashMap<java.lang.String,ShaderVariable> |
shaderAttributes
Storage for shader attribute values |
protected GLSLShaderDataLogic |
shaderDataLogic
Optional logic for setting shadervariables based on the current geom |
protected java.util.HashMap<java.lang.String,ShaderVariable> |
shaderUniforms
Storage for shader uniform values |
protected java.lang.String |
vertShader
|
Fields inherited from class com.jme.scene.state.RenderState |
---|
QUICK_COMPARE, RS_BLEND, RS_CLIP, RS_COLORMASK_STATE, RS_CULL, 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 |
checkAttributeSizeLimits()
Check if we are keeping the size limits in terms of attribute locations on the card. |
void |
checkUniformSizeLimits()
Check if we are keeping the size limits in terms of uniform locations on the card. |
abstract void |
cleanup()
Frees the memory and invalidates the shader handle |
void |
clearAttributes()
clearAttributes clears all attribute values from this
state. |
void |
clearUniforms()
clearUniforms clears all uniform values from this state. |
ShaderVariable |
getAttributeByName(java.lang.String attributeName)
Retrieves a shader attribute by name. |
java.lang.Class<? extends GLSLShaderObjectsState> |
getClassTag()
|
java.lang.String |
getFragmentShader()
Gets the currently loaded fragment shader. |
java.util.Collection<ShaderVariable> |
getShaderAttributes()
Gets all shader attribute variables. |
java.util.Collection<ShaderVariable> |
getShaderUniforms()
Gets all shader uniforms variables. |
RenderState.StateType |
getStateType()
getStateType returns the type RenderState.StateType.GLSLShaderObjects |
int |
getType()
Deprecated. As of 2.0, use RenderState.getStateType() instead. |
ShaderVariable |
getUniformByName(java.lang.String uniformName)
Retrieves a shader uniform by name. |
java.lang.String |
getVertexShader()
Gets the currently loaded vertex shader. |
static boolean |
isSupported()
isSupported determines if the ARB_shader_objects extension
is supported by current graphics configuration. |
protected java.nio.ByteBuffer |
load(java.io.InputStream in)
Load an URL and grab content into a ByteBuffer. |
void |
load(java.io.InputStream vert,
java.io.InputStream frag)
load loads the shader object from the specified file. |
void |
load(java.lang.String vert,
java.lang.String frag)
load loads the shader object from the specified string. |
void |
load(java.net.URL vert,
java.net.URL frag)
load loads the shader object from the specified file. |
static void |
overrideSupport(boolean use)
Overide setting of glsl support. |
void |
read(JMEImporter e)
|
static void |
resetSupport()
Reset glsl support to driver-detected setting. |
protected abstract void |
sendToGL(java.nio.ByteBuffer vertexByteBuffer,
java.nio.ByteBuffer fragmentByteBuffer)
Loads the shader object. |
void |
setAttributePointer(java.lang.String name,
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 name,
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 name,
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 name,
int size,
boolean normalized,
int stride,
java.nio.FloatBuffer data)
Set an attribute pointer value for this shader object. |
void |
setGeometry(Geometry geom)
|
void |
setShaderDataLogic(GLSLShaderDataLogic shaderDataLogic)
Logic to handle setting geom-specific data to a shader before rendering |
void |
setUniform(java.lang.String name,
boolean value)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
boolean value1,
boolean value2)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
boolean value1,
boolean value2,
boolean value3)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
boolean value1,
boolean value2,
boolean value3,
boolean value4)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
ColorRGBA value)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
float value)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
float[] value,
boolean rowMajor)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
float value1,
float value2)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
float value1,
float value2,
float value3)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
float value1,
float value2,
float value3,
float value4)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
int value)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
int value1,
int value2)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
int value1,
int value2,
int value3)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
int value1,
int value2,
int value3,
int value4)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
Matrix3f value,
boolean rowMajor)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
Matrix4f[] values,
boolean rowMajor)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
Matrix4f value,
boolean rowMajor)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
Quaternion value)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
Vector2f value)
Set an uniform value for this shader object. |
void |
setUniform(java.lang.String name,
Vector3f value)
Set an uniform value for this shader object. |
void |
write(JMEExporter e)
|
Methods inherited from class com.jme.scene.state.RenderState |
---|
apply, createStateRecord, extract, isEnabled, needsRefresh, setEnabled, setNeedsRefresh, setQuickCompares |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.HashMap<java.lang.String,ShaderVariable> shaderUniforms
protected java.util.HashMap<java.lang.String,ShaderVariable> shaderAttributes
protected GLSLShaderDataLogic shaderDataLogic
protected Geometry geom
protected static boolean glslSupported
protected static boolean glslSupportedDetected
protected boolean needSendShader
protected java.lang.String vertShader
protected java.lang.String fragShader
Constructor Detail |
---|
public GLSLShaderObjectsState()
Method Detail |
---|
public java.lang.String getVertexShader()
public java.lang.String getFragmentShader()
public java.util.Collection<ShaderVariable> getShaderUniforms()
public ShaderVariable getUniformByName(java.lang.String uniformName)
uniformName
-
public java.util.Collection<ShaderVariable> getShaderAttributes()
public ShaderVariable getAttributeByName(java.lang.String attributeName)
uniformName
-
public void setGeometry(Geometry geom)
geom
- public void setShaderDataLogic(GLSLShaderDataLogic shaderDataLogic)
shaderDataLogic
- public static boolean isSupported()
isSupported
determines if the ARB_shader_objects extension
is supported by current graphics configuration. This will only be valid
if a renderer has been created.
public static void overrideSupport(boolean use)
use
- public static void resetSupport()
public void setUniform(java.lang.String name, boolean value)
name
- uniform variable to changevalue
- the new valuepublic void setUniform(java.lang.String name, int value)
name
- uniform variable to changevalue
- the new valuepublic void setUniform(java.lang.String name, float value)
name
- uniform variable to changevalue
- the new valuepublic void setUniform(java.lang.String name, boolean value1, boolean value2)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuepublic void setUniform(java.lang.String name, int value1, int value2)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuepublic void setUniform(java.lang.String name, float value1, float value2)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuepublic void setUniform(java.lang.String name, boolean value1, boolean value2, boolean value3)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuepublic void setUniform(java.lang.String name, int value1, int value2, int value3)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuepublic void setUniform(java.lang.String name, float value1, float value2, float value3)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuepublic void setUniform(java.lang.String name, boolean value1, boolean value2, boolean value3, boolean value4)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuevalue4
- the new valuepublic void setUniform(java.lang.String name, int value1, int value2, int value3, int value4)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuevalue4
- the new valuepublic void setUniform(java.lang.String name, float value1, float value2, float value3, float value4)
name
- uniform variable to changevalue1
- the new valuevalue2
- the new valuevalue3
- the new valuevalue4
- the new valuepublic void setUniform(java.lang.String name, Vector2f value)
name
- uniform variable to changevalue
- the new valuepublic void setUniform(java.lang.String name, Vector3f value)
name
- uniform variable to changevalue
- the new valuepublic void setUniform(java.lang.String name, ColorRGBA value)
name
- uniform variable to changevalue
- the new valuepublic void setUniform(java.lang.String name, Quaternion value)
name
- uniform variable to changevalue
- the new valuepublic void setUniform(java.lang.String name, float[] value, boolean rowMajor)
name
- uniform variable to changevalue
- the new value (a float buffer of size 4)rowMajor
- true if is this in row major orderpublic void setUniform(java.lang.String name, Matrix3f value, boolean rowMajor)
name
- uniform variable to changevalue
- the new valuerowMajor
- true if is this in row major orderpublic void setUniform(java.lang.String name, Matrix4f value, boolean rowMajor)
name
- uniform variable to changevalue
- the new valuerowMajor
- true if is this in row major orderpublic void setUniform(java.lang.String name, Matrix4f[] values, boolean rowMajor)
name
- uniform variable to changevalue
- the new valuerowMajor
- true if is this in row major orderpublic void clearUniforms()
clearUniforms
clears all uniform values from this state.
public void setAttributePointer(java.lang.String name, int size, boolean normalized, int stride, java.nio.FloatBuffer data)
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 pointerpublic void setAttributePointer(java.lang.String name, int size, boolean normalized, boolean unsigned, int stride, java.nio.ByteBuffer data)
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 pointerpublic void setAttributePointer(java.lang.String name, int size, boolean normalized, boolean unsigned, int stride, java.nio.IntBuffer data)
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 pointerpublic void setAttributePointer(java.lang.String name, int size, boolean normalized, boolean unsigned, int stride, java.nio.ShortBuffer data)
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 pointerpublic void clearAttributes()
clearAttributes
clears all attribute values from this
state.
public int getType()
RenderState.getStateType()
instead.
RenderState
getType
in class RenderState
RenderState.getType()
public RenderState.StateType getStateType()
getStateType
returns the type RenderState.StateType.GLSLShaderObjects
getStateType
in class RenderState
RenderState.StateType.GLSLShaderObjects
RenderState.getStateType()
public void checkUniformSizeLimits()
public void checkAttributeSizeLimits()
public 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. The implementation must
convert the String into data compatible with the graphics library.
vert
- text file containing the vertex shader objectfrag
- text file containing the fragment shader objectpublic void load(java.io.InputStream vert, java.io.InputStream frag)
load
loads the shader object from the specified file. The
program must be in ASCII format. The implementation must
convert the String into data compatible with the graphics library.
vert
- The input stream from which the vertex shader can be readfrag
- The input stream from which the fragment shader can be readpublic void load(java.lang.String vert, java.lang.String frag)
load
loads the shader object from the specified string. 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.
vert
- string containing the vertex shader objectfrag
- string containing the fragment shader objectpublic void write(JMEExporter e) throws java.io.IOException
write
in interface Savable
write
in class RenderState
java.io.IOException
public void read(JMEImporter e) throws java.io.IOException
read
in interface Savable
read
in class RenderState
java.io.IOException
public java.lang.Class<? extends GLSLShaderObjectsState> getClassTag()
getClassTag
in interface Savable
getClassTag
in class RenderState
protected abstract void sendToGL(java.nio.ByteBuffer vertexByteBuffer, java.nio.ByteBuffer fragmentByteBuffer)
vertexByteBuffer
- vertex shaderfragmentByteBuffer
- fragment shaderload(java.net.URL,
java.net.URL)
protected java.nio.ByteBuffer load(java.io.InputStream in)
in
- The input stream to read
public abstract void cleanup()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |