Package graphics

Class Shader

java.lang.Object
graphics.Shader

public class Shader extends Object
  • Field Details

    • vertexID

      public static int vertexID
      Vertex Shader ID
    • fragmentID

      public static int fragmentID
      Fragment Shader ID
  • Constructor Details

    • Shader

      public Shader(String filePath)
      Loads the shader file at filepath. The shader file should have both shaders. Vertex Shader and fragment shader. #type should be used to separate them.
  • Method Details

    • compile

      public void compile()
      Creates vertex and fragment shader objects and compiles them. Also links them with the shader program
    • attach

      public void attach()
      Bind the shader program
    • detach

      public void detach()
      Unbind the shader program
    • uploadMat4f

      public void uploadMat4f(String varName, org.joml.Matrix4f mat4)
      Upload a 4x4 Matrix to the gpu
      Parameters:
      varName - name of the uniform
      mat4 - the matrix to be uploaded
    • uploadMat3f

      public void uploadMat3f(String varName, org.joml.Matrix3f mat3)
      Upload a 3x3 Matrix to the gpu
      Parameters:
      varName - name of the uniform
      mat3 - the matrix to be uploaded
    • uploadVec4f

      public void uploadVec4f(String varName, org.joml.Vector4f vec)
      Upload a 4-d Vector to the gpu
      Parameters:
      varName - name of the uniform
      vec - the vector to be uploaded
    • uploadVec3fArray

      public void uploadVec3fArray(String varName, org.joml.Vector3f[] vec)
      Upload a 3-d Vector array to the gpu
      Parameters:
      varName - name of the uniform
      vec - the array to be uploaded
    • uploadVec2f

      public void uploadVec2f(String varName, org.joml.Vector2f vec)
      Upload a 2-d Vector to the gpu
      Parameters:
      varName - name of the uniform
      vec - the vector to be uploaded
    • uploadVec2fArray

      public void uploadVec2fArray(String varName, org.joml.Vector2f[] vec)
      Upload a 2-d Vector array to the gpu
      Parameters:
      varName - name of the uniform
      vec - the array to be uploaded
    • uploadFloat

      public void uploadFloat(String varName, float val)
      Upload a float to the gpu
      Parameters:
      varName - name of the uniform
      val - the float value to be uploaded
    • uploadFloatArray

      public void uploadFloatArray(String varName, float[] array)
      Upload a float array to the gpu
      Parameters:
      varName - name of the uniform
      array - the array to be uploaded
    • uploadInt

      public void uploadInt(String varName, int val)
      Upload an int to the gpu
      Parameters:
      varName - name of the uniform
      val - the int value to be uploaded
    • uploadTexture

      public void uploadTexture(String varName, int slot)
      Upload a integer texture sampler to the gpu
      Parameters:
      varName - name of the uniform
      slot - the texture slot to which the texture is bound
    • uploadIntArray

      public void uploadIntArray(String varName, int[] array)
      Upload a int array to the gpu
      Parameters:
      varName - name of the uniform
      array - the array to be uploaded