From 7813eedf61dc3873f1903c806f4220e63bcff752 Mon Sep 17 00:00:00 2001
From: Jozufozu implements MaterialMana
group.render(state, viewProjection, camX, camY, camZ);
}
+
+ GlBufferType.ELEMENT_ARRAY_BUFFER.unbind();
+ GlBufferType.ARRAY_BUFFER.unbind();
+ GlVertexArray.unbind();
}
public void delete() {
diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java
index 48359821c..8ac9bc906 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java
@@ -22,8 +22,6 @@ public class ArrayModelRenderer extends ModelRenderer {
vao.bind();
model.drawCall();
-
- vao.unbind();
}
@Override
@@ -44,7 +42,7 @@ public class ArrayModelRenderer extends ModelRenderer {
AttribUtil.enableArrays(this.model.getAttributeCount());
- vao.unbind();
+ GlVertexArray.unbind();
this.model.clearState();
}
diff --git a/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java b/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java
index 19245df4f..d3635718d 100644
--- a/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java
+++ b/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java
@@ -39,14 +39,14 @@ public class FullscreenQuad {
GL20.glVertexAttribPointer(0, 4, GlNumericType.FLOAT.getGlEnum(), false, 4 * 4, 0);
- vao.unbind();
+ GlVertexArray.unbind();
vbo.unbind();
}
public void draw() {
vao.bind();
GL20.glDrawArrays(GL20.GL_TRIANGLES, 0, 6);
- vao.unbind();
+ GlVertexArray.unbind();
}
public void delete() {
diff --git a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java
index 3c403ebcd..cf096be15 100644
--- a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java
+++ b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java
@@ -28,16 +28,7 @@ public class CrumblingGroup extends MaterialGroupImp
int renderTex = RenderSystem.getShaderTexture(0);
- ResourceLocation texture = RenderTextures.getShaderTexture(0);
-
- if (texture != null) {
- SheetData atlasData = AtlasInfo.getAtlasData(texture);
-
- width = atlasData.width;
- height = atlasData.height;
- } else {
- width = height = 256;
- }
+ updateAtlasSize();
type.clearRenderState();
@@ -56,6 +47,19 @@ public class CrumblingGroup extends MaterialGroupImp
CrumblingRenderer._currentLayer.clearRenderState();
}
+ private void updateAtlasSize() {
+ ResourceLocation texture = RenderTextures.getShaderTexture(0);
+
+ if (texture != null) {
+ SheetData atlasData = AtlasInfo.getAtlasData(texture);
+
+ width = atlasData.width;
+ height = atlasData.height;
+ } else {
+ width = height = 256;
+ }
+ }
+
@Override
public void setup(P p) {
p.setAtlasSize(width, height);
From ca459dd2cacbc85a397e3c7b53901ab96397e02f Mon Sep 17 00:00:00 2001
From: Jozufozu
+ * This prevents floating point precision issues at high coordinates.
+ */
+ void beginFrame(Camera info);
+
+ default void delete() {
+
+ }
+}
diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/batching/BatchedMaterial.java b/src/main/java/com/jozufozu/flywheel/backend/material/batching/BatchedMaterial.java
new file mode 100644
index 000000000..96a93766a
--- /dev/null
+++ b/src/main/java/com/jozufozu/flywheel/backend/material/batching/BatchedMaterial.java
@@ -0,0 +1,46 @@
+package com.jozufozu.flywheel.backend.material.batching;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import com.jozufozu.flywheel.backend.instancing.CPUInstancer;
+import com.jozufozu.flywheel.backend.instancing.InstanceData;
+import com.jozufozu.flywheel.backend.instancing.Instancer;
+import com.jozufozu.flywheel.backend.material.Material;
+import com.jozufozu.flywheel.backend.material.MaterialSpec;
+import com.jozufozu.flywheel.backend.struct.StructType;
+import com.jozufozu.flywheel.core.model.IModel;
+import com.mojang.blaze3d.vertex.PoseStack;
+import com.mojang.blaze3d.vertex.VertexConsumer;
+
+public class BatchedMaterial