Class ShaderProgram

java.lang.Object
dev.prozilla.pine.core.rendering.ShaderProgram
All Implemented Interfaces:
Lifecycle

public class ShaderProgram extends Object implements Lifecycle
Represents an OpenGL shader program.
  • Constructor Details

    • ShaderProgram

      public ShaderProgram()
      Creates a shader program.
  • Method Details

    • attachShader

      public void attachShader(Shader shader)
      Attach a shader to this program.
      Parameters:
      shader - Shader to get attached
    • bindFragmentDataLocation

      public void bindFragmentDataLocation(int number, CharSequence name)
      Binds the fragment out color variable.
      Parameters:
      number - Color number you want to bind
      name - Variable name
    • link

      public void link()
      Link this program and check its status afterward.
    • getAttributeLocation

      public int getAttributeLocation(CharSequence name)
      Gets the location of an attribute variable with specified name.
      Parameters:
      name - Attribute name
      Returns:
      Location of the attribute
    • enableVertexAttribute

      public void enableVertexAttribute(int location)
      Enables a vertex attribute.
      Parameters:
      location - Location of the vertex attribute
    • disableVertexAttribute

      public void disableVertexAttribute(int location)
      Disables a vertex attribute.
      Parameters:
      location - Location of the vertex attribute
    • pointVertexAttribute

      public void pointVertexAttribute(int location, int size, int stride, int offset)
      Sets the vertex attribute pointer.
      Parameters:
      location - Location of the vertex attribute
      size - Number of values per vertex
      stride - Offset between consecutive generic vertex attributes in bytes
      offset - Offset of the first component of the first generic vertex attribute in bytes
    • getUniformLocation

      public int getUniformLocation(CharSequence name)
      Gets the location of a uniform variable with specified name.
      Parameters:
      name - Uniform name
      Returns:
      Location of the uniform
    • setUniform

      public void setUniform(int location, int value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, float value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, Vector2f value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, Vector3f value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, Vector4f value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, Matrix2f value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, Matrix3f value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, Matrix4f value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • setUniform

      public void setUniform(int location, int[] value)
      Sets the uniform variable for specified location.
      Parameters:
      location - Uniform location
      value - Value to set
    • use

      public void use()
      Use this shader program.
    • checkStatus

      public void checkStatus()
      Checks if the program was linked successfully.
    • destroy

      public void destroy()
      Deletes the shader program.
      Specified by:
      destroy in interface Lifecycle