Renderer: Fixed and enabled GL43+ Vertex Attribute

Not sure if it's faster currently. It should in theory be.
This commit is contained in:
tom lee
2021-12-15 17:15:54 +08:00
parent a295dcafd4
commit 3913b955be
2 changed files with 9 additions and 9 deletions
@@ -92,9 +92,9 @@ public class LodRenderProgram extends ShaderProgram {
// TODO: Add better use of the LODFormat thing
int vertexByteCount = LodUtil.LOD_VERTEX_FORMAT.getByteSize();
//if (GLProxy.getInstance().openGL43VertexAttributeSupported)
// vao = new VertexAttributePostGL43();
//else
if (GLProxy.getInstance().openGL43VertexAttributeSupported)
vao = new VertexAttributePostGL43();
else
vao = new VertexAttributePreGL43();
vao.bind();
vao.setVertexAttribute(0, posAttrib, VertexAttribute.VertexPointer.addVec3Pointer(false));
@@ -2,10 +2,10 @@ package com.seibel.lod.core.render.objects;
import java.util.ArrayList;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL43;
import com.seibel.lod.core.api.ClientApi;
import com.seibel.lod.core.render.objects.VertexAttribute.VertexPointer;
// In OpenGL 4.3 and later, Vertex Attribute got a make-over.
// Now it provides support for buffer binding points natively.
@@ -19,8 +19,6 @@ public final class VertexAttributePostGL43 extends VertexAttribute {
int numberOfBindingPoints = 0;
int strideSize = 0;
ArrayList<VertexPointer> pointersBuilder;
public VertexAttributePostGL43() {
super();
@@ -50,11 +48,12 @@ public final class VertexAttributePostGL43 extends VertexAttribute {
@Override
public void setVertexAttribute(int bindingPoint, int attributeIndex, VertexPointer attribute) {
GL43.glVertexAttribFormat(attributeIndex, attribute.elementCount,
attribute.glType, attribute.normalized, strideSize);
GL43.glVertexAttribFormat(attributeIndex, attribute.elementCount, attribute.glType,
attribute.normalized, strideSize); // Here strideSize is new attrib offset
strideSize += attribute.byteSize;
if (numberOfBindingPoints <= bindingPoint) numberOfBindingPoints = bindingPoint+1;
GL43.glVertexAttribBinding(attributeIndex, bindingPoint);
GL43.glEnableVertexAttribArray(attributeIndex);
}
@Override
@@ -63,7 +62,8 @@ public final class VertexAttributePostGL43 extends VertexAttribute {
ClientApi.LOGGER.error("Vertex Attribute calculated stride size " + strideSize +
" does not match the provided expected stride size " + expectedStrideSize + "!");
}
ClientApi.LOGGER.info("Vertex Attribute (GL43+) completed.");
ClientApi.LOGGER.info("Vertex Attribute (GL43+) completed. It contains "+numberOfBindingPoints
+" binding points and a stride size of "+strideSize);
}
}