Package engine.shaders
Class ShaderProgram
java.lang.Object
engine.shaders.ShaderProgram
- Direct Known Subclasses:
EntityShader
,FontShader
,GuiShader
,SelectorShader
,TerrainShader
Abstract class from which all shaders inherit.
-
Constructor Summary
ConstructorsConstructorDescriptionShaderProgram
(String vertexFile, String fragmentFile) Receives the file name of the vertex and fragment GLSL file for a shader. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
bindAttribute
(int attribute, String variableName) Binds the attributes to the Shaderprotected abstract void
Binds all attributes on a per shader program basisvoid
cleanUp()
Detaches and deletes the program from the GPUprotected abstract void
Gets all uniform loactions on a per shader program basis.protected int
getUniformLocation
(String uniformName) Finds the uniform variables in the shaderprotected void
load2DVector
(int location, org.joml.Vector2f vector) Loads a Vector2f into the shaderprotected void
loadBoolean
(int location, boolean value) Loads a boolean value into the shader.protected void
loadFloat
(int location, float value) Loads a float value into the shader.protected void
loadMatrix
(int location, org.joml.Matrix4f matrix) Loads a Matrix4f into the shaderprotected void
loadVector
(int location, org.joml.Vector3f vector) Loads a Vector3f into the shader.void
start()
Starts the programvoid
stop()
Stops the program
-
Constructor Details
-
ShaderProgram
Receives the file name of the vertex and fragment GLSL file for a shader. Proceeds to load the shader file from the method below and then create a shader program which runs on the GPU. Shader program is attached and linked to the GPU and all attributes are bind as well as all uniform locations are found.- Parameters:
vertexFile
-fragmentFile
-
-
-
Method Details
-
start
public void start()Starts the program -
stop
public void stop()Stops the program -
cleanUp
public void cleanUp()Detaches and deletes the program from the GPU -
bindAttribute
Binds the attributes to the Shader- Parameters:
attribute
-variableName
-
-
getUniformLocation
Finds the uniform variables in the shader- Parameters:
uniformName
-- Returns:
-
loadFloat
protected void loadFloat(int location, float value) Loads a float value into the shader.- Parameters:
location
-value
-
-
loadVector
protected void loadVector(int location, org.joml.Vector3f vector) Loads a Vector3f into the shader.- Parameters:
location
-vector
-
-
load2DVector
protected void load2DVector(int location, org.joml.Vector2f vector) Loads a Vector2f into the shader- Parameters:
location
-vector
-
-
loadBoolean
protected void loadBoolean(int location, boolean value) Loads a boolean value into the shader.- Parameters:
location
-value
-
-
loadMatrix
protected void loadMatrix(int location, org.joml.Matrix4f matrix) Loads a Matrix4f into the shader- Parameters:
location
-matrix
-
-
bindAttributes
protected abstract void bindAttributes()Binds all attributes on a per shader program basis -
getAllUniformLocations
protected abstract void getAllUniformLocations()Gets all uniform loactions on a per shader program basis.
-