mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 00:07:45 +00:00
Backport of patch #6543 to enable Stencil buffer in net.minecraft.client.shader.Framebuffer. Closes #6751
This commit is contained in:
1 parent
a401a9b9d0
commit
23f00d26bb
3 files changed
+92
No files matched your search
@@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/client/shader/Framebuffer.java
|
||||
+++ b/net/minecraft/client/shader/Framebuffer.java
|
||||
@@ -95,8 +95,14 @@
|
||||
GLX.glFramebufferTexture2D(GLX.GL_FRAMEBUFFER, GLX.GL_COLOR_ATTACHMENT0, 3553, this.field_147617_g, 0);
|
||||
if (this.field_147619_e) {
|
||||
GLX.glBindRenderbuffer(GLX.GL_RENDERBUFFER, this.field_147624_h);
|
||||
+ if (!stencilEnabled) {
|
||||
GLX.glRenderbufferStorage(GLX.GL_RENDERBUFFER, 33190, this.field_147622_a, this.field_147620_b);
|
||||
GLX.glFramebufferRenderbuffer(GLX.GL_FRAMEBUFFER, GLX.GL_DEPTH_ATTACHMENT, GLX.GL_RENDERBUFFER, this.field_147624_h);
|
||||
+ } else {
|
||||
+ GLX.glRenderbufferStorage(GLX.GL_RENDERBUFFER, org.lwjgl.opengl.EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, this.field_147622_a, this.field_147620_b);
|
||||
+ GLX.glFramebufferRenderbuffer(GLX.GL_FRAMEBUFFER, GLX.GL_DEPTH_ATTACHMENT, GLX.GL_RENDERBUFFER, this.field_147624_h);
|
||||
+ GLX.glFramebufferRenderbuffer(GLX.GL_FRAMEBUFFER, org.lwjgl.opengl.EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, GLX.GL_RENDERBUFFER, this.field_147624_h);
|
||||
+ }
|
||||
}
|
||||
|
||||
this.func_147611_b();
|
||||
@@ -229,4 +235,29 @@
|
||||
GlStateManager.clear(i, p_216493_1_);
|
||||
this.func_147609_e();
|
||||
}
|
||||
+
|
||||
+ /*================================ FORGE START ================================================*/
|
||||
+ private boolean stencilEnabled = false;
|
||||
+ /**
|
||||
+ * Attempts to enable 8 bits of stencil buffer on this FrameBuffer.
|
||||
+ * Modders must call this directly to set things up.
|
||||
+ * This is to prevent the default cause where graphics cards do not support stencil bits.
|
||||
+ * <b>Make sure to call this on the main render thread!</b>
|
||||
+ */
|
||||
+ public void enableStencil()
|
||||
+ {
|
||||
+ if(stencilEnabled) return;
|
||||
+ stencilEnabled = true;
|
||||
+ this.func_216491_a(field_147621_c, field_147618_d, net.minecraft.client.Minecraft.field_142025_a);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns whether or not this FBO has been successfully initialised with stencil bits.
|
||||
+ * If not, and a modder wishes it to be, they must call enableStencil.
|
||||
+ */
|
||||
+ public boolean isStencilEnabled()
|
||||
+ {
|
||||
+ return this.stencilEnabled;
|
||||
+ }
|
||||
+ /*================================ FORGE END ================================================*/
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.testmods;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Mod(StencilTest.MODID)
|
||||
public class StencilTest {
|
||||
|
||||
public static final String MODID = "stencil_backport_test";
|
||||
|
||||
public StencilTest() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modEventBus.addListener(this::clientSetup);
|
||||
}
|
||||
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
DeferredWorkQueue.runLater(() -> Minecraft.getInstance().getFramebuffer().enableStencil());
|
||||
}
|
||||
}
|
||||
@@ -69,3 +69,5 @@ loaderVersion="[28,)"
|
||||
modId="custom_plant_type_test"
|
||||
[[mods]]
|
||||
modId="forgedebugmultilayermodel"
|
||||
[[mods]]
|
||||
modId="stencil_backport_test"
|
||||
Reference in new issue
Block a user