mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-28 07:55:53 +00:00
CapturingTessellator and VBO support (#120)
* Adds a CapturingTessellator * VBO support * Remove some silly badly translated Iris vertex implementation from HFPModelVertexType * Support Normals * Move normal rendering to the CapturingTessellator, and remove off thread non-capturing tessellators * Add quad writer support to VertexFormat
This commit is contained in:
1 parent
ab54359f03
commit
4fabe45ae7
45 files changed
+508
-291
No files matched your search
@@ -1,13 +1,11 @@
|
||||
package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITessellatorInstance;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
@@ -59,33 +57,13 @@ public class HorizonRenderer {
|
||||
// Build the horizon quads into a buffer
|
||||
tessellator.startDrawingQuads(); //(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
|
||||
buildHorizon(currentRenderDistance * 16, tessellator);
|
||||
final ByteBuffer buf = tessellatorToBuffer(tessellator);
|
||||
((ITessellatorInstance) tessellator).discard();
|
||||
|
||||
this.vertexBuffer = new VertexBuffer();
|
||||
this.vertexBuffer.bind();
|
||||
this.vertexBuffer.upload(buf, tessellator.vertexCount);
|
||||
this.vertexBuffer.upload(tessellator, DefaultVertexFormat.POSITION);
|
||||
this.vertexBuffer.unbind();
|
||||
}
|
||||
|
||||
/* Convert the tessellator's data into a buffer that can be uploaded to the GPU. */
|
||||
private ByteBuffer tessellatorToBuffer(Tessellator tessellator) {
|
||||
final int[] rawBuffer = tessellator.rawBuffer;
|
||||
final int byteSize = (tessellator.vertexCount * 3) << 2;
|
||||
ByteBuffer byteBuffer = BufferUtils.createByteBuffer(byteSize);
|
||||
|
||||
for(int quadI = 0 ; quadI < tessellator.vertexCount / 4 ; quadI++) {
|
||||
for(int vertexI = 0 ; vertexI < 4 ; vertexI++) {
|
||||
int i = (quadI * 4 * 8 ) + (vertexI * 8);
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 0]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 1]));
|
||||
byteBuffer.putFloat(Float.intBitsToFloat(rawBuffer[i + 2]));
|
||||
}
|
||||
}
|
||||
|
||||
return (ByteBuffer) byteBuffer.rewind();
|
||||
}
|
||||
|
||||
private void buildQuad(Tessellator consumer, double x1, double z1, double x2, double z2) {
|
||||
consumer.addVertex(x1, BOTTOM, z1);
|
||||
consumer.addVertex(x1, TOP, z1);
|
||||
|
||||
Reference in new issue
Block a user