Class GLProgram

java.lang.Object
org.xjge.graphics.GLProgram

public class GLProgram
extends java.lang.Object
Represents a completed shader program comprised of multiple Shader objects that specify how data sent to the GPU will be processed at different rendering stages while the program is active.
Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type Field Description
    java.lang.String name  
  • Constructor Summary

    Constructors
    Constructor Description
    GLProgram​(java.util.LinkedList<Shader> shaders, java.lang.String name)
    Creates a new shader program with the code supplied from the compiled .glsl source files.
  • Method Summary

    Modifier and Type Method Description
    void addUniform​(BufferType type, java.lang.String name)
    Creates an association between a CPU-stored data buffer holding the value of a uniform variable and its corresponding memory location on the GPU.
    boolean containsUniform​(java.lang.String name)
    Checks whether this shader program contains a uniform variable at any stage in its pipeline.
    void setUniform​(java.lang.String name, boolean transpose, java.util.List<org.joml.Matrix4f> values)
    Supplies the specified uniform variable with a new values.
    void setUniform​(java.lang.String name, boolean transpose, org.joml.Matrix2f value)
    Supplies the specified uniform variable with a new value.
    void setUniform​(java.lang.String name, boolean transpose, org.joml.Matrix3f value)
    Supplies the specified uniform variable with a new value.
    void setUniform​(java.lang.String name, boolean transpose, org.joml.Matrix4f value)
    Supplies the specified uniform variable with a new value.
    void setUniform​(java.lang.String name, float value)
    Supplies the specified uniform variable with a new value.
    void setUniform​(java.lang.String name, int value)
    Supplies the specified uniform variable with a new value.
    void setUniform​(java.lang.String name, org.joml.Vector2f value)
    Supplies the specified uniform variable with a new value.
    void setUniform​(java.lang.String name, org.joml.Vector3f value)
    Supplies the specified uniform variable with a new value.
    void setUniform​(java.lang.String name, org.joml.Vector4f value)
    Supplies the specified uniform variable with a new value.
    void use()
    Sets this as the current shader program the GPU will use for all subsequent rendering operations.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      public final java.lang.String name
  • Constructor Details

    • GLProgram

      public GLProgram​(java.util.LinkedList<Shader> shaders, java.lang.String name)
      Creates a new shader program with the code supplied from the compiled .glsl source files.
      Parameters:
      shaders - the objects representing various stages of the rendering pipeline
      name - the name used to identify the program should it fail to link properly
  • Method Details

    • addUniform

      public void addUniform​(BufferType type, java.lang.String name)
      Creates an association between a CPU-stored data buffer holding the value of a uniform variable and its corresponding memory location on the GPU.

      More specifically, this method allocates a new data buffer on the CPU with a size corresponding to the GLSL data type specified, then locates the memory address of the buffer on the GPU that holds the value of the uniform variable and provides that information in an object which will wrap this state for the engine to use during rendering operations.

      Parameters:
      type - the GLSL data type of the uniform variable
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
    • use

      public void use()
      Sets this as the current shader program the GPU will use for all subsequent rendering operations.
    • setUniform

      public void setUniform​(java.lang.String name, int value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, float value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, org.joml.Vector2f value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, org.joml.Vector3f value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, org.joml.Vector4f value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, boolean transpose, org.joml.Matrix2f value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      transpose - if true, the matrix data provided in the value parameter will be transposed before it is read
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, boolean transpose, org.joml.Matrix3f value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      transpose - if true, the matrix data provided in the value parameter will be transposed before it is read
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, boolean transpose, org.joml.Matrix4f value)
      Supplies the specified uniform variable with a new value.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      transpose - if true, the matrix data provided in the value parameter will be transposed before it is read
      value - the new value of the uniform variable
    • setUniform

      public void setUniform​(java.lang.String name, boolean transpose, java.util.List<org.joml.Matrix4f> values)
      Supplies the specified uniform variable with a new values. This variant of setUniform is modified so multiple values can be sent under a single name- specifically for instances where the uniform variable in question is actually a collection such as an array.
      Parameters:
      name - the unique name used to identify the uniform variable array as it appears in the .glsl source file
      transpose - if true, the matrix data provided in the value parameter will be transposed before it is read
      values - a collection of values of the uniform variable array
    • containsUniform

      public boolean containsUniform​(java.lang.String name)
      Checks whether this shader program contains a uniform variable at any stage in its pipeline.
      Parameters:
      name - the unique name used to identify the uniform variable as it appears in the .glsl source file
      Returns:
      true if this program contains a uniform variable by the name specified