fix debug wireframes not rendering

This commit is contained in:
James Seibel
2026-03-10 19:06:09 -05:00
parent 3d1af8f944
commit f13095875f
2 changed files with 19 additions and 9 deletions
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.common.render.openGl;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLElementBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlAbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexPointer;
@@ -51,7 +52,8 @@ public class GlDhDebugWireframeRenderer extends AbstractDebugWireframeRenderer
// rendering setup
private GlShaderProgram basicShader;
private GLElementBuffer outlineIndexBuffer;
private GLVertexBuffer vertexBuffer;
private GLElementBuffer indexBuffer;
private GlAbstractVertexAttribute va;
private boolean init = false;
@@ -128,6 +130,9 @@ public class GlDhDebugWireframeRenderer extends AbstractDebugWireframeRenderer
boxVerticesBuffer.order(ByteOrder.nativeOrder());
boxVerticesBuffer.asFloatBuffer().put(BOX_VERTICES);
boxVerticesBuffer.rewind();
this.vertexBuffer = new GLVertexBuffer(false);
this.vertexBuffer.bind();
this.vertexBuffer.uploadBuffer(boxVerticesBuffer, 8, EDhApiGpuUploadMethod.DATA, BOX_VERTICES.length * Float.BYTES);
// outline vertex indexes
@@ -135,11 +140,12 @@ public class GlDhDebugWireframeRenderer extends AbstractDebugWireframeRenderer
boxOutlineBuffer.order(ByteOrder.nativeOrder());
boxOutlineBuffer.asIntBuffer().put(BOX_OUTLINE_INDICES);
boxOutlineBuffer.rewind();
this.outlineIndexBuffer = new GLElementBuffer(false);
this.outlineIndexBuffer.uploadBuffer(boxOutlineBuffer, EDhApiGpuUploadMethod.DATA, BOX_OUTLINE_INDICES.length * Integer.BYTES, GL32.GL_STATIC_DRAW);
this.indexBuffer = new GLElementBuffer(false);
this.indexBuffer.uploadBuffer(boxOutlineBuffer, EDhApiGpuUploadMethod.DATA, BOX_OUTLINE_INDICES.length * Integer.BYTES, GL32.GL_STATIC_DRAW);
}
//endregion
@@ -150,7 +156,7 @@ public class GlDhDebugWireframeRenderer extends AbstractDebugWireframeRenderer
//region
@Override
public void renderPass(RenderParams renderParams)
public void render(RenderParams renderParams)
{
this.init();
@@ -159,14 +165,18 @@ public class GlDhDebugWireframeRenderer extends AbstractDebugWireframeRenderer
this.basicShader.bind();
this.va.bind();
this.va.bindBufferToAllBindingPoints(this.vertexBuffer.getId());
this.outlineIndexBuffer.bind();
this.indexBuffer.bind();
super.renderPass(renderParams);
super.render(renderParams);
// revert to prevent issues with the following passes
GL32.glPolygonMode(GL32.GL_FRONT_AND_BACK, GL32.GL_FILL);
}
@Override
public void render(Box box)
public void renderBox(Box box)
{
Mat4f boxTransform = Mat4f.createTranslateMatrix(box.minPos.x - this.camPosFloatThisFrame.x, box.minPos.y - this.camPosFloatThisFrame.y, box.minPos.z - this.camPosFloatThisFrame.z);
boxTransform.multiply(Mat4f.createScaleMatrix(box.maxPos.x - box.minPos.x, box.maxPos.y - box.minPos.y, box.maxPos.z - box.minPos.z));