Package graphics
Class Shader
java.lang.Object
graphics.Shader
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Fragment Shader IDstatic int
Vertex Shader ID -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
attach()
Bind the shader programvoid
compile()
Creates vertex and fragment shader objects and compiles them.void
detach()
Unbind the shader programvoid
uploadFloat
(String varName, float val) Upload a float to the gpuvoid
uploadFloatArray
(String varName, float[] array) Upload a float array to the gpuvoid
Upload an int to the gpuvoid
uploadIntArray
(String varName, int[] array) Upload a int array to the gpuvoid
uploadMat3f
(String varName, org.joml.Matrix3f mat3) Upload a 3x3 Matrix to the gpuvoid
uploadMat4f
(String varName, org.joml.Matrix4f mat4) Upload a 4x4 Matrix to the gpuvoid
uploadTexture
(String varName, int slot) Upload a integer texture sampler to the gpuvoid
uploadVec2f
(String varName, org.joml.Vector2f vec) Upload a 2-d Vector to the gpuvoid
uploadVec2fArray
(String varName, org.joml.Vector2f[] vec) Upload a 2-d Vector array to the gpuvoid
uploadVec3fArray
(String varName, org.joml.Vector3f[] vec) Upload a 3-d Vector array to the gpuvoid
uploadVec4f
(String varName, org.joml.Vector4f vec) Upload a 4-d Vector to the gpu
-
Field Details
-
vertexID
public static int vertexIDVertex Shader ID -
fragmentID
public static int fragmentIDFragment Shader ID
-
-
Constructor Details
-
Shader
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
Upload a 4x4 Matrix to the gpu- Parameters:
varName
- name of the uniformmat4
- the matrix to be uploaded
-
uploadMat3f
Upload a 3x3 Matrix to the gpu- Parameters:
varName
- name of the uniformmat3
- the matrix to be uploaded
-
uploadVec4f
Upload a 4-d Vector to the gpu- Parameters:
varName
- name of the uniformvec
- the vector to be uploaded
-
uploadVec3fArray
Upload a 3-d Vector array to the gpu- Parameters:
varName
- name of the uniformvec
- the array to be uploaded
-
uploadVec2f
Upload a 2-d Vector to the gpu- Parameters:
varName
- name of the uniformvec
- the vector to be uploaded
-
uploadVec2fArray
Upload a 2-d Vector array to the gpu- Parameters:
varName
- name of the uniformvec
- the array to be uploaded
-
uploadFloat
Upload a float to the gpu- Parameters:
varName
- name of the uniformval
- the float value to be uploaded
-
uploadFloatArray
Upload a float array to the gpu- Parameters:
varName
- name of the uniformarray
- the array to be uploaded
-
uploadInt
Upload an int to the gpu- Parameters:
varName
- name of the uniformval
- the int value to be uploaded
-
uploadTexture
Upload a integer texture sampler to the gpu- Parameters:
varName
- name of the uniformslot
- the texture slot to which the texture is bound
-
uploadIntArray
Upload a int array to the gpu- Parameters:
varName
- name of the uniformarray
- the array to be uploaded
-