diff --git a/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java b/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java index 7b2e408a0..f5d07cd83 100644 --- a/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java +++ b/src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java @@ -55,6 +55,7 @@ import java.nio.ByteBuffer; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; +import java.util.AbstractMap; import java.util.Map; import java.util.Set; @@ -732,6 +733,7 @@ public class GLStateManager { glListMode = mode; GL11.glNewList(list, mode); for(IStateStack stack : Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS)) { + // Feature Stack, copy of current feature state glListStates.put(stack, (ISettableState) ((ISettableState)stack).copy()); } if(glListMode == GL11.GL_COMPILE) { @@ -746,8 +748,10 @@ public class GLStateManager { final Set, ISettableState>> changedStates = new ObjectArraySet<>(); for(Map.Entry, ISettableState> entry : glListStates.entrySet()) { + // If the current stack state is different than the copy of the state at the start if(!((ISettableState)entry.getKey()).sameAs(entry.getValue())) { - changedStates.add(entry); + // Then we want to put into the change set the stack and the copy of the state now + changedStates.add(new AbstractMap.SimpleEntry<>(entry.getKey(), (ISettableState) ((ISettableState) entry.getKey()).copy())); } } if(changedStates.size() != 0) { @@ -769,6 +773,7 @@ public class GLStateManager { GL11.glCallList(list); if(glListChanges.containsKey(list)) { for(Map.Entry, ISettableState> entry : glListChanges.get(list)) { + // Set the stack to the cached state at the end of the call list compilation ((ISettableState)entry.getKey()).set(entry.getValue()); } }