mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 21:02:15 +00:00
Emulate color logic ops and fix pixel readback on SDL-GPU (#2157)
This commit is contained in:
1 parent
74ea5c4709
commit
7bb5bfd45c
45 files changed
+4412
-329
No files matched your search
@@ -138,6 +138,12 @@ public enum Mixins implements IMixins {
|
||||
.addClientMixins("angelica.gui.MixinGuiMainMenuSplash")
|
||||
),
|
||||
|
||||
ANGELICA_TEXT_HIGHLIGHT(
|
||||
new MixinBuilder("Draw text field selection without color logic op")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.gui.MixinGuiTextField")
|
||||
),
|
||||
|
||||
ANGELICA_FONT_RENDERER(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableFontRenderer)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gtnewhorizons.angelica.mixins.hooks;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.StateSet;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class TextHighlightHooks {
|
||||
|
||||
public static void draw(int x1, int y1, int x2, int y2) {
|
||||
final int depth = GLStateManager.pushState(StateSet.BLEND);
|
||||
|
||||
GLStateManager.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GLStateManager.glEnable(GL11.GL_BLEND);
|
||||
|
||||
GLStateManager.glBlendFuncSeparate(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
quad(x1, y1, x2, y2);
|
||||
|
||||
GLStateManager.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
GLStateManager.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
quad(x1, y1, x2, y2);
|
||||
|
||||
GLStateManager.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GLStateManager.popStateTo(depth);
|
||||
}
|
||||
|
||||
private static void quad(int x1, int y1, int x2, int y2) {
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertex(x1, y2, 0.0D);
|
||||
tessellator.addVertex(x2, y2, 0.0D);
|
||||
tessellator.addVertex(x2, y1, 0.0D);
|
||||
tessellator.addVertex(x1, y1, 0.0D);
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
+2
-9
@@ -14,9 +14,8 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.hooks.TextHighlightHooks;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -173,13 +172,7 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
if (x1 > this.dim.getOriginX() + this.dim.getWidth()) {
|
||||
x1 = this.dim.getOriginX() + this.dim.getWidth();
|
||||
}
|
||||
GLStateManager.glEnable(GL11.GL_COLOR_LOGIC_OP);
|
||||
GLStateManager.glLogicOp(GL11.GL_OR_REVERSE);
|
||||
|
||||
drawRect(x1, y1, x2, y2, -0xFFFF01);
|
||||
|
||||
GLStateManager.glDisable(GL11.GL_COLOR_LOGIC_OP);
|
||||
|
||||
TextHighlightHooks.draw(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
private int getMaxLength() {
|
||||
|
||||
Reference in new issue
Block a user