we do a little bit of merging

This commit is contained in:
UnknownUser1789 2023-01-19 02:49:21 +00:00
parent 190e053b80
commit be7ad251dd
3 changed files with 28029 additions and 27991 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,5 @@
package net.lax1dude.eaglercraft.v1_8.opengl; package net.lax1dude.eaglercraft.v1_8.opengl;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer; import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger; import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -10,6 +7,9 @@ import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f; import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f; import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
/** /**
* Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved. * Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved.
* *
@ -94,7 +94,10 @@ public class GlStateManager {
static int activeTexture = 0; static int activeTexture = 0;
static final boolean[] stateTexture = new boolean[16]; static final boolean[] stateTexture = new boolean[16];
static final int[] boundTexture = new int[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; static final int[] boundTexture = new int[] {
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1
};
static float stateAnisotropicFixW = -999.0f; static float stateAnisotropicFixW = -999.0f;
static float stateAnisotropicFixH = -999.0f; static float stateAnisotropicFixH = -999.0f;
@ -117,14 +120,12 @@ public class GlStateManager {
static float clearDepth = -999.0f; static float clearDepth = -999.0f;
public static enum TexGen { public static enum TexGen {
S, S, T, R, Q;
T,
R,
Q;
int source = GL_OBJECT_LINEAR; int source = GL_OBJECT_LINEAR;
int plane = GL_OBJECT_PLANE; int plane = GL_OBJECT_PLANE;
Vector4f vector = new Vector4f(); Vector4f vector = new Vector4f();
} }
static int stateTexGenSerial = 0; static int stateTexGenSerial = 0;
@ -197,7 +198,8 @@ public class GlStateManager {
stateLightingSerial[push] = stateLightingSerial[stateLightsStackPointer]; stateLightingSerial[push] = stateLightingSerial[stateLightsStackPointer];
stateLightsStackPointer = push; stateLightsStackPointer = push;
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack overflow!" + " Exceeded " + stateLightsStack.length + " calls to GlStateManager.pushLightCoords"); Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack overflow!" +
" Exceeded " + stateLightsStack.length + " calls to GlStateManager.pushLightCoords");
logger.error(t); logger.error(t);
} }
} }
@ -206,7 +208,8 @@ public class GlStateManager {
if(stateLightsStackPointer > 0) { if(stateLightsStackPointer > 0) {
--stateLightsStackPointer; --stateLightsStackPointer;
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack underflow!" + " Called GlStateManager.popLightCoords on an empty light stack"); Throwable t = new IndexOutOfBoundsException("GL_LIGHT direction stack underflow!" +
" Called GlStateManager.popLightCoords on an empty light stack");
logger.error(t); logger.error(t);
} }
} }
@ -236,8 +239,8 @@ public class GlStateManager {
} }
private static final Vector4f paramVector4 = new Vector4f(); private static final Vector4f paramVector4 = new Vector4f();
public static final void enableMCLight(int light, float diffuse, double dirX,
public static final void enableMCLight(int light, float diffuse, double dirX, double dirY, double dirZ, double dirW) { double dirY, double dirZ, double dirW) {
paramVector4.x = (float)dirX; paramVector4.x = (float)dirX;
paramVector4.y = (float)dirY; paramVector4.y = (float)dirY;
paramVector4.z = (float)dirZ; paramVector4.z = (float)dirZ;
@ -348,6 +351,10 @@ public class GlStateManager {
} }
public static final void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) { public static final void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) {
if(stateEnableOverlayFramebufferBlending) { // game overlay framebuffer in EntityRenderer.java
srcFactorAlpha = GL_ONE;
dstFactorAlpha = GL_ONE_MINUS_SRC_ALPHA;
}
int srcBits = (srcFactor | (srcFactorAlpha << 16)); int srcBits = (srcFactor | (srcFactorAlpha << 16));
int dstBits = (dstFactor | (dstFactorAlpha << 16)); int dstBits = (dstFactor | (dstFactorAlpha << 16));
if(srcBits != stateBlendSRC || dstBits != stateBlendDST) { if(srcBits != stateBlendSRC || dstBits != stateBlendDST) {
@ -357,6 +364,14 @@ public class GlStateManager {
} }
} }
public static final void enableOverlayFramebufferBlending() {
stateEnableOverlayFramebufferBlending = true;
}
public static final void disableOverlayFramebufferBlending() {
stateEnableOverlayFramebufferBlending = false;
}
public static final void setShaderBlendSrc(float r, float g, float b, float a) { public static final void setShaderBlendSrc(float r, float g, float b, float a) {
stateShaderBlendSrcColorR = r; stateShaderBlendSrcColorR = r;
stateShaderBlendSrcColorG = g; stateShaderBlendSrcColorG = g;
@ -456,9 +471,13 @@ public class GlStateManager {
System.err.println("TODO: rewrite text field cursor to use blending"); System.err.println("TODO: rewrite text field cursor to use blending");
} }
public static final void disableColorLogic() {} public static final void disableColorLogic() {
public static final void colorLogicOp(int opcode) {} }
public static final void colorLogicOp(int opcode) {
}
public static final void enableTexGen() { public static final void enableTexGen() {
stateTexGen = true; stateTexGen = true;
@ -524,13 +543,17 @@ public class GlStateManager {
return boundTexture[activeTexture]; return boundTexture[activeTexture];
} }
public static final void shadeModel(int mode) {} public static final void shadeModel(int mode) {
}
public static final void enableRescaleNormal() { public static final void enableRescaleNormal() {
// still not sure what this is for // still not sure what this is for
} }
public static final void disableRescaleNormal() {} public static final void disableRescaleNormal() {
}
public static final void viewport(int x, int y, int w, int h) { public static final void viewport(int x, int y, int w, int h) {
if(viewportX != x || viewportY != y || viewportW != w || viewportH != h) { if(viewportX != x || viewportY != y || viewportW != w || viewportH != h) {
@ -589,7 +612,8 @@ public class GlStateManager {
break; break;
case GL_TEXTURE: case GL_TEXTURE:
textureMatrixStack[activeTexture][textureMatrixStackPointer[activeTexture]].setIdentity(); textureMatrixStack[activeTexture][textureMatrixStackPointer[activeTexture]].setIdentity();
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
} }
@ -605,7 +629,8 @@ public class GlStateManager {
modelMatrixStackAccessSerial[push] = modelMatrixStackAccessSerial[modelMatrixStackPointer]; modelMatrixStackAccessSerial[push] = modelMatrixStackAccessSerial[modelMatrixStackPointer];
modelMatrixStackPointer = push; modelMatrixStackPointer = push;
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack overflow!" + " Exceeded " + modelMatrixStack.length + " calls to GlStateManager.pushMatrix"); Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack overflow!" +
" Exceeded " + modelMatrixStack.length + " calls to GlStateManager.pushMatrix");
logger.error(t); logger.error(t);
} }
break; break;
@ -616,7 +641,8 @@ public class GlStateManager {
projectionMatrixStackAccessSerial[push] = projectionMatrixStackAccessSerial[projectionMatrixStackPointer]; projectionMatrixStackAccessSerial[push] = projectionMatrixStackAccessSerial[projectionMatrixStackPointer];
projectionMatrixStackPointer = push; projectionMatrixStackPointer = push;
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack overflow!" + " Exceeded " + projectionMatrixStack.length + " calls to GlStateManager.pushMatrix"); Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack overflow!" +
" Exceeded " + projectionMatrixStack.length + " calls to GlStateManager.pushMatrix");
logger.error(t); logger.error(t);
} }
break; break;
@ -628,7 +654,8 @@ public class GlStateManager {
textureMatrixStackAccessSerial[activeTexture][push] = textureMatrixStackAccessSerial[activeTexture][ptr]; textureMatrixStackAccessSerial[activeTexture][push] = textureMatrixStackAccessSerial[activeTexture][ptr];
textureMatrixStackPointer[activeTexture] = push; textureMatrixStackPointer[activeTexture] = push;
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture + " matrix stack overflow!" + " Exceeded " + textureMatrixStack.length + " calls to GlStateManager.pushMatrix"); Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture + " matrix stack overflow!" +
" Exceeded " + textureMatrixStack.length + " calls to GlStateManager.pushMatrix");
logger.error(t); logger.error(t);
} }
break; break;
@ -642,7 +669,8 @@ public class GlStateManager {
if(modelMatrixStackPointer > 0) { if(modelMatrixStackPointer > 0) {
--modelMatrixStackPointer; --modelMatrixStackPointer;
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack underflow!" + " Called GlStateManager.popMatrix on an empty matrix stack"); Throwable t = new IndexOutOfBoundsException("GL_MODELVIEW matrix stack underflow!" +
" Called GlStateManager.popMatrix on an empty matrix stack");
logger.error(t); logger.error(t);
} }
break; break;
@ -650,7 +678,8 @@ public class GlStateManager {
if(projectionMatrixStackPointer > 0) { if(projectionMatrixStackPointer > 0) {
--projectionMatrixStackPointer; --projectionMatrixStackPointer;
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack underflow!" + " Called GlStateManager.popMatrix on an empty matrix stack"); Throwable t = new IndexOutOfBoundsException("GL_PROJECTION matrix stack underflow!" +
" Called GlStateManager.popMatrix on an empty matrix stack");
logger.error(t); logger.error(t);
} }
break; break;
@ -658,7 +687,8 @@ public class GlStateManager {
if(textureMatrixStackPointer[activeTexture] > 0) { if(textureMatrixStackPointer[activeTexture] > 0) {
--textureMatrixStackPointer[activeTexture]; --textureMatrixStackPointer[activeTexture];
}else { }else {
Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture + " matrix stack underflow! Called GlStateManager.popMatrix on an empty matrix stack"); Throwable t = new IndexOutOfBoundsException("GL_TEXTURE #" + activeTexture +
" matrix stack underflow! Called GlStateManager.popMatrix on an empty matrix stack");
logger.error(t); logger.error(t);
} }
break; break;
@ -696,7 +726,8 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr]; matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
matrix.m00 = 2.0f / (float)(right - left); matrix.m00 = 2.0f / (float)(right - left);
@ -719,7 +750,6 @@ public class GlStateManager {
private static final Vector3f paramVector = new Vector3f(); private static final Vector3f paramVector = new Vector3f();
private static final float toRad = 0.0174532925f; private static final float toRad = 0.0174532925f;
public static final void rotate(float angle, float x, float y, float z) { public static final void rotate(float angle, float x, float y, float z) {
paramVector.x = x; paramVector.x = x;
paramVector.y = y; paramVector.y = y;
@ -737,7 +767,8 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].rotate(angle * toRad, paramVector); textureMatrixStack[activeTexture][ptr].rotate(angle * toRad, paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
} }
@ -759,7 +790,8 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector); textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
} }
@ -781,7 +813,8 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector); textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
} }
@ -803,7 +836,8 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector); textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
} }
@ -825,13 +859,13 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector); textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
} }
private static final Matrix4f paramMatrix = new Matrix4f(); private static final Matrix4f paramMatrix = new Matrix4f();
public static final void multMatrix(float[] matrix) { public static final void multMatrix(float[] matrix) {
Matrix4f modeMatrix; Matrix4f modeMatrix;
@ -848,7 +882,8 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
modeMatrix = textureMatrixStack[activeTexture][ptr]; modeMatrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
@ -900,7 +935,8 @@ public class GlStateManager {
case GL_TEXTURE: case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture]; int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr]; matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] = ++textureMatrixAccessSerial[activeTexture]; textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break; break;
} }
float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f); float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f);
@ -925,13 +961,14 @@ public class GlStateManager {
private static final Matrix4f unprojA = new Matrix4f(); private static final Matrix4f unprojA = new Matrix4f();
private static final Matrix4f unprojB = new Matrix4f(); private static final Matrix4f unprojB = new Matrix4f();
private static final Vector4f unprojC = new Vector4f(); private static final Vector4f unprojC = new Vector4f();
public static final void gluUnProject(float p1, float p2, float p3, float[] modelview, float[] projection,
public static final void gluUnProject(float p1, float p2, float p3, float[] modelview, float[] projection, int[] viewport, float[] objectcoords) { int[] viewport, float[] objectcoords) {
unprojA.load(modelview); unprojA.load(modelview);
unprojB.load(projection); unprojB.load(projection);
Matrix4f.mul(unprojA, unprojB, unprojB); Matrix4f.mul(unprojA, unprojB, unprojB);
unprojB.invert(); unprojB.invert();
unprojC.set(((p1 - (float) viewport[0]) / (float) viewport[2]) * 2f - 1f, ((p2 - (float) viewport[1]) / (float) viewport[3]) * 2f - 1f, p3, 1.0f); unprojC.set(((p1 - (float)viewport[0]) / (float)viewport[2]) * 2f - 1f,
((p2 - (float)viewport[1]) / (float)viewport[3]) * 2f - 1f, p3, 1.0f);
Matrix4f.transform(unprojB, unprojC, unprojC); Matrix4f.transform(unprojB, unprojC, unprojC);
objectcoords[0] = unprojC.x / unprojC.w; objectcoords[0] = unprojC.x / unprojC.w;
objectcoords[1] = unprojC.y / unprojC.w; objectcoords[1] = unprojC.y / unprojC.w;