Skip to content

Commit

Permalink
Gracefully handle nested display list compilations in GLSM (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cleptomania authored Nov 21, 2024
1 parent 55c1786 commit 3d98e57
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public static void reset() {
@Setter @Getter private static boolean runningSplash = true;

private static int glListMode = 0;
private static int glListNesting = 0;
private static int glListId = -1;
private static final Map<IStateStack<?>, ISettableState<?>> glListStates = new Object2ObjectArrayMap<>();
private static final Int2ObjectMap<Set<Map.Entry<IStateStack<?>, ISettableState<?>>>> glListChanges = new Int2ObjectOpenHashMap<>();
Expand Down Expand Up @@ -1187,7 +1188,8 @@ public static void makeCurrent(Drawable drawable) throws LWJGLException {

public static void glNewList(int list, int mode) {
if(glListMode > 0) {
throw new RuntimeException("glNewList called inside of a display list!");
glListNesting += 1;
return;
}
glListId = list;
glListMode = mode;
Expand All @@ -1202,6 +1204,11 @@ public static void glNewList(int list, int mode) {
}

public static void glEndList() {
if (glListNesting > 0) {
glListNesting -= 1;
return;
}

if(glListMode == 0) {
throw new RuntimeException("glEndList called outside of a display list!");
}
Expand Down

0 comments on commit 3d98e57

Please sign in to comment.