remove unused frame buffer

This commit is contained in:
NULL511
2023-09-09 02:48:57 -04:00
parent 36092008ef
commit a21edfeed6
2 changed files with 62 additions and 61 deletions
@@ -48,15 +48,15 @@ public abstract class AbstractShaderRenderer
};
protected final ShaderProgram shader;
protected final ShaderProgram applyShader;
//protected final ShaderProgram applyShader;
public GLVertexBuffer boxBuffer;
protected VertexAttribute va;
boolean init = false;
private int width = -1;
private int height = -1;
private int framebuffer = -1;
private int shaderTexture = -1;
//private int width = -1;
//private int height = -1;
//private int framebuffer = -1;
//private int shaderTexture = -1;
protected AbstractShaderRenderer(ShaderProgram shader)
@@ -67,7 +67,7 @@ public abstract class AbstractShaderRenderer
protected AbstractShaderRenderer(ShaderProgram shader, ShaderProgram applyShader)
{
this.shader = shader;
this.applyShader = applyShader;
//this.applyShader = applyShader;
}
private void init()
@@ -92,16 +92,16 @@ public abstract class AbstractShaderRenderer
{
va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
}
;
/** Overwrite this to apply uniforms to the shader */
void setShaderUniforms(float partialTicks) { }
;
/** Overwrite this to apply uniforms to the apply shader */
void setApplyShaderUniforms(float partialTicks) { }
;
///** Overwrite this to apply uniforms to the apply shader */
//void setApplyShaderUniforms(float partialTicks) { }
/** Overwrite if you need to run something on runtime */
void postInit() { }
;
// TODO pass in the Model View and Projection Matrices along with the ticks
public void render(float partialTicks)
@@ -111,16 +111,17 @@ public abstract class AbstractShaderRenderer
int width = MC_RENDER.getTargetFrameBufferViewportWidth();
int height = MC_RENDER.getTargetFrameBufferViewportHeight();
if (this.width != width || this.height != height)
{
this.width = width;
this.height = height;
this.createFramebuffer(width, height);
}
// if (this.width != width || this.height != height)
// {
// this.width = width;
// this.height = height;
// this.createFramebuffer(width, height);
// }
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, framebuffer);
//GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, framebuffer);
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
GL32.glViewport(0, 0, width, height);
GL32.glDisable(GL32.GL_DEPTH_TEST);
GL32.glDisable(GL32.GL_BLEND);
@@ -135,19 +136,19 @@ public abstract class AbstractShaderRenderer
GL32.glActiveTexture(GL32.GL_TEXTURE0);
GL32.glBindTexture(GL32.GL_TEXTURE_2D, MC_RENDER.getDepthTextureId());
GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, 6);
//GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, 6);
if (applyShader != null)
{
applyShader.bind();
this.setApplyShaderUniforms(partialTicks);
}
// if (applyShader != null)
// {
// applyShader.bind();
// this.setApplyShaderUniforms(partialTicks);
// }
GL32.glEnable(GL11.GL_BLEND);
GL32.glBlendFunc(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA);
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
GL32.glActiveTexture(GL32.GL_TEXTURE0);
GL32.glBindTexture(GL32.GL_TEXTURE_2D, shaderTexture);
//GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, MC_RENDER.getTargetFrameBuffer());
//GL32.glActiveTexture(GL32.GL_TEXTURE0);
//GL32.glBindTexture(GL32.GL_TEXTURE_2D, shaderTexture);
GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, 6);
@@ -158,30 +159,30 @@ public abstract class AbstractShaderRenderer
}
private void createFramebuffer(int width, int height)
{
if (this.framebuffer != -1)
{
GL32.glDeleteFramebuffers(this.framebuffer);
this.framebuffer = -1;
}
if (this.shaderTexture != -1)
{
GL32.glDeleteTextures(this.shaderTexture);
this.shaderTexture = -1;
}
this.framebuffer = GL32.glGenFramebuffers();
GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, this.framebuffer);
this.shaderTexture = GL32.glGenTextures();
GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.shaderTexture);
GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, GL32.GL_RED, width, height, 0, GL32.GL_RED, GL32.GL_FLOAT, (ByteBuffer) null);
GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MIN_FILTER, GL32.GL_NEAREST);
GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MAG_FILTER, GL32.GL_NEAREST);
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.shaderTexture, 0);
}
// private void createFramebuffer(int width, int height)
// {
// if (this.framebuffer != -1)
// {
// GL32.glDeleteFramebuffers(this.framebuffer);
// this.framebuffer = -1;
// }
//
// if (this.shaderTexture != -1)
// {
// GL32.glDeleteTextures(this.shaderTexture);
// this.shaderTexture = -1;
// }
//
// this.framebuffer = GL32.glGenFramebuffers();
// GL32.glBindFramebuffer(GL32.GL_FRAMEBUFFER, this.framebuffer);
//
// this.shaderTexture = GL32.glGenTextures();
// GL32.glBindTexture(GL32.GL_TEXTURE_2D, this.shaderTexture);
// GL32.glTexImage2D(GL32.GL_TEXTURE_2D, 0, GL32.GL_RED, width, height, 0, GL32.GL_RED, GL32.GL_FLOAT, (ByteBuffer) null);
// GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MIN_FILTER, GL32.GL_NEAREST);
// GL32.glTexParameteri(GL32.GL_TEXTURE_2D, GL32.GL_TEXTURE_MAG_FILTER, GL32.GL_NEAREST);
// GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.shaderTexture, 0);
// }
private void createBuffer()
{
@@ -197,10 +198,10 @@ public abstract class AbstractShaderRenderer
public void free()
{
this.shader.free();
if (this.applyShader != null)
{
this.applyShader.free();
}
// if (this.applyShader != null)
// {
// this.applyShader.free();
// }
}
}
@@ -80,11 +80,11 @@ public class FogShader extends AbstractShaderRenderer
this.nearFogLengthUniform = this.shader.tryGetUniformLocation("nearFogLength");
}
@Override
void setVertexAttributes()
{
this.va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
}
// @Override
// void setVertexAttributes()
// {
// this.va.setVertexAttribute(0, 0, VertexAttribute.VertexPointer.addVec2Pointer(false));
// }
@Override
void setShaderUniforms(float partialTicks)