From c8e94bdc156d2bb8aedc688d22e738bf6cb3856b Mon Sep 17 00:00:00 2001 From: Ven Date: Mon, 15 Jul 2024 07:46:17 +0100 Subject: [PATCH 1/2] Added binding empty texture into API --- .../com/falsepattern/lib/util/RenderUtil.java | 16 ++++++++++++++++ .../falsepatternlib/textures/empty_texture.png | Bin 0 -> 139 bytes .../textures/empty_texture_n.png | Bin 0 -> 140 bytes .../textures/empty_texture_s.png | Bin 0 -> 141 bytes 4 files changed, 16 insertions(+) create mode 100644 src/main/resources/assets/falsepatternlib/textures/empty_texture.png create mode 100644 src/main/resources/assets/falsepatternlib/textures/empty_texture_n.png create mode 100644 src/main/resources/assets/falsepatternlib/textures/empty_texture_s.png diff --git a/src/main/java/com/falsepattern/lib/util/RenderUtil.java b/src/main/java/com/falsepattern/lib/util/RenderUtil.java index 7d2cceb..2c30ebd 100644 --- a/src/main/java/com/falsepattern/lib/util/RenderUtil.java +++ b/src/main/java/com/falsepattern/lib/util/RenderUtil.java @@ -23,11 +23,13 @@ package com.falsepattern.lib.util; import com.falsepattern.lib.StableAPI; +import com.falsepattern.lib.internal.Tags; import com.falsepattern.lib.internal.render.ClampedIcon; import com.falsepattern.lib.internal.render.FullTextureIcon; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; import lombok.val; +import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; @@ -45,6 +47,7 @@ import static net.minecraft.client.Minecraft.getMinecraft; @StableAPI(since = "0.8.0") public final class RenderUtil { private static final Timer MINECRAFT_TIMER = getMinecraftTimer(); + private static final ResourceLocation EMPTY_TEXTURE = new ResourceLocation(Tags.MODID, "textures/gui/empty_texture.png"); /** * Sets the OpenGL translation, relative to the player's position. @@ -95,6 +98,19 @@ public final class RenderUtil { return new ClampedIcon(icon); } + /** + * Binds an empty texture. + *

+ * When rendering without shaders, using {@link GL11#glDisable(int)} with {@link GL11#GL_TEXTURE_2D} + * is sufficient to achieve the same effect. + *

+ * However, when shaders are enabled, disabling textures using this method will have no effect. Therefore this method can be used as a workaround. + */ + // TODO: Define stable API Version + public static void bindEmptyTexture() { + getMinecraft().renderEngine.bindTexture(EMPTY_TEXTURE); + } + /** * Provides the partial tick between the last and next client tick, in the range of 0 to 1. *

diff --git a/src/main/resources/assets/falsepatternlib/textures/empty_texture.png b/src/main/resources/assets/falsepatternlib/textures/empty_texture.png new file mode 100644 index 0000000000000000000000000000000000000000..771c145cc490bf8aecacd2fef9060a537155b264 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK?P42#}Etu1OhU`-;GE-e%ECZ@#@O1TaS?83{1OOt1A#4Bu literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/falsepatternlib/textures/empty_texture_n.png b/src/main/resources/assets/falsepatternlib/textures/empty_texture_n.png new file mode 100644 index 0000000000000000000000000000000000000000..6a2331e61778f2740d4ac32acd285b4570a3b689 GIT binary patch literal 140 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucK}Am&#}Etu Date: Mon, 15 Jul 2024 12:02:31 +0200 Subject: [PATCH 2/2] expose binding in StableAPI --- src/main/java/com/falsepattern/lib/util/RenderUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/falsepattern/lib/util/RenderUtil.java b/src/main/java/com/falsepattern/lib/util/RenderUtil.java index 2c30ebd..ecb2f7a 100644 --- a/src/main/java/com/falsepattern/lib/util/RenderUtil.java +++ b/src/main/java/com/falsepattern/lib/util/RenderUtil.java @@ -106,7 +106,7 @@ public final class RenderUtil { *

* However, when shaders are enabled, disabling textures using this method will have no effect. Therefore this method can be used as a workaround. */ - // TODO: Define stable API Version + @StableAPI.Expose(since = "1.3.0") public static void bindEmptyTexture() { getMinecraft().renderEngine.bindTexture(EMPTY_TEXTURE); }