Fix a few Legacy GL issues

This commit is contained in:
James Seibel
2026-03-13 07:42:41 -05:00
parent 99703d65df
commit 0ffefaa8c1
2 changed files with 29 additions and 23 deletions
@@ -2,6 +2,7 @@ package com.seibel.distanthorizons.common.render.openGl;
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectRenderer;
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDummyUniformData;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fade.GlDhFarFadeRenderer;
@@ -44,6 +45,15 @@ public class GlDhRenderApiDefinition extends AbstractDhRenderApiDefinition
@Override public IDhVanillaFadeRenderer getVanillaFadeRenderer() { return GlVanillaFadeRenderer.INSTANCE; }
@Override public IDhTestTriangleRenderer getTestTriangleRenderer() { return GlTestTriangleRenderer.INSTANCE; }
@Override
public void bindRenderers()
{
try (GLState state = new GLState())
{
super.bindRenderers();
}
}
//endregion
@@ -1,22 +1,3 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program 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 3.
*
* This program 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 program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.openGl;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShaderProgram;
@@ -55,7 +36,7 @@ import org.lwjgl.opengl.GL32;
/**
* Handles rendering the normal LOD terrain.
* @see LodQuadBuilder
* @see LodQuadBuilder
*/
public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiShaderProgram, IDhTerrainRenderer
{
@@ -69,9 +50,10 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
private boolean init = false;
public GlQuadElementBuffer quadIBO = null;
public final GlAbstractVertexAttribute vao;
public GlAbstractVertexAttribute vao;
// uniforms //
//region
@@ -113,6 +95,15 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
"assets/distanthorizons/shaders/shared/gl/flat_shaded.frag",
new String[]{"vPosition", "color"}
);
}
public void init()
{
if (this.init)
{
return;
}
this.uCombinedMatrix = this.getUniformLocation("uCombinedMatrix");
this.uModelOffset = this.getUniformLocation("uModelOffset");
@@ -165,6 +156,10 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
throw e;
}
// unbinding here is necessary to fix an issue when running on Legacy GL
this.vao.unbind();
this.init = true;
}
//endregion
@@ -179,6 +174,7 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
@Override
public void bind()
{
this.init();
super.bind();
this.vao.bind();
}
@@ -206,7 +202,7 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
combinedMatrix.multiply(renderParameters.dhModelViewMatrix);
super.bind();
// uniforms
this.setUniform(this.uCombinedMatrix, combinedMatrix);
this.setUniform(this.uMircoOffset, 0.01f); // 0.01 block offset
@@ -384,4 +380,4 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
}
}