Class ShaderProgram

java.lang.Object
codechicken.lib.render.shader.ShaderProgram
All Implemented Interfaces:
net.minecraft.server.packs.resources.PreparableReloadListener, net.minecraft.server.packs.resources.ResourceManagerReloadListener

public class ShaderProgram extends Object implements net.minecraft.server.packs.resources.ResourceManagerReloadListener
A ShaderProgram.

As of 1.18.2, you will probably want to use CCShaderInstance instead as an extension to Vanilla's ShaderInstance.

You probably want ShaderProgramBuilder to construct a ShaderProgram. it should be noted, that a ShaderProgram is a ResourceManagerReloadListener, its recommended that you ensure this is registered to ReloadableResourceManager to ensure ShaderObjects are re loaded properly when Resources are reloaded.

Created by covers1624 on 24/5/20.

  • Method Details

    • getShaders

      public List<ShaderObject> getShaders()
      Gets all ShaderObjects that make up this ShaderProgram.
      Returns:
      The ShaderObjects.
    • getUniforms

      public Map<String,CCUniform> getUniforms()
      Get all UniformPairs exposed by this shader.
      Returns:
      The uniforms.
    • getUniform

      @Nullable public @Nullable CCUniform getUniform(String name)
      Get a CCUniform from this ShaderProgram.
      Parameters:
      name - The name of the Uniform.
      Returns:
      the CCUniform.
    • getProgramId

      public int getProgramId()
      Gets the GL ShaderProgram id for this shader. Might not be initialized until use() is called once.
      Returns:
      The id, -1 if not initialized.
    • use

      public void use()
      Binds this shader for use, Lazily allocates, links and compiles all ShaderObjects.
    • compile

      public void compile()
      Forces the ShaderProgram to compile and link.

      This will happen automatically when calling use(), however, it may be required to call this ahead of time in some cases.

      Be sure to only call this when you have GL context.

    • release

      public void release()
      Releases this shader.
    • onResourceManagerReload

      public void onResourceManagerReload(net.minecraft.server.packs.resources.ResourceManager resourceManager)
      Specified by:
      onResourceManagerReload in interface net.minecraft.server.packs.resources.ResourceManagerReloadListener