Class ShaderProgram

java.lang.Object
lol.trq.helios.shader.ShaderProgram
All Implemented Interfaces:
AutoCloseable

public final class ShaderProgram extends Object implements AutoCloseable
A linked program with a uniform location cache. A uniform the driver optimised away resolves to -1 once, is cached as -1, and setting it does nothing, as in OpenGL.

Setters apply to the program currently in use; bind it first, through a StateGuard.program(int).

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes the program.
    int
    id()
    Returns the GL program id.
    int
    location(String uniform)
    Returns a uniform location, from the cache after the first lookup.
    Returns the name this program was loaded under.
    void
    set(String uniform, float v)
    Sets a float uniform.
    void
    set(String uniform, float[] m)
    Sets a mat4 uniform.
    void
    set(String uniform, float x, float y)
    Sets a vec2 uniform.
    void
    set(String uniform, float x, float y, float z, float w)
    Sets a vec4 uniform.
    void
    set(String uniform, int v)
    Sets an int or sampler uniform.

    Methods inherited from class Object

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

    • id

      public int id()
      Returns the GL program id.
      Returns:
      the id, or 0 after close()
    • name

      public String name()
      Returns the name this program was loaded under.
      Returns:
      the name
    • location

      public int location(String uniform)
      Returns a uniform location, from the cache after the first lookup.
      Parameters:
      uniform - the uniform name
      Returns:
      the location, or -1 if the program has no such active uniform
    • set

      public void set(String uniform, int v)
      Sets an int or sampler uniform.
      Parameters:
      uniform - the name
      v - the value
    • set

      public void set(String uniform, float v)
      Sets a float uniform.
      Parameters:
      uniform - the name
      v - the value
    • set

      public void set(String uniform, float x, float y)
      Sets a vec2 uniform.
      Parameters:
      uniform - the name
      x - first component
      y - second component
    • set

      public void set(String uniform, float[] m)
      Sets a mat4 uniform.
      Parameters:
      uniform - the name
      m - the matrix, 16 floats column-major
    • set

      public void set(String uniform, float x, float y, float z, float w)
      Sets a vec4 uniform.
      Parameters:
      uniform - the name
      x - first component
      y - second component
      z - third component
      w - fourth component
    • close

      public void close()
      Deletes the program.
      Specified by:
      close in interface AutoCloseable