Skip to content

Commit

Permalink
Destroy unused buffers properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Nov 14, 2024
1 parent b895419 commit 320f6de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions fabric/src/main/java/com/noxcrew/noxesium/NoxesiumMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ public void onInitializeClient() {
initialize();
});

// Clear out all UI rendering state when we start configuring
ClientConfigurationConnectionEvents.START.register((ignored1, ignored2) -> {
NoxesiumMod.forEachRenderStateHolder(NoxesiumRenderStateHolder::clear);
});

// Call disconnection hooks
ClientPlayConnectionEvents.DISCONNECT.register((ignored1, ignored2) -> {
uninitialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class NoxesiumConfig {
public double mapUiSize = 0.8;
public MapLocation mapUiLocation = MapLocation.TOP;
public int minUiFramerate = 30;
public int maxUiFramerate = 120;
public int maxUiFramerate = 60;
public boolean showOptimizationOverlay = false;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ public boolean update(long nanoTime, GuiGraphics guiGraphics, Runnable draw) {
guiGraphics.flush();
SharedVertexBuffer.blendStateHook = null;

// Remove any remaining buffers
for (var index = (bufferIndex + 1); index < buffers.size(); index++) {
buffers.remove(index).close();
}

// Nothing was drawn, this layer does not contain anything!
bufferEmpty = !elementsWereDrawn && allBuffersEmpty;

Expand Down

0 comments on commit 320f6de

Please sign in to comment.