Interface ShaderCompiler
- All Superinterfaces:
AutoCloseable,org.lwjgl.system.NativeResource
- All Known Implementing Classes:
CachedShaderCompiler,DirectShaderCompiler
public interface ShaderCompiler
extends org.lwjgl.system.NativeResource
Creates and compiles shaders for shader programs.
Create a compiler using direct(ResourceProvider) for a single program,
or cached(ResourceProvider) if compiling multiple.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordContext for compiling shaders and programs. -
Method Summary
Modifier and TypeMethodDescriptionAdds the default preprocessors for shader code.default ShaderCompileraddPreprocessor(ShaderPreProcessor processor) Adds the specified pre-processor to the end of the stack.addPreprocessor(ShaderPreProcessor processor, boolean modifyImports) Adds the specified pre-processor to the end of the stack.static ShaderCompilercached(@Nullable net.minecraft.server.packs.resources.ResourceProvider provider) Constructs a shader compiler that caches duplicate shader sources.compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, String source) Creates a new shader and attempts to attach the specified sources to it.compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, net.minecraft.resources.ResourceLocation id) Creates a new shader and attempts to attach sources read from file to it.static ShaderCompilerdirect(@Nullable net.minecraft.server.packs.resources.ResourceProvider provider) Constructs a shader compiler that creates a new shader for each requested type.Methods inherited from interface org.lwjgl.system.NativeResource
close, free
-
Method Details
-
compile
CompiledShader compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, net.minecraft.resources.ResourceLocation id) throws IOException, ShaderException 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.- Parameters:
context- The context for compiling the shadertype- The type of shader to createid- 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
CompiledShader compile(ShaderCompiler.Context context, int type, ProgramDefinition.SourceType sourceType, String source) throws IOException, ShaderException 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.- Parameters:
context- The context for compiling the shadertype- The type of shader to createsource- 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 sourceShaderException- If an error occurs compiling the shader
-
addPreprocessor
Adds the specified pre-processor to the end of the stack.- Parameters:
processor- The processor to addmodifyImports- Whether the processor will also be run on imports
-
addPreprocessor
Adds the specified pre-processor to the end of the stack.- Parameters:
processor- The processor to add
-
addDefaultProcessors
ShaderCompiler addDefaultProcessors()Adds the default preprocessors for shader code. -
direct
static ShaderCompiler direct(@Nullable @Nullable net.minecraft.server.packs.resources.ResourceProvider provider) Constructs a shader compiler that creates a new shader for each requested type.- Parameters:
provider- The source of shader files- Returns:
- shader compiler
-
cached
static ShaderCompiler cached(@Nullable @Nullable net.minecraft.server.packs.resources.ResourceProvider provider) Constructs a shader compiler that caches duplicate shader sources.- Parameters:
provider- The source of shader files- Returns:
- cached shader compiler
-