Skip to content

Commit

Permalink
Remove no-op method for enabling depth, pass desired width/height
Browse files Browse the repository at this point in the history
  • Loading branch information
FiniteReality committed Dec 9, 2024
1 parent 1b484aa commit ef3f2f4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
10 changes: 6 additions & 4 deletions patches/com/mojang/blaze3d/pipeline/MainTarget.java.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
--- a/com/mojang/blaze3d/pipeline/MainTarget.java
+++ b/com/mojang/blaze3d/pipeline/MainTarget.java
@@ -16,7 +_,11 @@
@@ -16,8 +_,12 @@
static final MainTarget.Dimension DEFAULT_DIMENSIONS = new MainTarget.Dimension(854, 480);

public MainTarget(int p_166137_, int p_166138_) {
- super(true);
+ this(net.neoforged.neoforge.client.ClientHooks.configureMainRenderTarget(), p_166137_, p_166138_);
- this.createFrameBuffer(p_166137_, p_166138_);
+ this(net.neoforged.neoforge.client.ClientHooks.configureMainRenderTarget(true, p_166137_, p_166138_));
+ }
+
+ private MainTarget(net.neoforged.neoforge.client.event.ConfigureMainRenderTargetEvent e, int p_166137_, int p_166138_) {
+ private MainTarget(net.neoforged.neoforge.client.event.ConfigureMainRenderTargetEvent e) {
+ super(e.useDepth(), e.useStencil());
this.createFrameBuffer(p_166137_, p_166138_);
+ this.createFrameBuffer(e.width(), e.height());
}

private void createFrameBuffer(int p_166142_, int p_166143_) {
@@ -30,13 +_,24 @@
GlStateManager._texParameter(3553, 10242, 33071);
GlStateManager._texParameter(3553, 10243, 33071);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/neoforged/neoforge/client/ClientHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,8 @@ public static Map<ResourceLocation, ResourceLocation> gatherMaterialAtlases(Map<
return Map.copyOf(vanillaAtlases);
}

public static ConfigureMainRenderTargetEvent configureMainRenderTarget() {
var e = new ConfigureMainRenderTargetEvent();
public static ConfigureMainRenderTargetEvent configureMainRenderTarget(boolean useDepth, int width, int height) {
var e = new ConfigureMainRenderTargetEvent(useDepth, width, height);
ModLoader.postEvent(e);
return e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@
* This event is fired on the mod-speciffic event bus, only on the {@linkplain LogicalSide#CLIENT logical client}.
*/
public class ConfigureMainRenderTargetEvent extends Event implements IModBusEvent {
private boolean useDepth;
private final boolean useDepth;
private boolean useStencil;

private final int width;
private final int height;

@ApiStatus.Internal
public ConfigureMainRenderTargetEvent() {
this.useDepth = true;
public ConfigureMainRenderTargetEvent(boolean useDepth, int width, int height) {
this.useDepth = useDepth;
this.useStencil = false;

this.width = width;
this.height = height;
}

/**
Expand All @@ -51,13 +57,21 @@ public boolean useStencil() {
}

/**
* Enable the depth buffer for the main render target.
* Returns the preferred width of the framebuffer.
*
* @return <code>this</code>, for method chaining.
* @return The width, in pixels, to attempt to use for the framebuffer.
*/
public ConfigureMainRenderTargetEvent enableDepth() {
this.useDepth = true;
return this;
public int width() {
return this.width;
}

/**
* Returns the preferred height of the framebuffer.
*
* @return The height, in pixels, to attempt to use for the framebuffer.
*/
public int height() {
return this.height;
}

/**
Expand Down

0 comments on commit ef3f2f4

Please sign in to comment.