re-add several necessary GLState calls

This commit is contained in:
James Seibel
2024-12-07 11:19:56 -06:00
parent 821fa086e6
commit a9314510fe
5 changed files with 19 additions and 7 deletions
@@ -97,7 +97,7 @@ public class GLState
this.texture2 = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
GLMC.glActiveTexture(GL32.GL_TEXTURE3);
this.texture3= GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
this.texture3 = GL32.glGetInteger(GL32.GL_TEXTURE_BINDING_2D);
GLMC.glActiveTexture(this.activeTextureNumber);
@@ -117,9 +117,7 @@ public class FadeRenderer
profiler.push("DH-RenderLevel");
// TODO try removing this now that we use GLMC
// if there are reports of things breaking, we might have to re-add it
//GLState mcState = new GLState();
GLState mcState = new GLState();
try
{
@@ -160,7 +158,8 @@ public class FadeRenderer
finally
{
// make sure we always revert to MC's state to prevent GL state corruption
//mcState.restore();
// this is especially important on MC 1.16.5 or when other rendering mods are present
mcState.restore();
}
}
@@ -20,6 +20,7 @@
package com.seibel.distanthorizons.core.render.renderer;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.render.glObject.GLState;
import com.seibel.distanthorizons.core.render.renderer.shaders.FogApplyShader;
import com.seibel.distanthorizons.core.render.renderer.shaders.FogShader;
import com.seibel.distanthorizons.core.util.math.Mat4f;
@@ -101,6 +102,9 @@ public class FogRenderer
public void render(Mat4f modelViewProjectionMatrix, float partialTicks)
{
// needed in MC 1.16.5 probably due to MC not manually setting each GL state they need before the next rendering step
GLState state = new GLState();
this.init();
// resize the framebuffer if necessary
@@ -119,6 +123,8 @@ public class FogRenderer
FogApplyShader.INSTANCE.fogTexture = this.fogTexture;
FogApplyShader.INSTANCE.render(partialTicks);
state.restore();
}
public void free()
@@ -102,8 +102,6 @@ public class SSAORenderer
public void render(Mat4f projectionMatrix, float partialTicks)
{
// TODO remove need for GLState, there are a few GL items that aren't being cleaned up correctly
// note that this doesn't affect Iris since Iris disables SSAO
GLState state = new GLState();
this.init();
@@ -20,6 +20,7 @@
package com.seibel.distanthorizons.core.render.renderer.shaders;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.render.glObject.GLState;
import com.seibel.distanthorizons.core.render.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
import com.seibel.distanthorizons.core.render.renderer.ScreenQuad;
@@ -82,6 +83,8 @@ public class DhApplyShader extends AbstractShaderRenderer
}
GLState state = new GLState();
GLMC.disableDepthTest();
GLMC.enableBlend();
@@ -100,6 +103,12 @@ public class DhApplyShader extends AbstractShaderRenderer
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, targetFrameBuffer);
ScreenQuad.INSTANCE.render();
// restore everything, except at this point the MC framebuffer should now be used instead
state.restore();
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, targetFrameBuffer);
}
}