java.lang.Object
com.marginallyclever.ro3.apps.viewport.ShaderProgram

public class ShaderProgram extends Object

ShaderProgram is a wrapper for vertex and fragment shader programs. It also provides a simple interface for setting uniforms.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ShaderProgram(com.jogamp.opengl.GL3 gl, String[] vertexCode, String[] fragmentCode)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete(com.jogamp.opengl.GL3 gl)
     
    int
     
    int
    getUniformLocation(com.jogamp.opengl.GL3 gl, String name)
     
    void
    set1f(com.jogamp.opengl.GL3 gl, String name, float v0)
     
    void
    set1i(com.jogamp.opengl.GL3 gl, String name, int value)
     
    void
    set2f(com.jogamp.opengl.GL3 gl, String name, float v0, float v1)
     
    void
    set3f(com.jogamp.opengl.GL3 gl, String name, float v0, float v1, float v2)
     
    void
    set4f(com.jogamp.opengl.GL3 gl, String name, float v0, float v1, float v2, float v3)
     
    void
    setColor(com.jogamp.opengl.GL3 gl3, String name, Color color)
     
    void
    setMatrix4d(com.jogamp.opengl.GL3 gl, String name, javax.vecmath.Matrix4d value)
    Set a matrix in the shader.
    void
    setVector3d(com.jogamp.opengl.GL3 gl, String name, javax.vecmath.Vector3d value)
     
    void
    use(com.jogamp.opengl.GL3 gl)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ShaderProgram

      public ShaderProgram(com.jogamp.opengl.GL3 gl, String[] vertexCode, String[] fragmentCode)
  • Method Details

    • use

      public void use(com.jogamp.opengl.GL3 gl)
    • delete

      public void delete(com.jogamp.opengl.GL3 gl)
    • getProgramId

      public int getProgramId()
    • getUniformLocation

      public int getUniformLocation(com.jogamp.opengl.GL3 gl, String name)
    • set1f

      public void set1f(com.jogamp.opengl.GL3 gl, String name, float v0)
    • set2f

      public void set2f(com.jogamp.opengl.GL3 gl, String name, float v0, float v1)
    • set3f

      public void set3f(com.jogamp.opengl.GL3 gl, String name, float v0, float v1, float v2)
    • set4f

      public void set4f(com.jogamp.opengl.GL3 gl, String name, float v0, float v1, float v2, float v3)
    • setVector3d

      public void setVector3d(com.jogamp.opengl.GL3 gl, String name, javax.vecmath.Vector3d value)
    • setMatrix4d

      public void setMatrix4d(com.jogamp.opengl.GL3 gl, String name, javax.vecmath.Matrix4d value)
      Set a matrix in the shader. OpenGL uses column-major order, where Java and DirectX use row-major order. Don't forget to transpose!
      Parameters:
      gl - the viewport context
      name - the name of the uniform variable
      value - the matrix to set
    • set1i

      public void set1i(com.jogamp.opengl.GL3 gl, String name, int value)
    • setColor

      public void setColor(com.jogamp.opengl.GL3 gl3, String name, Color color)