Skip to content

Commit

Permalink
Adjust Shader API operations and naming's
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon-Seeker committed Oct 20, 2024
1 parent 9aa2ee0 commit f576dcd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/wispforest/owo/client/OwoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void onInitializeClient() {
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new NinePatchTexture.MetadataLoader());
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override public Identifier getFabricId() { return Identifier.of("owo", "after_shader_load"); }
@Override public void reload(ResourceManager manager) { GlProgram.forEachProgram(Runnable::run); }
@Override public void reload(ResourceManager manager) { GlProgram.loadAndSetupPrograms(); }
});

final var renderdocPath = System.getProperty("owo.renderdocPath");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
public interface ShaderProgramAccessor {

@Accessor("uniformsByName")
Map<String, GlUniform> owo$getLoadedUniforms();
Map<String, GlUniform> owo$getUniformsByName();

}
10 changes: 3 additions & 7 deletions src/main/java/io/wispforest/owo/shader/GlProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
import net.minecraft.client.gl.*;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.resource.ResourceFactory;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

/**
* A simple wrapper around Minecraft's built-in core shaders. In order to load and use
Expand Down Expand Up @@ -86,11 +82,11 @@ protected void setup() {}
* the value of the uniform, or {@code null} if no such uniform exists
*/
protected @Nullable GlUniform findUniform(String name) {
return ((ShaderProgramAccessor) this.backingProgram).owo$getLoadedUniforms().get(name);
return ((ShaderProgramAccessor) this.backingProgram).owo$getUniformsByName().get(name);
}

@ApiStatus.Internal
public static void forEachProgram(Consumer<Runnable> loader) {
REGISTERED_PROGRAMS.forEach(loader);
public static void loadAndSetupPrograms() {
REGISTERED_PROGRAMS.forEach(Runnable::run);
}
}

0 comments on commit f576dcd

Please sign in to comment.