mirror of
https://github.com/JonasunderscoreJones/nicer-skies.git
synced 2025-10-23 03:39:18 +02:00
change: reuse same buffer to work around mem leaks in 1.19
This commit is contained in:
parent
b15b7a1d87
commit
ab607ff7b7
1 changed files with 5 additions and 4 deletions
|
@ -8,6 +8,8 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
//todo: redo all of the star rendering to be able to use the same vertex buffer object with a uniform or with the posestack
|
//todo: redo all of the star rendering to be able to use the same vertex buffer object with a uniform or with the posestack
|
||||||
public class StarManager {
|
public class StarManager {
|
||||||
|
private static final BufferBuilder starBufferBuilder = Tesselator.getInstance().getBuilder();
|
||||||
|
|
||||||
private static final int STAR_ATTEMPTS = 1500;
|
private static final int STAR_ATTEMPTS = 1500;
|
||||||
public static ArrayList<Star> starList = new ArrayList<>();
|
public static ArrayList<Star> starList = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -34,16 +36,15 @@ public class StarManager {
|
||||||
|
|
||||||
public static void updateStars(int ticks, VertexBuffer starBuffer) {
|
public static void updateStars(int ticks, VertexBuffer starBuffer) {
|
||||||
if (!ExampleMod.toggle) return;
|
if (!ExampleMod.toggle) return;
|
||||||
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
|
starBufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
|
||||||
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
|
|
||||||
|
|
||||||
for (Star star : starList) {
|
for (Star star : starList) {
|
||||||
star.tick(ticks);
|
star.tick(ticks);
|
||||||
star.setVertices(bufferBuilder);
|
star.setVertices(starBufferBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
starBuffer.bind();
|
starBuffer.bind();
|
||||||
starBuffer.upload(bufferBuilder.end());
|
starBuffer.upload(starBufferBuilder.end());
|
||||||
VertexBuffer.unbind();
|
VertexBuffer.unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue