Package graphics
Class Shader
java.lang.Object
graphics.Shader
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intFragment Shader IDstatic intVertex Shader ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattach()Bind the shader programvoidcompile()Creates vertex and fragment shader objects and compiles them.voiddetach()Unbind the shader programvoiduploadFloat(String varName, float val) Upload a float to the gpuvoiduploadFloatArray(String varName, float[] array) Upload a float array to the gpuvoidUpload an int to the gpuvoiduploadIntArray(String varName, int[] array) Upload a int array to the gpuvoiduploadMat3f(String varName, org.joml.Matrix3f mat3) Upload a 3x3 Matrix to the gpuvoiduploadMat4f(String varName, org.joml.Matrix4f mat4) Upload a 4x4 Matrix to the gpuvoiduploadTexture(String varName, int slot) Upload a integer texture sampler to the gpuvoiduploadVec2f(String varName, org.joml.Vector2f vec) Upload a 2-d Vector to the gpuvoiduploadVec2fArray(String varName, org.joml.Vector2f[] vec) Upload a 2-d Vector array to the gpuvoiduploadVec3fArray(String varName, org.joml.Vector3f[] vec) Upload a 3-d Vector array to the gpuvoiduploadVec4f(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
-