Package dev.prozilla.pine.core.rendering
Class ShaderProgram
java.lang.Object
dev.prozilla.pine.core.rendering.ShaderProgram
- All Implemented Interfaces:
Lifecycle
Represents an OpenGL shader program.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
attachShader
(Shader shader) Attach a shader to this program.void
bindFragmentDataLocation
(int number, CharSequence name) Binds the fragment out color variable.void
Checks if the program was linked successfully.void
destroy()
Deletes the shader program.void
disableVertexAttribute
(int location) Disables a vertex attribute.void
enableVertexAttribute
(int location) Enables a vertex attribute.int
Gets the location of an attribute variable with specified name.int
Gets the location of a uniform variable with specified name.void
link()
Link this program and check its status afterward.void
pointVertexAttribute
(int location, int size, int stride, int offset) Sets the vertex attribute pointer.void
setUniform
(int location, float value) Sets the uniform variable for specified location.void
setUniform
(int location, int value) Sets the uniform variable for specified location.void
setUniform
(int location, int[] value) Sets the uniform variable for specified location.void
setUniform
(int location, Matrix2f value) Sets the uniform variable for specified location.void
setUniform
(int location, Matrix3f value) Sets the uniform variable for specified location.void
setUniform
(int location, Matrix4f value) Sets the uniform variable for specified location.void
setUniform
(int location, Vector2f value) Sets the uniform variable for specified location.void
setUniform
(int location, Vector3f value) Sets the uniform variable for specified location.void
setUniform
(int location, Vector4f value) Sets the uniform variable for specified location.void
use()
Use this shader program.
-
Constructor Details
-
ShaderProgram
public ShaderProgram()Creates a shader program.
-
-
Method Details
-
attachShader
Attach a shader to this program.- Parameters:
shader
- Shader to get attached
-
bindFragmentDataLocation
Binds the fragment out color variable.- Parameters:
number
- Color number you want to bindname
- Variable name
-
link
public void link()Link this program and check its status afterward. -
getAttributeLocation
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 attributesize
- Number of values per vertexstride
- Offset between consecutive generic vertex attributes in bytesoffset
- Offset of the first component of the first generic vertex attribute in bytes
-
getUniformLocation
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 locationvalue
- Value to set
-
setUniform
public void setUniform(int location, float value) Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
public void setUniform(int location, int[] value) Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- 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.
-