com.jme3.shader
Class Shader

java.lang.Object
  extended by com.jme3.util.NativeObject
      extended by com.jme3.shader.Shader
All Implemented Interfaces:
java.lang.Cloneable

public final class Shader
extends NativeObject


Nested Class Summary
static class Shader.ShaderSource
          Shader source describes a shader object in OpenGL.
static class Shader.ShaderType
          Type of shader.
 
Field Summary
 
Fields inherited from class com.jme3.util.NativeObject
handleRef, id, type, updateNeeded
 
Constructor Summary
  Shader()
          Creates a new shader, initialize() must be called after this constructor for the shader to be usable.
protected Shader(Shader s)
          Do not use this constructor.
  Shader(java.lang.String language)
          Deprecated. Shader sources are now associated with the shader language.
 
Method Summary
 void addSource(Shader.ShaderType type, java.lang.String source)
          Deprecated. Use the method that takes a language argument instead. addSource(com.jme3.shader.Shader.ShaderType, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
 void addSource(Shader.ShaderType type, java.lang.String source, java.lang.String defines)
          Deprecated. Use the method that takes a language argument instead. addSource(com.jme3.shader.Shader.ShaderType, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
 void addSource(Shader.ShaderType type, java.lang.String name, java.lang.String source, java.lang.String defines)
          Deprecated. Use the method that takes a language argument instead. addSource(com.jme3.shader.Shader.ShaderType, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
 void addSource(Shader.ShaderType type, java.lang.String name, java.lang.String source, java.lang.String defines, java.lang.String language)
          Adds source code to a certain pipeline.
 NativeObject createDestructableClone()
          Creates a shallow clone of this GL Object.
 void deleteObject(java.lang.Object rendererObject)
          Deletes the GL object from the GPU when it is no longer used.
 Attribute getAttribute(VertexBuffer.Type attribType)
           
 java.lang.String getLanguage()
          Deprecated. Shaders no longer have a language variable, use Shader.ShaderSource.getLanguage() instead.
 java.util.Collection<Shader.ShaderSource> getSources()
           
 Uniform getUniform(java.lang.String name)
           
 ListMap<java.lang.String,Uniform> getUniformMap()
           
 void initialize()
          Initializes the shader for use, must be called after the constructor without arguments is used.
 boolean isUsable()
          Deprecated. Unusable shaders cause the renderer to crash, therefore this field no longer serves any purpose.
 void removeUniform(java.lang.String name)
           
 void resetLocations()
          Usually called when the shader itself changes or during any time when the variable locations need to be refreshed.
 void resetObject()
          Called by the object manager to reset all object IDs.
 void resetSources()
          Deprecated. This method is not needed since deleting a shader causes the sources to delete as well, thus its not required for them to be GC'd to be removed from GL.
 void setUpdateNeeded()
          Internal use only.
 void setUsable(boolean usable)
          Deprecated. Unusable shaders cause the renderer to crash, therefore this field no longer serves any purpose.
 java.lang.String toString()
           
 
Methods inherited from class com.jme3.util.NativeObject
clearUpdateNeeded, clone, getId, isUpdateNeeded, setId
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Shader

@Deprecated
public Shader(java.lang.String language)
Deprecated. Shader sources are now associated with the shader language.


Shader

public Shader()
Creates a new shader, initialize() must be called after this constructor for the shader to be usable.


Shader

protected Shader(Shader s)
Do not use this constructor. Used for destructable clones only.

Method Detail

initialize

public void initialize()
Initializes the shader for use, must be called after the constructor without arguments is used.


addSource

@Deprecated
public void addSource(Shader.ShaderType type,
                                 java.lang.String name,
                                 java.lang.String source,
                                 java.lang.String defines)
Deprecated. Use the method that takes a language argument instead. addSource(com.jme3.shader.Shader.ShaderType, java.lang.String, java.lang.String, java.lang.String, java.lang.String)


addSource

@Deprecated
public void addSource(Shader.ShaderType type,
                                 java.lang.String source,
                                 java.lang.String defines)
Deprecated. Use the method that takes a language argument instead. addSource(com.jme3.shader.Shader.ShaderType, java.lang.String, java.lang.String, java.lang.String, java.lang.String)


addSource

@Deprecated
public void addSource(Shader.ShaderType type,
                                 java.lang.String source)
Deprecated. Use the method that takes a language argument instead. addSource(com.jme3.shader.Shader.ShaderType, java.lang.String, java.lang.String, java.lang.String, java.lang.String)


addSource

public void addSource(Shader.ShaderType type,
                      java.lang.String name,
                      java.lang.String source,
                      java.lang.String defines,
                      java.lang.String language)
Adds source code to a certain pipeline.

Parameters:
type - The pipeline to control
source - 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.

getUniform

public Uniform getUniform(java.lang.String name)

removeUniform

public void removeUniform(java.lang.String name)

getAttribute

public Attribute getAttribute(VertexBuffer.Type attribType)

getUniformMap

public ListMap<java.lang.String,Uniform> getUniformMap()

getSources

public java.util.Collection<Shader.ShaderSource> getSources()

getLanguage

@Deprecated
public java.lang.String getLanguage()
Deprecated. Shaders no longer have a language variable, use Shader.ShaderSource.getLanguage() instead.


toString

public java.lang.String toString()
Overrides:
toString in class NativeObject

resetSources

@Deprecated
public void resetSources()
Deprecated. This method is not needed since deleting a shader causes the sources to delete as well, thus its not required for them to be GC'd to be removed from GL.


isUsable

@Deprecated
public boolean isUsable()
Deprecated. Unusable shaders cause the renderer to crash, therefore this field no longer serves any purpose.


setUsable

@Deprecated
public void setUsable(boolean usable)
Deprecated. Unusable shaders cause the renderer to crash, therefore this field no longer serves any purpose.


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 class NativeObject

resetObject

public void resetObject()
Called by the object manager to reset all object IDs. This causes the shader to be reuploaded to the GPU incase the display was restarted.

Specified by:
resetObject in class NativeObject

deleteObject

public void deleteObject(java.lang.Object rendererObject)
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 class NativeObject
Parameters:
rendererObject - The renderer to be used to delete the object

createDestructableClone

public NativeObject 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 class NativeObject