Class Shader

All Implemented Interfaces:
Cloneable

public final class Shader extends NativeObject
  • Constructor Details

    • 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 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 control
      name - a name for the new shader object
      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.
    • addUniformBinding

      public void addUniformBinding(UniformBinding binding)
    • getUniform

      public Uniform getUniform(String name)
    • getBufferBlock

      public ShaderBufferBlock getBufferBlock(String name)
      Gets or creates a buffer block by the name.
      Parameters:
      name - the buffer block's name.
      Returns:
      the buffer block.
    • removeUniform

      public void removeUniform(String name)
    • removeBufferBlock

      public void removeBufferBlock(String name)
      Removes a buffer block by the name.
      Parameters:
      name - the buffer block's name.
    • getAttribute

      public Attribute getAttribute(VertexBuffer.Type attribType)
    • getUniformMap

      public ListMap<String,Uniform> getUniformMap()
    • getBufferBlockMap

      public ListMap<String,ShaderBufferBlock> getBufferBlockMap()
      Get the buffer blocks map.
      Returns:
      the buffer blocks map.
    • getBoundUniforms

      public ArrayList<Uniform> getBoundUniforms()
    • getSources

      public Collection<Shader.ShaderSource> getSources()
    • toString

      public String toString()
      Overrides:
      toString in class NativeObject
    • 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 to resetUniformsNotSetByCurrent() 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, use clearUniformsSetByCurrentFlag().
    • 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 in case the display was restarted.
      Specified by:
      resetObject in class NativeObject
    • deleteObject

      public void deleteObject(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
      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 class NativeObject
      Returns:
      unique ID for this NativeObject.