aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/makamys/neodymium/renderer/Mesh.java9
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java16
2 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/Mesh.java b/src/main/java/makamys/neodymium/renderer/Mesh.java
index 6eadf88..2b2b070 100644
--- a/src/main/java/makamys/neodymium/renderer/Mesh.java
+++ b/src/main/java/makamys/neodymium/renderer/Mesh.java
@@ -1,6 +1,7 @@
package makamys.neodymium.renderer;
import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
import makamys.neodymium.util.Util;
@@ -40,4 +41,12 @@ public abstract class Mesh {
public static enum GPUStatus {
UNSENT, SENT, PENDING_DELETE
}
+
+ public void writeToIndexBuffer(IntBuffer piFirst, IntBuffer piCount, int[] renderedMeshesReturn,
+ int[] renderedQuadsReturn) {
+ renderedMeshesReturn[0] = 1;
+ renderedQuadsReturn[0] = quadCount;
+ piFirst.put(iFirst);
+ piCount.put(iCount);
+ }
}
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
index 2a18950..7d85586 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
@@ -195,16 +195,18 @@ public class NeoRenderer {
}
}
+ private static int[] renderedMeshesReturn = new int[1];
+ private static int[] renderedQuadsReturn = new int[1];
+
private void initIndexBuffers() {
for(int i = 0; i < 2; i++) {
- piFirst[i].limit(sentMeshes[i].size());
- piCount[i].limit(sentMeshes[i].size());
+ piFirst[i].limit(MAX_MESHES);
+ piCount[i].limit(MAX_MESHES);
for(Mesh mesh : sentMeshes[i]) {
- if(isNormalMeshVisible(mesh) && mesh.visible && (Config.maxMeshesPerFrame == -1 || renderedMeshes < Config.maxMeshesPerFrame)) {
- renderedMeshes++;
- renderedQuads += mesh.quadCount;
- piFirst[i].put(mesh.iFirst);
- piCount[i].put(mesh.iCount);
+ if(mesh.visible && (Config.maxMeshesPerFrame == -1 || renderedMeshes < Config.maxMeshesPerFrame)) {
+ mesh.writeToIndexBuffer(piFirst[i], piCount[i], renderedMeshesReturn, renderedQuadsReturn);
+ renderedMeshes += renderedMeshesReturn[0];
+ renderedQuads += renderedQuadsReturn[0];
}
}
piFirst[i].flip();