mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 04:42:17 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52776530d8 | ||
|
|
9cebb352ad | ||
|
|
d810eaf876 | ||
|
|
1a1ca32721 | ||
|
|
a3d689e806 | ||
|
|
d4e22b6c0c | ||
|
|
7e24f6a395 | ||
|
|
c8e6a6f34f |
No files matched your search
@@ -45,9 +45,9 @@ body:
|
||||
- type: textarea
|
||||
id: modlist
|
||||
attributes:
|
||||
label: Mod List
|
||||
description: "List of mods, ideally a minimal reproducible set (can be retrieved from latest.log)"
|
||||
placeholder: "List of mods go here"
|
||||
label: Mod List or GTNH Pack Version
|
||||
description: "List of mods, ideally a minimal reproducible set (can be retrieved from latest.log). If using GTNH please indicate pack version and any changed mods, not the entire modlist."
|
||||
placeholder: "List of mods or GTNH Pack version goes here"
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
|
||||
@@ -73,4 +73,9 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeTextureLoading;
|
||||
|
||||
@Config.Comment("Optimize slow glGetInteger in Jabba w/ Nvidia Drivers")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeJabbaGetInteger;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.states.AlphaState;
|
||||
import com.gtnewhorizons.angelica.glsm.states.BlendState;
|
||||
@@ -8,7 +9,9 @@ import com.gtnewhorizons.angelica.glsm.states.Color4;
|
||||
import com.gtnewhorizons.angelica.glsm.states.DepthState;
|
||||
import com.gtnewhorizons.angelica.glsm.states.FogState;
|
||||
import com.gtnewhorizons.angelica.glsm.states.GLColorMask;
|
||||
import com.gtnewhorizons.angelica.glsm.states.MatrixState;
|
||||
import com.gtnewhorizons.angelica.glsm.states.TextureState;
|
||||
import com.gtnewhorizons.angelica.glsm.states.ViewportState;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
@@ -24,7 +27,10 @@ import net.coderbot.iris.texture.TextureInfoCache;
|
||||
import net.coderbot.iris.texture.TextureTracker;
|
||||
import net.coderbot.iris.texture.pbr.PBRTextureManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.joml.Matrix4d;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.ARBMultitexture;
|
||||
import org.lwjgl.opengl.Drawable;
|
||||
@@ -33,6 +39,7 @@ import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -55,6 +62,8 @@ public class GLStateManager {
|
||||
@Getter private static final AlphaState alphaState = new AlphaState();
|
||||
@Getter private static final BooleanState lightingState = new BooleanState(GL11.GL_LIGHTING);
|
||||
@Getter private static final BooleanState rescaleNormalState = new BooleanState(GL12.GL_RESCALE_NORMAL);
|
||||
@Getter private static final MatrixState matrixState = new MatrixState();
|
||||
@Getter private static final ViewportState viewportState = new ViewportState();
|
||||
|
||||
private static long dirty = 0;
|
||||
|
||||
@@ -77,7 +86,7 @@ public class GLStateManager {
|
||||
private static Thread CurrentThread = MainThread;
|
||||
private static boolean runningSplash = false;
|
||||
|
||||
private static boolean inGLNewList = false;
|
||||
private static int glListMode = 0;
|
||||
|
||||
private static boolean hudCaching$blendEnabled;
|
||||
|
||||
@@ -386,11 +395,17 @@ public class GLStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getBoundTexture() {
|
||||
return Textures[activeTexture].binding;
|
||||
}
|
||||
|
||||
public static void glBindTexture(int target, int texture) {
|
||||
if(inGLNewList) {
|
||||
// Binding a texture, while building a list, is not allowed and is a silent noop
|
||||
Throwable throwable = new Throwable();
|
||||
LOGGER.info("Naughty naughty, someone's making a texture binding in a display list!", throwable);
|
||||
if(glListMode == GL11.GL_COMPILE ) {
|
||||
if(AngelicaMod.lwjglDebug) {
|
||||
// Binding a texture, while building a list, is not allowed and is a silent noop
|
||||
final Throwable throwable = new Throwable();
|
||||
LOGGER.info("Naughty naughty, someone's making a texture binding in a display list!", throwable);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -654,25 +669,26 @@ public class GLStateManager {
|
||||
}
|
||||
|
||||
public static void glNewList(int list, int mode) {
|
||||
if(inGLNewList) {
|
||||
if(glListMode > 0) {
|
||||
throw new RuntimeException("glNewList called inside of a display list!");
|
||||
}
|
||||
inGLNewList = true;
|
||||
|
||||
glListMode = mode;
|
||||
GL11.glNewList(list, mode);
|
||||
}
|
||||
|
||||
public static void glEndList() {
|
||||
if(!inGLNewList) {
|
||||
if(glListMode == 0) {
|
||||
throw new RuntimeException("glEndList called outside of a display list!");
|
||||
}
|
||||
inGLNewList = false;
|
||||
glListMode = 0;
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
public static void glPushAttrib(int mask) {
|
||||
// TODO: Proper state tracking; but at least for now the current cases of this didn't do anything related to textures and
|
||||
// just overly broadly set ALL_BITS :facepalm:
|
||||
GL11.glPushAttrib(mask & ~(GL11.GL_TEXTURE_BIT));
|
||||
GL11.glPushAttrib(GLStateManager.BYPASS_CACHE ? mask : (mask & ~(GL11.GL_TEXTURE_BIT)));
|
||||
}
|
||||
|
||||
public static void glPopAttrib() {
|
||||
@@ -694,4 +710,94 @@ public class GLStateManager {
|
||||
public static void dirty(long dirtyFlag) {
|
||||
dirty |= dirtyFlag;
|
||||
}
|
||||
|
||||
// Matrix Operations
|
||||
public static void glMatrixMode(int mode) {
|
||||
matrixState.setMode(mode);
|
||||
GL11.glMatrixMode(mode);
|
||||
}
|
||||
public static void glLoadIdentity() {
|
||||
GL11.glLoadIdentity();
|
||||
matrixState.identity();
|
||||
}
|
||||
|
||||
public static void glTranslatef(float x, float y, float z) {
|
||||
GL11.glTranslatef(x, y, z);
|
||||
matrixState.translate(x, y, z);
|
||||
}
|
||||
public static void glTranslated(double x, double y, double z) {
|
||||
GL11.glTranslated(x, y, z);
|
||||
matrixState.translate((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
public static void glScalef(float x, float y, float z) {
|
||||
GL11.glScalef(x, y, z);
|
||||
matrixState.scale(x, y, z);
|
||||
}
|
||||
|
||||
public static void glScaled(double x, double y, double z) {
|
||||
GL11.glScaled(x, y, z);
|
||||
matrixState.scale((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
public static void glMultMatrix(FloatBuffer matrix) {
|
||||
GL11.glMultMatrix(matrix);
|
||||
matrixState.multiply(matrix);
|
||||
}
|
||||
|
||||
public static final Matrix4d conersionMatrix4d = new Matrix4d();
|
||||
public static final Matrix4f conersionMatrix4f = new Matrix4f();
|
||||
public static void glMultMatrix(DoubleBuffer matrix) {
|
||||
GL11.glMultMatrix(matrix);
|
||||
conersionMatrix4d.set(matrix);
|
||||
conersionMatrix4f.set(conersionMatrix4d);
|
||||
matrixState.multiply(conersionMatrix4f);
|
||||
}
|
||||
|
||||
public static void glRotatef(float angle, float x, float y, float z) {
|
||||
GL11.glRotatef(angle, x, y, z);
|
||||
matrixState.rotate((float)Math.toRadians(angle), x, y, z);
|
||||
}
|
||||
|
||||
public static void glRotated(double angle, double x, double y, double z) {
|
||||
GL11.glRotated(angle, x, y, z);
|
||||
matrixState.rotate((float)Math.toRadians(angle), (float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
public static void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar) {
|
||||
GL11.glOrtho(left, right, bottom, top, zNear, zFar);
|
||||
matrixState.ortho(left, right, bottom, top, zNear, zFar);
|
||||
}
|
||||
|
||||
public static void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar) {
|
||||
GL11.glFrustum(left, right, bottom, top, zNear, zFar);
|
||||
matrixState.frustum(left, right, bottom, top, zNear, zFar);
|
||||
}
|
||||
public static void glPushMatrix() {
|
||||
GL11.glPushMatrix();
|
||||
matrixState.push();
|
||||
}
|
||||
|
||||
public static void glPopMatrix() {
|
||||
GL11.glPopMatrix();
|
||||
matrixState.pop();
|
||||
}
|
||||
|
||||
private static final Matrix4f perspectiveMatrix = new Matrix4f();
|
||||
private static final FloatBuffer perspectiveBuffer = BufferUtils.createFloatBuffer(16);
|
||||
public static void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
|
||||
perspectiveMatrix.identity().perspective((float)Math.toRadians(fovy), aspect, zNear, zFar);
|
||||
|
||||
perspectiveMatrix.get(0, perspectiveBuffer);
|
||||
GL11.glMultMatrix(perspectiveBuffer);
|
||||
|
||||
matrixState.multiply(perspectiveMatrix);
|
||||
|
||||
}
|
||||
|
||||
public static void glViewport(int x, int y, int width, int height) {
|
||||
GL11.glViewport(x, y, width, height);
|
||||
viewportState.set(x, y, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.gtnewhorizons.angelica.glsm.states;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class MatrixState {
|
||||
|
||||
public MatrixMode mode = MatrixMode.NONE;
|
||||
public final Matrix4fStack projectionMatrix;
|
||||
public final Matrix4fStack modelViewMatrix;
|
||||
|
||||
public MatrixState() {
|
||||
projectionMatrix = new Matrix4fStack(GL11.glGetInteger(GL11.GL_MAX_PROJECTION_STACK_DEPTH));
|
||||
modelViewMatrix = new Matrix4fStack(GL11.glGetInteger(GL11.GL_MAX_MODELVIEW_STACK_DEPTH));
|
||||
}
|
||||
|
||||
public void identity() {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.identity();
|
||||
case PROJECTION -> projectionMatrix.identity();
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMode(int mode) {
|
||||
switch (mode) {
|
||||
case GL11.GL_MODELVIEW -> this.mode = MatrixMode.MODELVIEW;
|
||||
case GL11.GL_PROJECTION -> this.mode = MatrixMode.PROJECTION;
|
||||
default -> this.mode = MatrixMode.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public void translate(float x, float y, float z) {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.translate(x, y, z);
|
||||
case PROJECTION -> projectionMatrix.translate(x, y, z);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void scale(float x, float y, float z) {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.scale(x, y, z);
|
||||
case PROJECTION -> projectionMatrix.scale(x, y, z);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Matrix4f tempMatrix = new Matrix4f();
|
||||
|
||||
public void multiply(FloatBuffer matrix) {
|
||||
tempMatrix.set(matrix);
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.mul(tempMatrix);
|
||||
case PROJECTION -> projectionMatrix.mul(tempMatrix);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void multiply(Matrix4f matrix) {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.mul(matrix);
|
||||
case PROJECTION -> projectionMatrix.mul(matrix);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rotate(float angle, float x, float y, float z) {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.rotate(angle, x, y, z);
|
||||
case PROJECTION -> projectionMatrix.rotate(angle, x, y, z);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.ortho((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
|
||||
case PROJECTION -> projectionMatrix.ortho((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void frustum(double left, double right, double bottom, double top, double zNear, double zFar) {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.frustum((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
|
||||
case PROJECTION -> projectionMatrix.frustum((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void push() {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.pushMatrix();
|
||||
case PROJECTION -> projectionMatrix.pushMatrix();
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.popMatrix();
|
||||
case PROJECTION -> projectionMatrix.popMatrix();
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void perspective(float fovy, float aspect, float zNear, float zFar) {
|
||||
switch (mode) {
|
||||
case MODELVIEW -> modelViewMatrix.perspective(fovy, aspect, zNear, zFar);
|
||||
case PROJECTION -> projectionMatrix.perspective(fovy, aspect, zNear, zFar);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MatrixMode {
|
||||
NONE,
|
||||
MODELVIEW,
|
||||
PROJECTION
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gtnewhorizons.angelica.glsm.states;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class ViewportState {
|
||||
public int x;
|
||||
public int y;
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
public void set(int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void get(IntBuffer params) {
|
||||
params.put(0, x);
|
||||
params.put(1, y);
|
||||
params.put(2, width);
|
||||
params.put(3, height);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,9 @@ public enum Mixins {
|
||||
|
||||
ANGELICA(new Builder("Angelica").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.MixinEntityRenderer"
|
||||
,"angelica.MixinActiveRenderInfo"
|
||||
"angelica.MixinActiveRenderInfo"
|
||||
,"angelica.MixinClippingHelperImpl"
|
||||
,"angelica.MixinEntityRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -135,6 +136,11 @@ public enum Mixins {
|
||||
)
|
||||
),
|
||||
|
||||
OPTIMIZE_JABBA_GET_INTEGER(new Builder("Optimize Jabba getInteger").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.JABBA).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeJabbaGetInteger)
|
||||
.addMixinClasses("client.jabba.MixinTileEntityBaseRenderer")),
|
||||
|
||||
|
||||
ANGELICA_TEXTURE(new Builder("Textures").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris || AngelicaConfig.enableSodium).addMixinClasses(
|
||||
|
||||
+23
@@ -1,11 +1,15 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.states.ViewportState;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
@@ -19,4 +23,23 @@ public class MixinActiveRenderInfo {
|
||||
RenderingState.INSTANCE.setProjectionMatrix(projection);
|
||||
RenderingState.INSTANCE.setModelViewMatrix(modelview);
|
||||
}
|
||||
|
||||
@Redirect(method = "updateRenderInfo", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glGetFloat(ILjava/nio/FloatBuffer;)V"), remap = false)
|
||||
private static void angelica$glGetFloat(int pname, FloatBuffer params) {
|
||||
if(pname == GL11.GL_MODELVIEW_MATRIX) {
|
||||
GLStateManager.getMatrixState().modelViewMatrix.get(0, params);
|
||||
} else if(pname == GL11.GL_PROJECTION_MATRIX) {
|
||||
GLStateManager.getMatrixState().projectionMatrix.get(0, params);
|
||||
} else {
|
||||
GL11.glGetFloat(pname, params);
|
||||
}
|
||||
}
|
||||
@Redirect(method = "updateRenderInfo", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glGetInteger(ILjava/nio/IntBuffer;)V"), remap = false)
|
||||
private static void angelica$glGetInteger(int pname, java.nio.IntBuffer params) {
|
||||
if(pname == GL11.GL_VIEWPORT) {
|
||||
GLStateManager.getViewportState().get(params);
|
||||
} else {
|
||||
GL11.glGetInteger(pname, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
@Mixin(ClippingHelperImpl.class)
|
||||
public class MixinClippingHelperImpl {
|
||||
@Redirect(method="init", at=@At(value="INVOKE", target="Lorg/lwjgl/opengl/GL11;glGetFloat(ILjava/nio/FloatBuffer;)V"), remap = false)
|
||||
private void angelica$glGetFloat(int pname, FloatBuffer params) {
|
||||
if(pname == GL11.GL_MODELVIEW_MATRIX) {
|
||||
GLStateManager.getMatrixState().modelViewMatrix.get(0, params);
|
||||
} else if(pname == GL11.GL_PROJECTION_MATRIX) {
|
||||
GLStateManager.getMatrixState().projectionMatrix.get(0, params);
|
||||
} else {
|
||||
GL11.glGetFloat(pname, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
-3
@@ -21,8 +21,5 @@ public abstract class MixinEntityRenderer {
|
||||
viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks,
|
||||
viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks
|
||||
);
|
||||
// RenderingState.INSTANCE.captureProjectionMatrix();
|
||||
// RenderingState.INSTANCE.captureModelViewMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium.startup;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.Iris;
|
||||
@@ -19,7 +20,7 @@ public class MixinInitDebug {
|
||||
}
|
||||
// Temp -- move this into common debug code
|
||||
Iris.identifyCapabilities();
|
||||
Iris.setDebug(true);
|
||||
Iris.setDebug(AngelicaMod.lwjglDebug);
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.jabba;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(targets = "mcp.mobius.betterbarrels.client.render.TileEntityBaseRenderer")
|
||||
public class MixinTileEntityBaseRenderer {
|
||||
@Redirect(method="saveBoundTexture", at=@At(value="INVOKE", target="Lorg/lwjgl/opengl/GL11;glGetInteger(I)I"), remap=false)
|
||||
private int glGetInteger(int pname) {
|
||||
if(pname == GL11.GL_TEXTURE_BINDING_2D) {
|
||||
return GLStateManager.getBoundTexture();
|
||||
} else {
|
||||
return GL11.glGetInteger(pname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import lombok.Getter;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
@@ -26,22 +27,10 @@ public class RenderingState {
|
||||
cameraPosition.set(x, y, z);
|
||||
}
|
||||
|
||||
public void captureProjectionMatrix() {
|
||||
// Not very fast, but given we're not on 3.2+ core and are still using the opengl matrix stack, we don't have much alternative
|
||||
projectionBuffer.position(0);
|
||||
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionBuffer);
|
||||
projectionMatrix.set(projectionBuffer);
|
||||
}
|
||||
|
||||
public void captureModelViewMatrix() {
|
||||
modelViewBuffer.position(0);
|
||||
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelViewBuffer);
|
||||
modelViewMatrix.set(modelViewBuffer);
|
||||
}
|
||||
|
||||
public void setProjectionMatrix(FloatBuffer projection) {
|
||||
projectionMatrix.set(projection);
|
||||
projectionMatrix.get(0, projectionBuffer);
|
||||
|
||||
}
|
||||
|
||||
public void setModelViewMatrix(FloatBuffer modelview) {
|
||||
|
||||
@@ -44,6 +44,8 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
private static final String GL11 = "org/lwjgl/opengl/GL11";
|
||||
private static final String GL13 = "org/lwjgl/opengl/GL13";
|
||||
private static final String GL14 = "org/lwjgl/opengl/GL14";
|
||||
private static final String Project = "org/lwjgl/util/glu/Project";
|
||||
|
||||
private static final String OpenGlHelper = "net/minecraft/client/renderer/OpenGlHelper";
|
||||
private static final String EXTBlendFunc = "org/lwjgl/opengl/EXTBlendFuncSeparate";
|
||||
private static final String ARBMultiTexture = "org/lwjgl/opengl/ARBMultitexture";
|
||||
@@ -66,7 +68,8 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
Pair.of("maxZ", "field_149757_G")
|
||||
);
|
||||
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, TessellatorClass, BlockClass);
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, TessellatorClass, BlockClass,
|
||||
Project);
|
||||
private static final Map<String, Map<String, String>> methodRedirects = new HashMap<>();
|
||||
private static final Map<Integer, String> glCapRedirects = new HashMap<>();
|
||||
private static final List<String> TransformerExclusions = Arrays.asList(
|
||||
@@ -113,6 +116,20 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
.add("glPopAttrib")
|
||||
.add("glShadeModel")
|
||||
.add("glTexImage2D")
|
||||
.add("glMatrixMode")
|
||||
.add("glLoadIdentity")
|
||||
.add("glTranslatef")
|
||||
.add("glTranslated")
|
||||
.add("glScalef")
|
||||
.add("glScaled")
|
||||
.add("glMultMatrix")
|
||||
.add("glRotatef")
|
||||
.add("glRotated")
|
||||
.add("glOrtho")
|
||||
.add("glFrustum")
|
||||
.add("glPushMatrix")
|
||||
.add("glPopMatrix")
|
||||
.add("glViewport")
|
||||
);
|
||||
methodRedirects.put(GL13, RedirectMap.newMap().add("glActiveTexture"));
|
||||
methodRedirects.put(GL14, RedirectMap.newMap().add("glBlendFuncSeparate", "tryBlendFuncSeparate"));
|
||||
@@ -121,6 +138,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
.add("func_148821_a", "tryBlendFuncSeparate"));
|
||||
methodRedirects.put(EXTBlendFunc, RedirectMap.newMap().add("glBlendFuncSeparateEXT", "tryBlendFuncSeparate"));
|
||||
methodRedirects.put(ARBMultiTexture, RedirectMap.newMap().add("glActiveTextureARB"));
|
||||
methodRedirects.put(Project, RedirectMap.newMap().add("gluPerspective"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,12 +8,14 @@ import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class GlStateTracker {
|
||||
private static final int UNASSIGNED_HANDLE = -1;
|
||||
|
||||
private final int[] bufferState = new int[GlBufferTarget.COUNT];
|
||||
//private final int[] bufferRestoreState = new int[GlBufferTarget.COUNT];
|
||||
private final EnumSet<GlBufferTarget> mutatedBuffers = EnumSet.noneOf(GlBufferTarget.class);
|
||||
|
||||
private int vertexArrayState;
|
||||
//private int vertexArrayRestoreState;
|
||||
@@ -31,6 +33,8 @@ public class GlStateTracker {
|
||||
|
||||
this.bufferState[target.ordinal()] = buffer;
|
||||
|
||||
mutatedBuffers.add(target);
|
||||
|
||||
return prevBuffer != buffer;
|
||||
}
|
||||
|
||||
@@ -47,9 +51,10 @@ public class GlStateTracker {
|
||||
}
|
||||
|
||||
public void applyRestoreState() {
|
||||
for (int i = 0; i < GlBufferTarget.COUNT; i++) {
|
||||
GL15.glBindBuffer(GlBufferTarget.VALUES[i].getTargetParameter(), 0);
|
||||
}
|
||||
mutatedBuffers.forEach(target -> {
|
||||
GL15.glBindBuffer(target.getTargetParameter(), 0);
|
||||
});
|
||||
mutatedBuffers.clear();
|
||||
if(GlFunctions.isVertexArraySupported()) {
|
||||
GL30.glBindVertexArray(0);
|
||||
}
|
||||
|
||||
+2
-2
@@ -229,7 +229,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
int baseY = this.render.getOriginY();
|
||||
int baseZ = this.render.getOriginZ();
|
||||
BlockPos renderOffset = this.offset;
|
||||
RenderBlocks rb = new RenderBlocks(slice);
|
||||
RenderBlocks rb = new RenderBlocks(slice.getWorld());
|
||||
for (int relY = 0; relY < 16; relY++) {
|
||||
if (cancellationSource.isCancelled()) {
|
||||
return;
|
||||
@@ -258,7 +258,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
|
||||
|
||||
if (cache.getBlockRenderer().renderModel(cache.getWorldSlice(), Tessellator.instance, rb, block, meta, pos, buffers.get(pass), true, seed)) {
|
||||
if (cache.getBlockRenderer().renderModel(slice.getWorld(), Tessellator.instance, rb, block, meta, pos, buffers.get(pass), true, seed)) {
|
||||
bounds.addBlock(relX, relY, relZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,4 +355,8 @@ public class WorldSlice implements IBlockAccess {
|
||||
case UNKNOWN -> 1.0f;
|
||||
};
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
}
|
||||
@@ -243,8 +243,7 @@ public class IrisRenderSystem {
|
||||
public static void setupProjectionMatrix(Matrix4f matrix) {
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glPushMatrix();
|
||||
PROJECTION_MATRIX_BUFFER.clear().rewind();
|
||||
matrix.get(PROJECTION_MATRIX_BUFFER);
|
||||
matrix.get(0, PROJECTION_MATRIX_BUFFER);
|
||||
GL11.glLoadMatrix(PROJECTION_MATRIX_BUFFER);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user