From 3f5a869a2b8678fc1fb1629d36f898e5d84e34a1 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:55:23 -0400 Subject: [PATCH] Removed Texture Blending --- .../mojang/minecraft/render/RenderEngine.java | 70 +++++++++++++++---- .../adapter/EaglerAdapterImpl2.java | 3 + .../org/lwjgl/opengl/EaglerAdapterGL30.java | 5 ++ 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java b/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java index 8933bcf..2c628d1 100644 --- a/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java +++ b/src/teavm/java/com/mojang/minecraft/render/RenderEngine.java @@ -1,10 +1,15 @@ package com.mojang.minecraft.render; + + import java.io.IOException; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import org.lwjgl.opengl.GL11; @@ -24,7 +29,7 @@ public class RenderEngine { imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000); imageDataB2 = GLAllocation.createDirectByteBuffer(0x100000); textureList = new ArrayList(); - textureBlending = false; + //useMipmaps = false; options = Minecraft.settings; } @@ -38,11 +43,11 @@ public class RenderEngine { singleIntBuffer.clear(); GLAllocation.generateTextureNames(singleIntBuffer); int i = singleIntBuffer.get(0); - if(s.contains("terrain")) { - textureBlending = true; - } + //if(s.equals("/terrain.png")) { + //useMipmaps = true; + //} setupTexture(readTextureImage(texturepackbase.func_6481_a(s)), i); - textureBlending = false; + //useMipmaps = false; textureMap.put(s, Integer.valueOf(i)); return i; } catch (IOException ioexception) { @@ -76,16 +81,25 @@ public class RenderEngine { public void setupTexture(EaglerImage bufferedimage, int i) { bindTexture(i); - if (textureBlending) { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - +// if (useMipmaps) { +// GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, EaglerAdapter.GL_NEAREST_MIPMAP_LINEAR); +// GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, EaglerAdapter.GL_NEAREST /* GL_LINEAR */); +// GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, EaglerAdapter.GL_TEXTURE_MAX_LEVEL, 4); +// } else { GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */); GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */); - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */); - GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */); - +// } +// if (blurTexture) { +// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9729 /* GL_LINEAR */); +// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9729 /* GL_LINEAR */); +// } +// if (clampTexture) { +// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10496 /* GL_CLAMP */); +// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10496 /* GL_CLAMP */); +// } else { + GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */); + GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */); +// } int j = bufferedimage.w; int k = bufferedimage.h; int ai[] = bufferedimage.data; @@ -111,7 +125,34 @@ public class RenderEngine { imageDataB1.clear(); imageDataB1.put(abyte0); imageDataB1.position(0).limit(abyte0.length); - GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */, 5121 /* GL_UNSIGNED_BYTE */, imageDataB1); + GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */, + 5121 /* GL_UNSIGNED_BYTE */, imageDataB1); +// if (useMipmaps) { +// for (int i1 = 1; i1 <= 4; i1++) { +// int k1 = j >> i1 - 1; +// int i2 = j >> i1; +// int k2 = k >> i1; +// imageDataB2.clear(); +// for (int i3 = 0; i3 < i2; i3++) { +// for (int k3 = 0; k3 < k2; k3++) { +// int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4); +// int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4); +// int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4); +// int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4); +// int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5)); +// imageDataB2.putInt((i3 + k3 * i2) * 4, j5); +// } +// +// } +// +// GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */, +// 5121 /* GL_UNSIGNED_BYTE */, imageDataB2); +// ByteBuffer tmp = imageDataB1; +// imageDataB1 = imageDataB2; +// imageDataB2 = tmp; +// } +// +// } } public void deleteTexture(int i) { @@ -154,5 +195,4 @@ public class RenderEngine { private ByteBuffer imageDataB2; private java.util.List textureList; private GameSettings options; - private boolean textureBlending; } \ No newline at end of file diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index a0cd486..a3fda13 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -608,6 +608,9 @@ public class EaglerAdapterImpl2 { public static final void _wglBlendFunc(int p1, int p2) { webgl.blendFunc(p1, p2); } + public static final void _wglBlendFuncSeparate(int p1, int p2, int p3, int p4) { + webgl.blendFuncSeparate(p1, p2, p3, p4); + } public static final void _wglDepthMask(boolean p1) { webgl.depthMask(p1); } diff --git a/src/teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java b/src/teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java index e331172..3d11198 100644 --- a/src/teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java +++ b/src/teavm/java/org/lwjgl/opengl/EaglerAdapterGL30.java @@ -561,6 +561,11 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { fogPremultiply = (p1 == GL_ONE && p2 == GL_ONE_MINUS_SRC_ALPHA); _wglBlendFunc(p1, p2); } + + public static final void glBlendFuncSeparate(int p1, int p2, int p3, int p4) { + fogPremultiply = (p3 == GL_ONE && p4 == GL_ONE_MINUS_SRC_ALPHA); + _wglBlendFuncSeparate(p1, p2, p3, p4); + } public static final void glDepthMask(boolean p1) { _wglDepthMask(p1);