diff --git a/core/src/mindustry/graphics/IndexedRenderer.java b/core/src/mindustry/graphics/IndexedRenderer.java index 15185fdfac..1a982af9c3 100644 --- a/core/src/mindustry/graphics/IndexedRenderer.java +++ b/core/src/mindustry/graphics/IndexedRenderer.java @@ -9,7 +9,7 @@ import arc.util.*; public class IndexedRenderer implements Disposable{ private static final int vsize = 5; - private final Shader program = new Shader( + private final static Shader program = new Shader( """ attribute vec4 a_position; attribute vec4 a_color; @@ -34,9 +34,9 @@ public class IndexedRenderer implements Disposable{ } """ ); + private static final float[] tmpVerts = new float[vsize * 6]; + private Mesh mesh; - private float[] tmpVerts = new float[vsize * 6]; - private float[] vertices; private Mat projMatrix = new Mat(); private Mat transMatrix = new Mat(); @@ -57,7 +57,7 @@ public class IndexedRenderer implements Disposable{ program.setUniformMatrix4("u_projTrans", combined); - mesh.render(program, Gl.triangles, 0, vertices.length / vsize); + mesh.render(program, Gl.triangles, 0, mesh.getMaxVertices()); } public void setColor(Color color){ @@ -203,8 +203,9 @@ public class IndexedRenderer implements Disposable{ VertexAttribute.position, VertexAttribute.color, VertexAttribute.texCoords); - vertices = new float[6 * sprites * vsize]; - mesh.setVertices(vertices); + + //TODO why is this the only way to get it working properly? it should not need an array + mesh.setVertices(new float[6 * sprites * vsize]); } private void updateMatrix(){