Replace GLU mipmapping with GL_GENERATE_MIPMAP (GL 1.4)

This commit is contained in:
Pazaz 2022-04-22 16:15:37 -04:00
parent e79d5ddee8
commit 87f04ac0e0
9 changed files with 63 additions and 58 deletions

View file

@ -1,6 +1,5 @@
import java.nio.ByteBuffer;
import com.jogamp.opengl.*;
import com.jogamp.opengl.glu.gl2es1.GLUgl2es1;
import org.openrs2.deob.annotation.OriginalArg;
import org.openrs2.deob.annotation.OriginalClass;
import org.openrs2.deob.annotation.OriginalMember;
@ -19,13 +18,13 @@ public final class GlTexture extends SecondaryNode {
private int[] anIntArray481;
@OriginalMember(owner = "client!uh", name = "bb", descriptor = "I")
private int anInt5493 = -1;
private int textureId = -1;
@OriginalMember(owner = "client!uh", name = "eb", descriptor = "Z")
public boolean aBoolean287 = false;
@OriginalMember(owner = "client!uh", name = "db", descriptor = "I")
private int anInt5495 = 0;
private int textureSize = 0;
@OriginalMember(owner = "client!uh", name = "W", descriptor = "Lclient!lc;")
private final Texture aClass88_1;
@ -172,49 +171,57 @@ public final class GlTexture extends SecondaryNode {
if (!this.aClass88_1.method2729(arg1, arg0)) {
return false;
}
@Pc(22) GL2 local22 = GlRenderer.gl;
@Pc(28) int local28 = arg2 ? 64 : 128;
@Pc(22) GL2 gl = GlRenderer.gl;
@Pc(28) int size = arg2 ? 64 : 128;
@Pc(31) int local31 = Static56.method1314();
if ((local31 & 0x1) == 0) {
if (this.anInt5493 == -1) {
@Pc(53) int[] local53 = new int[1];
local22.glGenTextures(1, local53, 0);
if (this.textureId == -1) {
@Pc(53) int[] temp = new int[1];
gl.glGenTextures(1, temp, 0);
this.anInt5492 = Static63.contextId;
this.anInt5493 = local53[0];
GlRenderer.setTextureId(this.anInt5493);
@Pc(82) ByteBuffer local82 = ByteBuffer.wrap(this.aClass88_1.method2728(local28, local28, this.aBoolean288, arg1, 0.7D, arg0));
this.textureId = temp[0];
GlRenderer.setTextureId(this.textureId);
@Pc(82) ByteBuffer pixels = ByteBuffer.wrap(this.aClass88_1.method2728(size, size, this.aBoolean288, arg1, 0.7D, arg0));
if (this.anInt5489 == 2) {
@Pc(201) GLUgl2es1 local201 = new GLUgl2es1();
local201.gluBuild2DMipmaps(3553, 6408, local28, local28, 6408, 5121, local82);
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
Static63.anInt1942 += local82.limit() * 4 / 3 - this.anInt5495;
this.anInt5495 = local82.limit() * 4 / 3;
// GLU code:
// @Pc(201) GLUgl2es1 local201 = new GLUgl2es1();
// local201.gluBuild2DMipmaps(3553, 6408, size, size, 6408, 5121, pixels);
// gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
// gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
// New code (OpenGL 1.4):
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_GENERATE_MIPMAP, GL2.GL_TRUE);
gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA8, size, size, 0, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, pixels);
Static63.onCardTexture += pixels.limit() * 4 / 3 - this.textureSize;
this.textureSize = pixels.limit() * 4 / 3;
} else if (this.anInt5489 == 1) {
@Pc(129) int local129 = 0;
while (true) {
local22.glTexImage2D(GL2.GL_TEXTURE_2D, local129++, GL2.GL_RGBA, local28, local28, 0, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, local82);
local28 >>= 0x1;
if (local28 == 0) {
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
Static63.anInt1942 += local82.limit() * 4 / 3 - this.anInt5495;
this.anInt5495 = local82.limit() * 4 / 3;
gl.glTexImage2D(GL2.GL_TEXTURE_2D, local129++, GL2.GL_RGBA, size, size, 0, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, pixels);
size >>= 0x1;
if (size == 0) {
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
Static63.onCardTexture += pixels.limit() * 4 / 3 - this.textureSize;
this.textureSize = pixels.limit() * 4 / 3;
break;
}
local82 = ByteBuffer.wrap(this.aClass88_1.method2728(local28, local28, this.aBoolean288, arg1, 0.7D, arg0));
pixels = ByteBuffer.wrap(this.aClass88_1.method2728(size, size, this.aBoolean288, arg1, 0.7D, arg0));
}
} else {
local22.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, local28, local28, 0, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, local82);
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
Static63.anInt1942 += local82.limit() - this.anInt5495;
this.anInt5495 = local82.limit();
gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, size, size, 0, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, pixels);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
Static63.onCardTexture += pixels.limit() - this.textureSize;
this.textureSize = pixels.limit();
}
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, this.aBoolean285 ? GL2.GL_REPEAT : GL2.GL_CLAMP_TO_EDGE);
local22.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, this.aBoolean284 ? GL2.GL_REPEAT : GL2.GL_CLAMP_TO_EDGE);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, this.aBoolean285 ? GL2.GL_REPEAT : GL2.GL_CLAMP_TO_EDGE);
gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, this.aBoolean284 ? GL2.GL_REPEAT : GL2.GL_CLAMP_TO_EDGE);
} else {
GlRenderer.setTextureId(this.anInt5493);
GlRenderer.setTextureId(this.textureId);
}
}
if ((local31 & 0x2) == 0) {
@ -227,8 +234,8 @@ public final class GlTexture extends SecondaryNode {
if (this.anInt5497 == 0 && this.anInt5485 == 0) {
GlRenderer.resetTextureMatrix();
} else {
@Pc(303) float local303 = (float) (this.anInt5497 * GlRenderer.anInt5323) / (float) local28;
@Pc(312) float local312 = (float) (this.anInt5485 * GlRenderer.anInt5323) / (float) local28;
@Pc(303) float local303 = (float) (this.anInt5497 * GlRenderer.anInt5323) / (float) size;
@Pc(312) float local312 = (float) (this.anInt5485 * GlRenderer.anInt5323) / (float) size;
GlRenderer.translateTextureMatrix(local312, local303, 0.0F);
}
}
@ -280,10 +287,10 @@ public final class GlTexture extends SecondaryNode {
@OriginalMember(owner = "client!uh", name = "finalize", descriptor = "()V")
@Override
public final void finalize() throws Throwable {
if (this.anInt5493 != -1) {
Static63.method1485(this.anInt5493, this.anInt5495, this.anInt5492);
this.anInt5495 = 0;
this.anInt5493 = -1;
if (this.textureId != -1) {
Static63.method1485(this.textureId, this.textureSize, this.anInt5492);
this.textureSize = 0;
this.textureId = -1;
}
super.finalize();
}