Interface ShaderProgram

All Superinterfaces:
AutoCloseable, MutableShaderUniformAccess, org.lwjgl.system.NativeResource, ShaderUniformAccess, UniformAccess
All Known Implementing Classes:
ShaderProgramImpl

public interface ShaderProgram extends org.lwjgl.system.NativeResource, MutableShaderUniformAccess
Represents a usable shader program with shaders attached.
  • Method Details

    • setup

      default void setup()
      Binds this program for use and prepares for rendering.
    • bind

      default void bind()
      Binds this program for use.
    • unbind

      static void unbind()
      Unbinds the currently bound shader program.
    • compile

      void compile(ShaderCompiler.Context context, ShaderCompiler compiler) throws Exception
      Compiles this shader based on the specified definition.
      Parameters:
      context - The context to use when compiling shaders
      compiler - The compiler to use
      Throws:
      Exception - If an error occurs while compiling or linking shaders
    • getShaders

      Set<CompiledShader> getShaders()
      Returns:
      The shaders attached to this program
    • getDefinitionDependencies

      Set<String> getDefinitionDependencies()
      Returns:
      All shader definitions this program depends on
    • getId

      net.minecraft.resources.ResourceLocation getId()
      Returns:
      The id of this program
    • toShaderInstance

      net.minecraft.client.renderer.ShaderInstance toShaderInstance()

      Wraps this shader with a vanilla Minecraft shader instance wrapper. There are a few special properties about the shader wrapper.

      • The shader instance cannot be used to free the shader program. NativeResource.free() must be called separately. If the shader is loaded through ShaderManager then there is no need to free the shader.
      • Calling Uniform.upload() will do nothing since the values are uploaded when the appropriate methods are called
      • Uniforms are lazily wrapped and will not crash when the wrong method is called.
      • Uniform.set(int, float) is not supported and will throw an UnsupportedOperationException.
      • Only Uniform.set(Matrix3f) and Uniform.set(Matrix4f) will be able to set matrix values. All other matrix methods will throw an UnsupportedOperationException.
      • Uniform.set(float[]) only works for 1, 2, 3, and 4 float elements. Any other size will throw an UnsupportedOperationException.
      Returns:
      A lazily loaded shader instance wrapper for this program
    • create

      static ShaderProgram create(net.minecraft.resources.ResourceLocation id)
      Creates a new shader program with the specified id.
      Parameters:
      id - The id of the program
      Returns:
      A new shader program