aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-23 00:46:43 +0200
committermakamys <makamys@outlook.com>2022-06-23 00:48:51 +0200
commit1536f57485a2e79bd694bf212fb000205c7580c8 (patch)
tree67b1565470c5b8618e29f29ae7655f955e4ce6d4 /src/main/java/makamys/neodymium
parent3dde44fb2dfc432e9db050956e3598ec403edd16 (diff)
downloadNeodymium-1536f57485a2e79bd694bf212fb000205c7580c8.tar.gz
Neodymium-1536f57485a2e79bd694bf212fb000205c7580c8.tar.bz2
Neodymium-1536f57485a2e79bd694bf212fb000205c7580c8.zip
Move index buffer population to the Mesh class
Diffstat (limited to 'src/main/java/makamys/neodymium')
-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();