Package dev.prozilla.pine.core.rendering
Class ShaderProgram
java.lang.Object
dev.prozilla.pine.core.rendering.ShaderProgram
- All Implemented Interfaces:
Destructible
Represents an OpenGL shader program.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattachShader(Shader shader) Attach a shader to this program.voidbindFragmentDataLocation(int number, CharSequence name) Binds the fragment out color variable.voidChecks if the program was linked successfully.voiddestroy()Deletes the shader program.voiddisableVertexAttribute(int location) Disables a vertex attribute.voidenableVertexAttribute(int location) Enables a vertex attribute.intGets the location of an attribute variable with specified name.static intintGets the location of a uniform variable with specified name.voidlink()Link this program and check its status afterward.voidpointVertexAttribute(int location, int size, int stride, int offset) Sets the vertex attribute pointer.intintvoidsetUniform(int location, float value) Sets the uniform variable for specified location.voidsetUniform(int location, int value) Sets the uniform variable for specified location.voidsetUniform(int location, int[] value) Sets the uniform variable for specified location.voidsetUniform(int location, Matrix2f value) Sets the uniform variable for specified location.voidsetUniform(int location, Matrix3f value) Sets the uniform variable for specified location.voidsetUniform(int location, Matrix4f value) Sets the uniform variable for specified location.voidsetUniform(int location, Vector2f value) Sets the uniform variable for specified location.voidsetUniform(int location, Vector3f value) Sets the uniform variable for specified location.voidsetUniform(int location, Vector4f value) Sets the uniform variable for specified location.voidsetUniform(CharSequence name, float value) voidsetUniform(CharSequence name, int value) voidsetUniform(CharSequence name, int[] value) voidsetUniform(CharSequence name, Matrix2f value) voidsetUniform(CharSequence name, Matrix3f value) voidsetUniform(CharSequence name, Matrix4f value) voidsetUniform(CharSequence name, Vector2f value) voidsetUniform(CharSequence name, Vector3f value) voidsetUniform(CharSequence name, Vector4f value) voidsetVertexAttribute(CharSequence name, int size, int stride, int offset) Enables a vertex attribute and sets its pointer.voidsetVertexAttributes(CharSequence[] names, int[] sizes, int stride) Sets multiple vertex attributes.voiduse()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. -
setVertexAttributes
Sets multiple vertex attributes.- Parameters:
names- The names of each attributesizes- The amount of floats used for each attributestride- The amount of floats used per vertex
-
setVertexAttribute
Enables a vertex attribute and sets its pointer.- Parameters:
name- The name of the attributesize- The amount of floats used for the attributestride- The amount of floats used per vertexoffset- The offset from the first component
-
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:
GLException- If the program failed to link.
-
destroy
public void destroy()Deletes the shader program.- Specified by:
destroyin interfaceDestructible
-
getMaxVertexAttributes
public static int getMaxVertexAttributes()
-