Restore texture and depthFunc in GlDhMetaRenderer instead of in CleanroomRenderMixin
This commit is contained in:
+8
-21
@@ -23,14 +23,10 @@ import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.util.math.DhMat4f;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -48,34 +44,25 @@ public class MixinRenderGlobal
|
||||
if (blockLayerIn == BlockRenderLayer.SOLID)
|
||||
{
|
||||
float[] mcProjMatrixRaw = new float[16];
|
||||
GL11.glGetFloatv(GL11.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
||||
GL32.glGetFloatv(GL32.GL_PROJECTION_MATRIX, mcProjMatrixRaw);
|
||||
ClientApi.RENDER_STATE.mcProjectionMatrix = new DhMat4f(mcProjMatrixRaw);
|
||||
ClientApi.RENDER_STATE.mcProjectionMatrix.transpose();
|
||||
|
||||
float[] mcModelViewRaw = new float[16];
|
||||
GL11.glGetFloatv(GL11.GL_MODELVIEW_MATRIX, mcModelViewRaw);
|
||||
GL32.glGetFloatv(GL32.GL_MODELVIEW_MATRIX, mcModelViewRaw);
|
||||
ClientApi.RENDER_STATE.mcModelViewMatrix = new DhMat4f(mcModelViewRaw);
|
||||
ClientApi.RENDER_STATE.mcModelViewMatrix.transpose();
|
||||
|
||||
ClientApi.RENDER_STATE.partialTickTime = (float) partialTicks;
|
||||
ClientApi.RENDER_STATE.clientLevelWrapper = ClientLevelWrapper.getWrapperIfDifferent(ClientApi.RENDER_STATE.clientLevelWrapper, this.world);
|
||||
|
||||
int blendSrc = GL11.glGetInteger(GL11.GL_BLEND_SRC);
|
||||
int blendDst = GL11.glGetInteger(GL11.GL_BLEND_DST);
|
||||
int boundTexture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
|
||||
ClientApi.INSTANCE.renderLods();
|
||||
|
||||
GL30.glBindVertexArray(0);
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
GL20.glUseProgram(0);
|
||||
|
||||
//Restore vanilla states
|
||||
GlStateManager.depthFunc(GL11.GL_LEQUAL);
|
||||
GlStateManager.bindTexture(boundTexture);
|
||||
GlStateManager.tryBlendFuncSeparate(blendSrc, blendDst, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
|
||||
//Some 1.12.2 rendering mods breaks if we don't unbind buffers
|
||||
GL32.glBindVertexArray(0);
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||
GL32.glBindBuffer(GL32.GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
GL32.glUseProgram(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-3
@@ -71,6 +71,11 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
||||
/** used in case there's an API override */
|
||||
public IDhApiShaderProgram shaderProgramForThisFrame;
|
||||
|
||||
/** Older MC versions assume GL state is unchanged, so we must restore it after DH rendering */
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private int previousBoundTextureId;
|
||||
private int previousDepthFunc;
|
||||
#endif
|
||||
|
||||
|
||||
//============//
|
||||
@@ -113,6 +118,11 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
||||
DhApiRenderParam renderEventParam,
|
||||
boolean firstPass)
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.previousBoundTextureId = GLMC.getActiveTexture();
|
||||
this.previousDepthFunc = GLMC.getActiveDepthFunc();
|
||||
#endif
|
||||
|
||||
//===================//
|
||||
// framebuffer setup //
|
||||
//===================//
|
||||
@@ -357,7 +367,9 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GLMC.glDepthFunc(previousDepthFunc);
|
||||
#endif
|
||||
this.unbindLightmap();
|
||||
this.shaderProgramForThisFrame.unbind();
|
||||
}
|
||||
@@ -455,8 +467,12 @@ public class GlDhMetaRenderer implements IDhMetaRenderer
|
||||
|
||||
public void unbindLightmap()
|
||||
{
|
||||
// strange that we don't call "glActiveTexture" here but since it's working James isn't going to change it right now (2026-03-10)
|
||||
GLMC.glBindTexture(0);
|
||||
// strange that we don't call "glActiveTexture" here but since it's working James isn't going to change it right now (2026-03-10)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GLMC.glBindTexture(previousBoundTextureId);
|
||||
#else
|
||||
GLMC.glBindTexture(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
+1
@@ -126,6 +126,7 @@ public class MinecraftGLWrapper
|
||||
GlStateManager._depthFunc(func);
|
||||
#endif
|
||||
}
|
||||
public int getActiveDepthFunc() { return GL32.glGetInteger(GL32.GL_DEPTH_FUNC); }
|
||||
|
||||
/** @see GL32#glDepthMask(boolean) */
|
||||
public void enableDepthMask()
|
||||
|
||||
Reference in New Issue
Block a user