mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-16 10:45:09 +00:00
114 lines
3.3 KiB
Java
114 lines
3.3 KiB
Java
package net.coderbot.iris.layer;
|
|
|
|
import net.coderbot.iris.Iris;
|
|
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
|
|
import net.coderbot.iris.gl.shader.ProgramCreator;
|
|
import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
|
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
|
import org.lwjgl.opengl.GL20;
|
|
|
|
public class GbufferPrograms {
|
|
private static boolean entities;
|
|
private static boolean blockEntities;
|
|
private static boolean outline;
|
|
|
|
private static void checkReentrancy() {
|
|
if (entities || blockEntities || outline) {
|
|
throw new IllegalStateException("GbufferPrograms in weird state, tried to call begin function when entities = "
|
|
+ entities + ", blockEntities = " + blockEntities + ", outline = " + outline);
|
|
}
|
|
}
|
|
|
|
public static void beginEntities() {
|
|
checkReentrancy();
|
|
setPhase(WorldRenderingPhase.ENTITIES);
|
|
setBlockEntityDefaults();
|
|
entities = true;
|
|
}
|
|
|
|
public static void endEntities() {
|
|
if (!entities) {
|
|
throw new IllegalStateException("GbufferPrograms in weird state, tried to call endEntities when entities = false");
|
|
}
|
|
|
|
setPhase(WorldRenderingPhase.NONE);
|
|
entities = false;
|
|
}
|
|
|
|
public static void beginOutline() {
|
|
checkReentrancy();
|
|
setPhase(WorldRenderingPhase.OUTLINE);
|
|
outline = true;
|
|
}
|
|
|
|
public static void endOutline() {
|
|
if (!outline) {
|
|
throw new IllegalStateException("GbufferPrograms in weird state, tried to call endOutline when outline = false");
|
|
}
|
|
|
|
setPhase(WorldRenderingPhase.NONE);
|
|
outline = false;
|
|
}
|
|
|
|
public static void beginBlockEntities() {
|
|
checkReentrancy();
|
|
setPhase(WorldRenderingPhase.BLOCK_ENTITIES);
|
|
setBlockEntityDefaults();
|
|
blockEntities = true;
|
|
}
|
|
|
|
public static void endBlockEntities() {
|
|
if (!blockEntities) {
|
|
throw new IllegalStateException("GbufferPrograms in weird state, tried to call endBlockEntities when blockEntities = false");
|
|
}
|
|
|
|
setPhase(WorldRenderingPhase.NONE);
|
|
blockEntities = false;
|
|
}
|
|
|
|
public static void setBlockEntityDefaults() {
|
|
GL20.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
|
|
GL20.glVertexAttrib2f(ProgramCreator.MC_MID_TEX_COORD, 0.5f, 0.5f);
|
|
GL20.glVertexAttrib4f(ProgramCreator.AT_TANGENT, 1.0f, 0.0f, 0.0f, 1.0f);
|
|
GL20.glVertexAttrib4f(ProgramCreator.AT_MIDBLOCK, 0.0f, 0.0f, 0.0f, 0.0f);
|
|
}
|
|
|
|
public static WorldRenderingPhase getCurrentPhase() {
|
|
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
|
|
|
if (pipeline != null) {
|
|
return pipeline.getPhase();
|
|
} else {
|
|
return WorldRenderingPhase.NONE;
|
|
}
|
|
}
|
|
|
|
private static void setPhase(WorldRenderingPhase phase) {
|
|
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
|
|
|
if (pipeline != null) {
|
|
pipeline.setPhase(phase);
|
|
}
|
|
}
|
|
|
|
public static void setOverridePhase(WorldRenderingPhase phase) {
|
|
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
|
|
|
|
if (pipeline != null) {
|
|
pipeline.setOverridePhase(phase);
|
|
}
|
|
}
|
|
|
|
public static void setupSpecialRenderCondition(SpecialCondition override) {
|
|
Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setSpecialCondition(override));
|
|
}
|
|
|
|
public static void teardownSpecialRenderCondition() {
|
|
Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setSpecialCondition(null));
|
|
}
|
|
|
|
public static void init() {
|
|
// Empty initializer to run static
|
|
}
|
|
}
|