Class DirectShaderCompiler

java.lang.Object
foundry.veil.impl.client.render.shader.DirectShaderCompiler
All Implemented Interfaces:
ShaderCompiler, AutoCloseable, org.lwjgl.system.NativeResource
Direct Known Subclasses:
CachedShaderCompiler

@Internal public class DirectShaderCompiler extends Object implements ShaderCompiler
Creates a new shader and compiles each time compile(Context, int, ProgramDefinition.SourceType, String) is called. This should only be used for compiling single shaders.
  • Constructor Details

    • DirectShaderCompiler

      public DirectShaderCompiler(@Nullable @Nullable net.minecraft.server.packs.resources.ResourceProvider provider)
  • Method Details

    • compile

      public CompiledShader compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, net.minecraft.resources.ResourceLocation id) throws IOException, ShaderException
      Description copied from interface: ShaderCompiler
      Creates a new shader and attempts to attach sources read from file to it. The sources are read from The shader will automatically be deleted at some point in the future.
      Specified by:
      compile in interface ShaderCompiler
      Parameters:
      context - The context for compiling the shader
      type - The type of shader to create
      id - The id of the shader to attach
      Returns:
      A new shader that can be attached to programs
      Throws:
      IOException - If the file could not be found.
      ShaderException - If an error occurs compiling the shader
    • compile

      public CompiledShader compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, String source) throws IOException, ShaderException
      Description copied from interface: ShaderCompiler
      Creates a new shader and attempts to attach the specified sources to it. The shader will automatically be deleted at some point in the future.
      Specified by:
      compile in interface ShaderCompiler
      Parameters:
      context - The context for compiling the shader
      type - The type of shader to create
      source - The source of the shader to attach
      Returns:
      A new shader that can be attached to programs
      Throws:
      IOException - If an error occurs processing the shader source
      ShaderException - If an error occurs compiling the shader
    • addPreprocessor

      public ShaderCompiler addPreprocessor(ShaderPreProcessor processor, boolean modifyImports)
      Description copied from interface: ShaderCompiler
      Adds the specified pre-processor to the end of the stack.
      Specified by:
      addPreprocessor in interface ShaderCompiler
      Parameters:
      processor - The processor to add
      modifyImports - Whether the processor will also be run on imports
    • addDefaultProcessors

      public ShaderCompiler addDefaultProcessors()
      Description copied from interface: ShaderCompiler
      Adds the default preprocessors for shader code.
      Specified by:
      addDefaultProcessors in interface ShaderCompiler
    • free

      public void free()
      Specified by:
      free in interface org.lwjgl.system.NativeResource