mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-22 21:29:44 +00:00
1 parent
65d9bf8f2f
commit
8863826d0e
9 files changed
+86
-57
No files matched your search
@@ -50,6 +50,7 @@ import org.lwjgl.opengl.Drawable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
|
||||
@@ -190,6 +191,71 @@ public class GLStateManager {
|
||||
default -> GL11.glDisable(cap);
|
||||
}
|
||||
}
|
||||
public static boolean glGetBoolean(int pname) {
|
||||
if(GLStateManager.BYPASS_CACHE) {
|
||||
return GL11.glGetBoolean(pname);
|
||||
}
|
||||
return switch (pname) {
|
||||
case GL11.GL_BLEND -> blendMode.isEnabled();
|
||||
case GL11.GL_DEPTH_TEST -> depthTest.isEnabled();
|
||||
case GL11.GL_CULL_FACE -> cullState.isEnabled();
|
||||
case GL11.GL_LIGHTING -> lightingState.isEnabled();
|
||||
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.topInt()).isEnabled();
|
||||
case GL11.GL_FOG -> fogMode.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_DEPTH_WRITEMASK -> depthState.isMask();
|
||||
default -> GL11.glGetBoolean(pname);
|
||||
};
|
||||
}
|
||||
|
||||
private static void glGetBoolean(int pname, ByteBuffer params) {
|
||||
if(GLStateManager.BYPASS_CACHE) {
|
||||
GL11.glGetBoolean(pname, params);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pname) {
|
||||
case GL11.GL_COLOR_WRITEMASK -> {
|
||||
params.put((byte) (colorMask.red ? GL11.GL_TRUE : GL11.GL_FALSE));
|
||||
params.put((byte) (colorMask.green ? GL11.GL_TRUE : GL11.GL_FALSE));
|
||||
params.put((byte) (colorMask.blue ? GL11.GL_TRUE : GL11.GL_FALSE));
|
||||
params.put((byte) (colorMask.alpha ? GL11.GL_TRUE : GL11.GL_FALSE));
|
||||
}
|
||||
default -> GL11.glGetBoolean(pname, params);
|
||||
}
|
||||
}
|
||||
|
||||
public static int glGetInteger(int pname) {
|
||||
if(GLStateManager.BYPASS_CACHE) {
|
||||
return GL11.glGetInteger(pname);
|
||||
}
|
||||
|
||||
return switch (pname) {
|
||||
case GL11.GL_TEXTURE_BINDING_2D -> getBoundTexture();
|
||||
case GL14.GL_BLEND_SRC_RGB -> blendState.getSrcRgb();
|
||||
case GL14.GL_BLEND_DST_RGB -> blendState.getDstRgb();
|
||||
case GL14.GL_BLEND_SRC_ALPHA -> blendState.getSrcAlpha();
|
||||
case GL14.GL_BLEND_DST_ALPHA -> blendState.getDstAlpha();
|
||||
case GL11.GL_DEPTH_FUNC -> depthState.getFunc();
|
||||
case GL11.GL_LIST_MODE -> glListMode;
|
||||
case GL11.GL_MATRIX_MODE -> matrixMode.getMode();
|
||||
|
||||
default -> GL11.glGetInteger(pname);
|
||||
};
|
||||
}
|
||||
|
||||
public static void glGetInteger(int pname, IntBuffer params) {
|
||||
if(GLStateManager.BYPASS_CACHE) {
|
||||
GL11.glGetInteger(pname, params);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pname) {
|
||||
case GL11.GL_VIEWPORT -> viewportState.get(params);
|
||||
default -> GL11.glGetInteger(pname, params);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glGetFloat(int pname, FloatBuffer params) {
|
||||
if(GLStateManager.BYPASS_CACHE) {
|
||||
@@ -201,6 +267,7 @@ public class GLStateManager {
|
||||
case GL11.GL_MODELVIEW_MATRIX -> modelViewMatrix.get(params);
|
||||
case GL11.GL_PROJECTION_MATRIX -> projectionMatrix.get(params);
|
||||
case GL11.GL_TEXTURE_MATRIX -> textureMatrix.get(params);
|
||||
case GL11.GL_COLOR_CLEAR_VALUE -> clearColor.get(params);
|
||||
default -> GL11.glGetFloat(pname, params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.gtnewhorizons.angelica.glsm.states;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
@Getter @Setter
|
||||
public class Color4 implements ISettableState<Color4> {
|
||||
protected float red = 1.0F;
|
||||
@@ -30,6 +32,13 @@ public class Color4 implements ISettableState<Color4> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void get(FloatBuffer params) {
|
||||
params.put(0, red);
|
||||
params.put(1, green);
|
||||
params.put(2, blue);
|
||||
params.put(3, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAs(Object state) {
|
||||
if (this == state) return true;
|
||||
|
||||
@@ -148,12 +148,6 @@ 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(
|
||||
"angelica.textures.MixinTextureAtlasSprite"
|
||||
|
||||
-12
@@ -1,14 +1,11 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
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;
|
||||
@@ -22,13 +19,4 @@ public class MixinActiveRenderInfo {
|
||||
RenderingState.INSTANCE.setProjectionMatrix(projection);
|
||||
RenderingState.INSTANCE.setModelViewMatrix(modelview);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,8 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
glCapRedirects.put(org.lwjgl.opengl.GL11.GL_SCISSOR_TEST, "ScissorTest");
|
||||
methodRedirects.put(GL11, RedirectMap.newMap()
|
||||
.add("glGetFloat")
|
||||
.add("glGetBoolean")
|
||||
.add("glGetInteger")
|
||||
.add("glAlphaFunc")
|
||||
.add("glBindTexture")
|
||||
.add("glBlendFunc")
|
||||
|
||||
@@ -57,14 +57,6 @@ public class IrisRenderSystem {
|
||||
supportsCompute = supportsCompute();
|
||||
}
|
||||
|
||||
public static void getIntegerv(int pname, IntBuffer params) {
|
||||
GL11.glGetInteger(pname, params);
|
||||
}
|
||||
|
||||
public static void getFloatv(int pname, FloatBuffer params) {
|
||||
GL11.glGetFloat(pname, params);
|
||||
}
|
||||
|
||||
public static void generateMipmaps(int texture, int mipmapTarget) {
|
||||
dsaState.generateMipmaps(texture, mipmapTarget);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.coderbot.iris.texture.util;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.BufferUtils;
|
||||
@@ -19,15 +18,13 @@ public class TextureManipulationUtil {
|
||||
colorFillFBO = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
|
||||
}
|
||||
|
||||
int previousFramebufferId = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
|
||||
final int previousFramebufferId = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
|
||||
// TODO: allocations
|
||||
FloatBuffer previousClearColorBuffer = BufferUtils.createFloatBuffer(4);
|
||||
// float[] previousClearColor = new float[4];
|
||||
IrisRenderSystem.getFloatv(GL11.GL_COLOR_CLEAR_VALUE, previousClearColorBuffer);
|
||||
int previousTextureId = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
IntBuffer previousViewportBuffer = BufferUtils.createIntBuffer(4);
|
||||
// int[] previousViewport = new int[4];
|
||||
IrisRenderSystem.getIntegerv(GL11.GL_VIEWPORT, previousViewportBuffer);
|
||||
final FloatBuffer previousClearColorBuffer = BufferUtils.createFloatBuffer(4);
|
||||
GL11.glGetFloat(GL11.GL_COLOR_CLEAR_VALUE, previousClearColorBuffer);
|
||||
final int previousTextureId = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
final IntBuffer previousViewportBuffer = BufferUtils.createIntBuffer(4);
|
||||
GL11.glGetInteger(GL11.GL_VIEWPORT, previousViewportBuffer);
|
||||
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, colorFillFBO);
|
||||
GL11.glClearColor(
|
||||
@@ -38,8 +35,8 @@ public class TextureManipulationUtil {
|
||||
);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
|
||||
for (int level = 0; level <= maxLevel; ++level) {
|
||||
int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
|
||||
int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
|
||||
final int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
|
||||
final int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
|
||||
GL11.glViewport(0, 0, width, height);
|
||||
GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, textureId, level);
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
Reference in new issue
Block a user