Class Shader

java.lang.Object
dev.prozilla.pine.core.rendering.Shader
All Implemented Interfaces:
Asset, Destructible

public class Shader extends Object implements Asset
Represents an OpenGL shader.
  • Constructor Details

    • Shader

      public Shader(int type)
      Creates a shader with specified type. The type in the tutorial should be either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
      Parameters:
      type - Type of the shader
  • Method Details

    • source

      public void source(CharSequence 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.
      Specified by:
      destroy in interface Asset
      Specified by:
      destroy in interface Destructible
    • getId

      public int getId()
      Getter for the shader ID.
      Returns:
      Handle of this shader
    • getPath

      public String getPath()
      Description copied from interface: Asset
      Returns the path to the file this asset was loaded from.
      Specified by:
      getPath in interface Asset
      Returns:
      The path of this asset.
    • setPath

      public void setPath(String path)
    • createShader

      public static Shader createShader(int type, CharSequence source)
      Creates a shader with specified type and source and compiles it. The type in the tutorial should be either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
      Parameters:
      type - Type of the shader
      source - Source of the shader
      Returns:
      Compiled Shader from the specified source