Made IndexedRenderer shader static

This commit is contained in:
Anuken
2022-06-08 07:52:51 -04:00
parent 49d859f6bb
commit 1c0eff0871

View File

@@ -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(){