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.int
int
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
setUniform
(CharSequence name, float value) void
setUniform
(CharSequence name, int value) void
setUniform
(CharSequence name, int[] value) void
setUniform
(CharSequence name, Matrix2f value) void
setUniform
(CharSequence name, Matrix3f value) void
setUniform
(CharSequence name, Matrix4f value) void
setUniform
(CharSequence name, Vector2f value) void
setUniform
(CharSequence name, Vector3f value) void
setUniform
(CharSequence name, Vector4f value) void
setVertexAttribute
(CharSequence name, int size, int stride, int offset) 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. -
setVertexAttribute
-
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
-
requireAttributeLocation
- Throws:
RuntimeException
-
getAttributeLocation
Gets the location of an attribute variable with specified name.- Parameters:
name
- Attribute name- Returns:
- Location of the attribute
-
setUniform
-
setUniform
public void setUniform(int location, int value) Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
public void setUniform(int location, float value) Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
setUniform
-
setUniform
public void setUniform(int location, int[] value) Sets the uniform variable for specified location.- Parameters:
location
- Uniform locationvalue
- Value to set
-
requireUniformLocation
- Throws:
RuntimeException
-
getUniformLocation
Gets the location of a uniform variable with specified name.- Parameters:
name
- Uniform name- Returns:
- Location of the uniform
-
use
public void use()Use this shader program. -
checkStatus
Checks if the program was linked successfully.- Throws:
RuntimeException
-
destroy
public void destroy()Deletes the shader program.
-