Package com.jme3.shader
Class Shader
java.lang.Object
com.jme3.util.NativeObject
com.jme3.shader.Shader
- All Implemented Interfaces:
Cloneable
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Shader source describes a shader object in OpenGL.static enum
Type of shader. -
Field Summary
Fields inherited from class com.jme3.util.NativeObject
handleRef, id, INVALID_ID, objectManager, OBJTYPE_AUDIOBUFFER, OBJTYPE_AUDIOSTREAM, OBJTYPE_BO, OBJTYPE_FILTER, OBJTYPE_FRAMEBUFFER, OBJTYPE_SHADER, OBJTYPE_SHADERSOURCE, OBJTYPE_TEXTURE, OBJTYPE_VERTEXBUFFER, updateNeeded
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds source code to a certain pipeline.void
addUniformBinding
(UniformBinding binding) void
Removes the "set-by-current-material" flag from all uniforms.Creates a shallow clone of this GL Object.void
deleteObject
(Object rendererObject) Deletes the GL object from the GPU when it is no longer used.getAttribute
(VertexBuffer.Type attribType) getBufferBlock
(String name) Gets or creates a buffer block by the name.Get the buffer blocks map.getUniform
(String name) long
Returns a unique ID for this NativeObject.void
removeBufferBlock
(String name) Removes a buffer block by the name.void
removeUniform
(String name) void
Usually called when the shader itself changes or during any time when the variable locations need to be refreshed.void
Called by the object manager to reset all object IDs.void
Resets all uniforms that do not have the "set-by-current-material" flag to their default value (usually all zeroes or false).void
Internal use only.toString()
Methods inherited from class com.jme3.util.NativeObject
clearUpdateNeeded, clone, deleteNativeBuffers, dispose, getId, getWeakRef, isUpdateNeeded, setId
-
Constructor Details
-
Shader
public Shader()Creates a new shader, initialize() must be called after this constructor for the shader to be usable. -
Shader
Do not use this constructor. Used for destructible clones only.- Parameters:
s
- (not null)
-
-
Method Details
-
addSource
public void addSource(Shader.ShaderType type, String name, String source, String defines, String language) Adds source code to a certain pipeline.- Parameters:
type
- The pipeline to controlname
- a name for the new shader objectsource
- The shader source code (in GLSL).defines
- Preprocessor defines (placed at the beginning of the shader)language
- The shader source language, currently accepted is GLSL### where ### is the version, e.g. GLSL100 = GLSL 1.0, GLSL330 = GLSL 3.3, etc.
-
addUniformBinding
-
getUniform
-
getBufferBlock
Gets or creates a buffer block by the name.- Parameters:
name
- the buffer block's name.- Returns:
- the buffer block.
-
removeUniform
-
removeBufferBlock
Removes a buffer block by the name.- Parameters:
name
- the buffer block's name.
-
getAttribute
-
getUniformMap
-
getBufferBlockMap
Get the buffer blocks map.- Returns:
- the buffer blocks map.
-
getBoundUniforms
-
getSources
-
toString
- Overrides:
toString
in classNativeObject
-
clearUniformsSetByCurrentFlag
public void clearUniformsSetByCurrentFlag()Removes the "set-by-current-material" flag from all uniforms. When a uniform is modified after this call, the flag shall become "set-by-current-material". A call toresetUniformsNotSetByCurrent()
will reset all uniforms that do not have the "set-by-current-material" flag to their default value (usually all zeroes or false). -
resetUniformsNotSetByCurrent
public void resetUniformsNotSetByCurrent()Resets all uniforms that do not have the "set-by-current-material" flag to their default value (usually all zeroes or false). When a uniform is modified, that flag is set, to remove the flag, useclearUniformsSetByCurrentFlag()
. -
resetLocations
public void resetLocations()Usually called when the shader itself changes or during any time when the variable locations need to be refreshed. -
setUpdateNeeded
public void setUpdateNeeded()Description copied from class:NativeObject
Internal use only. Indicates that the object has changed and its state needs to be updated.- Overrides:
setUpdateNeeded
in classNativeObject
-
resetObject
public void resetObject()Called by the object manager to reset all object IDs. This causes the shader to be reuploaded to the GPU in case the display was restarted.- Specified by:
resetObject
in classNativeObject
-
deleteObject
Description copied from class:NativeObject
Deletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.- Specified by:
deleteObject
in classNativeObject
- Parameters:
rendererObject
- The renderer to be used to delete the object
-
createDestructableClone
Description copied from class:NativeObject
Creates a shallow clone of this GL Object. The deleteObject method should be functional for this object.- Specified by:
createDestructableClone
in classNativeObject
- Returns:
- a new instance
-
getUniqueId
public long getUniqueId()Description copied from class:NativeObject
Returns a unique ID for this NativeObject. No other NativeObject shall have the same ID.- Specified by:
getUniqueId
in classNativeObject
- Returns:
- unique ID for this NativeObject.
-