Package com.jme3.shader
Class Shader
java.lang.Object
com.jme3.util.NativeObject
com.jme3.shader.Shader
- All Implemented Interfaces:
Cloneable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classShader source describes a shader object in OpenGL.static enumType 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds source code to a certain pipeline.voidaddUniformBinding(UniformBinding binding) voidRemoves the "set-by-current-material" flag from all uniforms.Creates a shallow clone of this GL Object.voiddeleteObject(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) longReturns a unique ID for this NativeObject.voidremoveBufferBlock(String name) Removes a buffer block by the name.voidremoveUniform(String name) voidUsually called when the shader itself changes or during any time when the variable locations need to be refreshed.voidCalled by the object manager to reset all object IDs.voidResets all uniforms that do not have the "set-by-current-material" flag to their default value (usually all zeroes or false).voidInternal 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:
toStringin 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:NativeObjectInternal use only. Indicates that the object has changed and its state needs to be updated.- Overrides:
setUpdateNeededin 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:
resetObjectin classNativeObject
-
deleteObject
Description copied from class:NativeObjectDeletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.- Specified by:
deleteObjectin classNativeObject- Parameters:
rendererObject- The renderer to be used to delete the object
-
createDestructableClone
Description copied from class:NativeObjectCreates a shallow clone of this GL Object. The deleteObject method should be functional for this object.- Specified by:
createDestructableClonein classNativeObject- Returns:
- a new instance
-
getUniqueId
public long getUniqueId()Description copied from class:NativeObjectReturns a unique ID for this NativeObject. No other NativeObject shall have the same ID.- Specified by:
getUniqueIdin classNativeObject- Returns:
- unique ID for this NativeObject.
-