Package dev.prozilla.pine.core.rendering
Class Shader
java.lang.Object
dev.prozilla.pine.core.rendering.Shader
- All Implemented Interfaces:
Lifecycle
Represents an OpenGL shader.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
compile()
Compiles the shader and checks its status afterward.static Shader
createShader
(int type, CharSequence source) Creates a shader with specified type and source and compiles it.void
destroy()
Deletes the shader.int
getId()
Getter for the shader ID.static Shader
loadShader
(int type, String path) Loads a shader from a file.void
source
(CharSequence source) Sets the source code of this shader.
-
Constructor Details
-
Shader
public Shader(int type) Creates a shader with specified type. The type in the tutorial should be eitherGL_VERTEX_SHADER
orGL_FRAGMENT_SHADER
.- Parameters:
type
- Type of the shader
-
-
Method Details
-
source
Sets the source code of this shader.- Parameters:
source
- GLSL Source Code for the shader
-
compile
public void compile()Compiles the shader and checks its status afterward. -
destroy
public void destroy()Deletes the shader. -
getId
public int getId()Getter for the shader ID.- Returns:
- Handle of this shader
-
createShader
Creates a shader with specified type and source and compiles it. The type in the tutorial should be eitherGL_VERTEX_SHADER
orGL_FRAGMENT_SHADER
.- Parameters:
type
- Type of the shadersource
- Source of the shader- Returns:
- Compiled Shader from the specified source
-
loadShader
Loads a shader from a file.- Parameters:
type
- Type of the shaderpath
- File path of the shader- Returns:
- Compiled Shader from specified file
-