mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-24 06:04:27 +00:00
Handle bad matrix modes (#93)
* Handle common incorrect modes for glMatrixMode * Handle matrix stack over/under flow
This commit is contained in:
1 parent
ae0e03bead
commit
d19b8d5302
2 files changed
+21
-2
No files matched your search
@@ -16,6 +16,7 @@ import com.gtnewhorizons.angelica.glsm.states.Color4;
|
||||
import com.gtnewhorizons.angelica.glsm.states.TextureBinding;
|
||||
import com.gtnewhorizons.angelica.glsm.states.TextureUnitArray;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntStack;
|
||||
import lombok.Getter;
|
||||
@@ -828,12 +829,24 @@ public class GLStateManager {
|
||||
}
|
||||
public static void glPushMatrix() {
|
||||
GL11.glPushMatrix();
|
||||
getMatrixStack().pushMatrix();
|
||||
try {
|
||||
getMatrixStack().pushMatrix();
|
||||
} catch(IllegalStateException ignored) {
|
||||
// Ignore
|
||||
if(AngelicaMod.lwjglDebug)
|
||||
AngelicaTweaker.LOGGER.warn("Matrix stack overflow ", new Throwable());
|
||||
}
|
||||
}
|
||||
|
||||
public static void glPopMatrix() {
|
||||
GL11.glPopMatrix();
|
||||
getMatrixStack().popMatrix();
|
||||
try {
|
||||
getMatrixStack().popMatrix();
|
||||
} catch(IllegalStateException ignored) {
|
||||
// Ignore
|
||||
if(AngelicaMod.lwjglDebug)
|
||||
AngelicaTweaker.LOGGER.warn("Matrix stack underflow ", new Throwable());
|
||||
}
|
||||
}
|
||||
|
||||
private static final Matrix4f perspectiveMatrix = new Matrix4f();
|
||||
|
||||
@@ -9,6 +9,12 @@ public class MatrixMode implements ISettableState<MatrixMode> {
|
||||
protected int mode = GL11.GL_MODELVIEW;
|
||||
|
||||
public void setMode(int mode) {
|
||||
if(mode != GL11.GL_MODELVIEW && mode != GL11.GL_PROJECTION && mode != GL11.GL_TEXTURE && mode != GL11.GL_COLOR) {
|
||||
// Invalid mode, do nothing on the cache, but pass it along to OGL
|
||||
GL11.glMatrixMode(mode);
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.mode != mode || GLStateManager.BYPASS_CACHE) {
|
||||
this.mode = mode;
|
||||
GL11.glMatrixMode(mode);
|
||||
|
||||
Reference in new issue
Block a user