Class CanvasProgram
java.lang.Object
net.ixdarklord.coolcatcanvas.internal.client.render.CanvasProgram
- All Implemented Interfaces:
AutoCloseable
A GLSL program linked from a vertex and a fragment shader in resources. Sources go through vanilla's preprocessor,
with namespaced imports:
#moj_import <namespace:file.glsl> reads assets/<namespace>/shaders/include/,
#moj_import "file.glsl" a path next to the importing shader. Extra #defines go right after
#version. The Position attribute is bound to location 0, where 1.20.1's vertex formats put it.
Kept out of vanilla's program caches, so its names never collide with vanilla's and reloading vanilla's shaders never frees it. Render thread only.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static CanvasProgramcompile(net.minecraft.server.packs.resources.ResourceManager resources, String name, net.minecraft.resources.ResourceLocation vertex, net.minecraft.resources.ResourceLocation fragment, List<String> defines) booleanintid()intThe uniform's location, or -1 if the program doesn't use it.name()voidvoidvoidvoidvoidvoidvoidsetVec4Array(String uniform, float[] values) Avec4[], from 4 floats per element.static voidunuse()voiduse()
-
Method Details
-
compile
public static CanvasProgram compile(net.minecraft.server.packs.resources.ResourceManager resources, String name, net.minecraft.resources.ResourceLocation vertex, net.minecraft.resources.ResourceLocation fragment, List<String> defines) throws IOException - Parameters:
vertex- the vertex shader's full path, e.g.minecraft:shaders/program/sobel.vshfragment- the fragment shader's full pathdefines- names to#definein both shaders- Throws:
IOException- if a file is missing, or a shader doesn't compile or link
-
name
-
id
public int id() -
use
public void use() -
unuse
public static void unuse() -
location
The uniform's location, or -1 if the program doesn't use it. -
has
-
setInt
-
setFloat
-
setVec2
-
setVec4
-
setVec4
-
setVec4Array
Avec4[], from 4 floats per element. -
setMat4
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-