Class ComputeShader

java.lang.Object
com.jme3.util.NativeObject
com.jme3.renderer.opengl.ComputeShader
All Implemented Interfaces:
Cloneable

public class ComputeShader extends NativeObject
A compute shader for general-purpose GPU computing (GPGPU).

Compute shaders require OpenGL 4.3 or higher.

  • Constructor Details

    • ComputeShader

      public ComputeShader(GL4 gl, String source)
      Creates a new compute shader from GLSL source code.
  • Method Details

    • makeActive

      public void makeActive()
      Activates this compute shader for use. Must be called before setting uniforms or dispatching.
    • dispatch

      public void dispatch(int numGroupsX, int numGroupsY, int numGroupsZ)
      Dispatches the compute shader with the specified number of work groups.
    • setUniform

      public void setUniform(int location, int value)
    • setUniform

      public void setUniform(int location, float value)
    • setUniform

      public void setUniform(int location, Vector2f value)
    • setUniform

      public void setUniform(int location, Vector3f value)
    • setUniform

      public void setUniform(int location, Vector4f value)
    • setUniform

      public void setUniform(int location, Matrix4f value)
    • getUniformLocation

      public int getUniformLocation(String name)
    • bindShaderStorageBuffer

      public void bindShaderStorageBuffer(int location, ShaderStorageBufferObject ssbo)
    • resetObject

      public void resetObject()
      Description copied from class: NativeObject
      Called when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.
      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.