From d58897d59abac7e264e779062e080055a58e5c2b Mon Sep 17 00:00:00 2001 From: JozsefA Date: Thu, 20 May 2021 17:59:26 -0700 Subject: [PATCH] Nothing in particular --- ...MultiProgram.java => FogMultiProgram.java} | 20 +++---------------- .../flywheel/backend/core/WorldContext.java | 4 ++-- .../core/shader/ExtensibleGlProgram.java | 6 +++++- .../backend/gl/shader/ShaderSpecLoader.java | 6 ------ .../render/ContraptionRenderDispatcher.java | 6 +++--- 5 files changed, 13 insertions(+), 29 deletions(-) rename src/main/java/com/jozufozu/flywheel/backend/core/{WorldMultiProgram.java => FogMultiProgram.java} (71%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java similarity index 71% rename from src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java rename to src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java index dfc822a9a..babe5d039 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldMultiProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/FogMultiProgram.java @@ -1,9 +1,7 @@ package com.jozufozu.flywheel.backend.core; -import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; -import java.util.List; import java.util.Map; import com.jozufozu.flywheel.backend.ShaderContext; @@ -17,14 +15,12 @@ import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram; import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader; import com.jozufozu.flywheel.backend.loading.Program; -public class WorldMultiProgram

implements IMultiProgram

{ +public class FogMultiProgram

implements IMultiProgram

{ private final Map programs; - private final List

debugPrograms; - public WorldMultiProgram(Map programs, List

debugPrograms) { + public FogMultiProgram(Map programs) { this.programs = programs; - this.debugPrograms = debugPrograms; } @Override @@ -47,16 +43,6 @@ public class WorldMultiProgram

implements IMultiProgram

@Override public IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec) { - List

debugModes = new ArrayList<>(2); - - String[] modes = new String[]{"NORMAL_DEBUG", "RAINBOW_DEBUG"}; - - for (String mode : modes) { - Program builder = ctx.loadProgram(loader, spec, Collections.singletonList(mode)); - - debugModes.add(factory.create(builder, null)); - } - Map programs = new EnumMap<>(GlFogMode.class); for (GlFogMode fogMode : GlFogMode.values()) { @@ -65,7 +51,7 @@ public class WorldMultiProgram

implements IMultiProgram

programs.put(fogMode, factory.create(builder, Collections.singletonList(fogMode))); } - return new WorldMultiProgram<>(programs, debugModes); + return new FogMultiProgram<>(programs); } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java index a68515382..0bf84e0c9 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/WorldContext.java @@ -32,8 +32,8 @@ public class WorldContext

extends ShaderContext

{ private static final String declaration = "#flwbuiltins"; private static final Pattern builtinPattern = Pattern.compile(declaration); - public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new WorldMultiProgram.SpecLoader<>(WorldProgram::new)); - public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new WorldMultiProgram.SpecLoader<>(CrumblingProgram::new)); + public static final WorldContext INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new FogMultiProgram.SpecLoader<>(WorldProgram::new)); + public static final WorldContext CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new FogMultiProgram.SpecLoader<>(CrumblingProgram::new)); protected ProgramTemplate template; protected final ResourceLocation name; diff --git a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java index f2e6423a0..701122ea6 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java +++ b/src/main/java/com/jozufozu/flywheel/backend/core/shader/ExtensibleGlProgram.java @@ -57,6 +57,10 @@ public class ExtensibleGlProgram extends GlProgram { public interface Factory

{ @Nonnull - P create(Program program, @Nullable List fogFactory); + P create(Program program, @Nullable List extensions); + + default P create(Program program) { + return create(program, null); + } } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java index 1fafd1346..51ed1d8c1 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/shader/ShaderSpecLoader.java @@ -6,11 +6,5 @@ import com.jozufozu.flywheel.backend.core.shader.ProgramSpec; public interface ShaderSpecLoader

{ - /** - * @param loader - * @param ctx - * @param spec - * @return - */ IMultiProgram

create(ShaderLoader loader, ShaderContext

ctx, ProgramSpec spec); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index 8add8c3b1..5eb5331f7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -15,8 +15,8 @@ import java.util.stream.Stream; import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.backend.Backend; +import com.jozufozu.flywheel.backend.core.FogMultiProgram; import com.jozufozu.flywheel.backend.core.WorldContext; -import com.jozufozu.flywheel.backend.core.WorldMultiProgram; import com.jozufozu.flywheel.backend.loading.ModelTemplate; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllMovementBehaviours; @@ -71,8 +71,8 @@ public class ContraptionRenderDispatcher { public static final Compartment> CONTRAPTION = new Compartment<>(); private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption"); - public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); - public static final WorldContext TILES = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new)); + public static final WorldContext STRUCTURE = new WorldContext<>(ctxRoot, new FogMultiProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new); + public static final WorldContext TILES = new WorldContext<>(ctxRoot, new FogMultiProgram.SpecLoader<>(ContraptionProgram::new)); public static void tick() { if (Minecraft.getInstance().isGamePaused()) return;