fix: Fix framebuffer state not being restored properly
This commit is contained in:
+1
-1
@@ -119,7 +119,7 @@ public class OpenGLConfigScreen extends AbstractScreen
|
||||
GL32.glDrawArrays(GL32.GL_TRIANGLE_FAN, 0, 4);
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
state.restore();
|
||||
//state.restore(MC_RENDER.getTargetFrameBuffer());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,28 +124,11 @@ public class GLState
|
||||
|
||||
public void restoreFrameBuffer()
|
||||
{
|
||||
// explicitly unbinding the frame buffer is necessary to prevent GL_CLEAR calls from hitting the wrong buffer
|
||||
//GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, 0);
|
||||
|
||||
// Depth buffer
|
||||
this.depthBuffer = GL32.glGenRenderbuffers();
|
||||
GL32.glBindRenderbuffer(GL32.GL_RENDERBUFFER, this.depthBuffer);
|
||||
GL32.glRenderbufferStorage(GL32.GL_RENDERBUFFER, GL32.GL_DEPTH_COMPONENT, 1920, 1080);
|
||||
|
||||
// Framebuffer
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, this.fbo[0]);
|
||||
//GL32.glFramebufferTexture(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, this.texture0, 0);
|
||||
|
||||
//for (int i = 0; i < FBO_MAX; i++)
|
||||
//{
|
||||
// int buffer = this.fbo[i];
|
||||
// if (i > 0 && buffer == 0) break;
|
||||
//
|
||||
// GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, GL32.glIsFramebuffer(buffer) ? buffer : 0);
|
||||
//}
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, 0);
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
public void restore()
|
||||
public void restore(int minecraftFramebufferId)
|
||||
{
|
||||
this.restoreFrameBuffer();
|
||||
|
||||
@@ -158,19 +141,20 @@ public class GLState
|
||||
GL32.glDisable(GL32.GL_BLEND);
|
||||
}
|
||||
|
||||
GL32.glActiveTexture(GL32.GL_TEXTURE0);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, GL32.glIsTexture(this.texture0) ? this.texture0 : 0);
|
||||
|
||||
GL32.glActiveTexture(GL32.GL_TEXTURE1);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, GL32.glIsTexture(this.texture1) ? this.texture1 : 0);
|
||||
|
||||
GL32.glActiveTexture(this.activeTextureNumber);
|
||||
//GL32.glActiveTexture(GL32.GL_TEXTURE0);
|
||||
//GL32.glBindTexture(GL32.GL_TEXTURE_2D, GL32.glIsTexture(this.texture0) ? this.texture0 : 0);
|
||||
//
|
||||
//GL32.glActiveTexture(GL32.GL_TEXTURE1);
|
||||
//GL32.glBindTexture(GL32.GL_TEXTURE_2D, GL32.glIsTexture(this.texture1) ? this.texture1 : 0);
|
||||
|
||||
//GL32.glActiveTexture(this.activeTextureNumber);
|
||||
GL32.glBindTexture(GL32.GL_TEXTURE_2D, GL32.glIsTexture(this.texture2D) ? this.texture2D : 0);
|
||||
|
||||
GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0);
|
||||
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, GL32.glIsBuffer(this.vbo) ? this.vbo : 0);
|
||||
GL32.glBindBuffer(GL32.GL_ELEMENT_ARRAY_BUFFER, GL32.glIsBuffer(this.ebo) ? this.ebo : 0);
|
||||
GL32.glUseProgram(GL32.glIsProgram(this.program) ? this.program : 0);
|
||||
|
||||
GL32.glBindVertexArray(0);
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, minecraftFramebufferId);
|
||||
//GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, GL32.glIsBuffer(this.vbo) ? this.vbo : 0);
|
||||
//GL32.glBindBuffer(GL32.GL_ELEMENT_ARRAY_BUFFER, GL32.glIsBuffer(this.ebo) ? this.ebo : 0);
|
||||
//GL32.glUseProgram(GL32.glIsProgram(this.program) ? this.program : 0);
|
||||
|
||||
//GL32.glDepthMask(this.writeToDepthBuffer);
|
||||
//GL32.glBlendFunc(this.blendSrcColor, this.blendDstColor);
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ public class DebugRenderer
|
||||
}
|
||||
|
||||
|
||||
glState.restore();
|
||||
glState.restore(MC_RENDER.getTargetFrameBuffer());
|
||||
}
|
||||
|
||||
public void renderBox(Box box)
|
||||
|
||||
@@ -233,12 +233,12 @@ public class LodRenderer
|
||||
|
||||
|
||||
|
||||
// Get DH's GL state
|
||||
// Save Minecraft's GL state so it can be restored at the end of LOD rendering
|
||||
LagSpikeCatcher drawSaveGLState = new LagSpikeCatcher();
|
||||
//GLState minecraftGlState = new GLState();
|
||||
GLState minecraftGlState = new GLState();
|
||||
if (ENABLE_DUMP_GL_STATE)
|
||||
{
|
||||
//tickLogger.debug("Saving GL state: " + minecraftGlState);
|
||||
tickLogger.debug("Saving GL state: " + minecraftGlState);
|
||||
}
|
||||
drawSaveGLState.end("drawSaveGLState");
|
||||
|
||||
@@ -299,8 +299,6 @@ public class LodRenderer
|
||||
this.shaderProgram.bind();
|
||||
}
|
||||
|
||||
GL32.glActiveTexture(GL32.GL_TEXTURE0);
|
||||
|
||||
/*---------Get required data--------*/
|
||||
int vanillaBlockRenderedDistance = MC_RENDER.getRenderDistance() * LodUtil.CHUNK_WIDTH;
|
||||
//Mat4f modelViewProjectionMatrix = RenderUtil.createCombinedModelViewProjectionMatrix(baseProjectionMatrix, baseModelViewMatrix, partialTicks);
|
||||
@@ -379,9 +377,6 @@ public class LodRenderer
|
||||
this.quadIBO.unbind();
|
||||
}
|
||||
|
||||
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, 0);
|
||||
GL32.glViewport(0,0, MC_RENDER.getTargetFrameBufferViewportWidth(), MC_RENDER.getTargetFrameBufferViewportHeight());
|
||||
|
||||
this.shaderProgram.unbind();
|
||||
|
||||
if (Config.Client.Advanced.Debugging.DebugWireframe.enableRendering.get())
|
||||
@@ -394,7 +389,11 @@ public class LodRenderer
|
||||
|
||||
//GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//minecraftGlState.restore();
|
||||
//GL32.glBindTexture(GL32.GL_TEXTURE_2D, 0);
|
||||
//GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, 0);
|
||||
//GL32.glViewport(0,0, MC_RENDER.getTargetFrameBufferViewportWidth(), MC_RENDER.getTargetFrameBufferViewportHeight());
|
||||
|
||||
minecraftGlState.restore(MC_RENDER.getTargetFrameBuffer());
|
||||
drawCleanup.end("LodDrawCleanup");
|
||||
|
||||
// end of internal LOD profiling
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ public class SSAORenderer
|
||||
SSAOApplyShader.INSTANCE.BufferTexture = this.ssaoTexture;
|
||||
SSAOApplyShader.INSTANCE.render(partialTicks);
|
||||
|
||||
state.restore();
|
||||
state.restore(MC_RENDER.getTargetFrameBuffer());
|
||||
}
|
||||
|
||||
public void free()
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ public class TestRenderer
|
||||
GL32.glDrawArrays(GL32.GL_TRIANGLE_FAN, 0, 4);
|
||||
GL32.glClear(GL32.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
state.restore();
|
||||
state.restore(MC_RENDER.getTargetFrameBuffer());
|
||||
spamLogger.incLogTries();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -58,6 +58,6 @@ public class DarkShader extends AbstractShaderRenderer
|
||||
|
||||
ScreenQuad.INSTANCE.render();
|
||||
|
||||
state.restore();
|
||||
state.restore(MC_RENDER.getTargetFrameBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -158,6 +158,6 @@ public class FogShader extends AbstractShaderRenderer
|
||||
|
||||
ScreenQuad.INSTANCE.render();
|
||||
|
||||
state.restore();
|
||||
state.restore(MC_RENDER.getTargetFrameBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user